int unlink;
const char *unixsock;
+ const char *bind;
const char *docroot;
};
"Syntax: %s [ OPTS ] <docroot>\n"
" -p - port\n"
" -U - bind to unix socket\n"
+ " -H - address to bind (default: 0.0.0.0)\n"
" -u - unlink unix socket before bind\n"
" -I - IOCP\n"
" -m - max body size\n"
memset(&o, 0, sizeof(o));
- while ((opt = getopt(argc, argv, "hp:U:m:uIv")) != -1) {
+ while ((opt = getopt(argc, argv, "hp:U:m:uIvH:")) != -1) {
switch (opt) {
case 'p': o.port = atoi(optarg); break;
case 'U': o.unixsock = optarg; break;
case 'I': o.iocp = 1; break;
case 'm': o.max_body_size = atoi(optarg); break;
case 'v': ++o.verbose; break;
+ case 'H': o.bind = optarg; break;
case 'h': print_usage(stdout, argv[0], 0); break;
default : fprintf(stderr, "Unknown option %c\n", opt); break;
}
#endif /* EVENT__HAVE_STRUCT_SOCKADDR_UN */
}
else {
- handle = evhttp_bind_socket_with_handle(http, "0.0.0.0", o.port);
+ handle = evhttp_bind_socket_with_handle(http, o.bind, o.port);
if (!handle) {
- fprintf(stderr, "couldn't bind to port %d. Exiting.\n", o.port);
+ fprintf(stderr, "couldn't bind to %s:%d. Exiting.\n", o.bind, o.port);
ret = 1;
goto err;
}