X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuhttpd.git;a=blobdiff_plain;f=main.c;h=e53a3114c52e76e9c1dfe22c6b49387a5a2ee4d1;hp=f88506cca812b5a947aed360912ab63dbacbb4ea;hb=d6366570bf706f3970b7f106a1ccd49b584559cf;hpb=ac7670faba12e23b8ec7e866dcfe1d98d3921b40;ds=sidebyside diff --git a/main.c b/main.c index f88506c..e53a311 100644 --- a/main.c +++ b/main.c @@ -103,6 +103,7 @@ static int add_listener_arg(char *arg, bool tls) char *host = NULL; char *port = arg; char *s; + int l; s = strrchr(arg, ':'); if (s) { @@ -111,6 +112,14 @@ static int add_listener_arg(char *arg, bool tls) *s = 0; } + if (host && *host == '[') { + l = strlen(host); + if (l >= 2) { + host[l-1] = 0; + host++; + } + } + return uh_socket_bind(host, port, tls); } @@ -156,7 +165,7 @@ static int usage(const char *name) return 1; } -static void init_defaults(void) +static void init_defaults_pre(void) { conf.script_timeout = 60; conf.network_timeout = 30; @@ -166,7 +175,10 @@ static void init_defaults(void) conf.realm = "Protected Area"; conf.cgi_prefix = "/cgi-bin"; conf.cgi_path = "/sbin:/usr/sbin:/bin:/usr/bin"; +} +static void init_defaults_post(void) +{ uh_index_add("index.html"); uh_index_add("index.htm"); uh_index_add("default.html"); @@ -204,7 +216,7 @@ int main(int argc, char **argv) BUILD_BUG_ON(sizeof(uh_buf) < PATH_MAX); uh_dispatch_add(&cgi_dispatch); - init_defaults(); + init_defaults_pre(); signal(SIGPIPE, SIG_IGN); while ((ch = getopt(argc, argv, "afSDRC:K:E:I:p:s:h:c:l:L:d:r:m:n:N:x:i:t:k:T:A:u:U:")) != -1) { @@ -334,6 +346,7 @@ int main(int argc, char **argv) } printf("%s", port); + return 0; break; /* basic auth realm */ @@ -393,6 +406,7 @@ int main(int argc, char **argv) } uh_config_parse(); + init_defaults_post(); if (!bound) { fprintf(stderr, "Error: No sockets bound, unable to continue\n");