From 0f707e47a346cbace8f4a889ab85c819bb71df9b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 30 Oct 2013 10:53:00 +0100 Subject: make pacredir listen on localhost only --- pacredir.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pacredir.c b/pacredir.c index 3fa106a..eaf8134 100644 --- a/pacredir.c +++ b/pacredir.c @@ -5,12 +5,14 @@ * of the GNU General Public License, incorporated herein by reference. */ +#include #include #include #include #include #include #include +#include #include #include @@ -372,6 +374,7 @@ int main(int argc, char ** argv) { int ret = 1; struct MHD_Daemon * mhd; struct hosts * tmphosts; + struct sockaddr_in address; printf("Starting pacredir/" VERSION "\n"); @@ -411,8 +414,13 @@ int main(int argc, char ** argv) { goto fail; } + /* prepare struct to make microhttpd listen on localhost only */ + address.sin_family = AF_INET; + address.sin_port = htons(PORT_PACREDIR); + inet_pton(AF_INET, "127.0.0.1", &address.sin_addr); + /* start http server */ - if ((mhd = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, PORT_PACREDIR, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END)) == NULL) { + if ((mhd = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, PORT_PACREDIR, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, &address, MHD_OPTION_END)) == NULL) { fprintf(stderr, "Could not start daemon on port %d.\n", PORT_PACREDIR); return EXIT_FAILURE; } -- cgit v1.2.3-70-g09d2