Added an initial implementation of HTTPS.
[ashd.git] / src / plaintcp.c
index 03da055..00b6f3c 100644 (file)
@@ -46,7 +46,7 @@ struct tcpconn {
     struct tcpport *port;
 };
 
-static int listensock4(int port)
+int listensock4(int port)
 {
     struct sockaddr_in name;
     int fd;
@@ -70,7 +70,7 @@ static int listensock4(int port)
     return(fd);
 }
 
-static int listensock6(int port)
+int listensock6(int port)
 {
     struct sockaddr_in6 name;
     int fd;
@@ -107,6 +107,7 @@ static int initreq(struct conn *conn, struct hthead *req)
        headappheader(req, "X-Ash-Port", sprintf3("%i", ntohs(((struct sockaddr_in6 *)&tcp->name)->sin6_port)));
     }
     headappheader(req, "X-Ash-Server-Port", sprintf3("%i", tcp->port->sport));
+    headappheader(req, "X-Ash-Protocol", "http");
     return(0);
 }
 
@@ -162,7 +163,8 @@ void handleplain(int argc, char **argp, char **argv)
     for(i = 0; i < argc; i++) {
        if(!strcmp(argp[i], "help")) {
            printf("plain handler parameters:\n");
-           printf("\tport=TCP-PORT (default is 80)\n");
+           printf("\tport=TCP-PORT   [80]\n");
+           printf("\t\tThe TCP port to listen on.\n");
            exit(0);
        } else if(!strcmp(argp[i], "port")) {
            port = atoi(argv[i]);
@@ -185,6 +187,9 @@ void handleplain(int argc, char **argp, char **argv)
            exit(1);
        }
     } else {
-       mustart(listenloop, fd, port);
+       omalloc(tcp);
+       tcp->fd = fd;
+       tcp->sport = port;
+       mustart(listenloop, tcp);
     }
 }