summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-10-30 10:53:00 +0100
committerGravatar Christian Hesse <mail@eworm.de>2013-10-30 10:53:00 +0100
commit0f707e47a346cbace8f4a889ab85c819bb71df9b (patch)
treeeafa312f04820cd7fd19832301a522c3aa47127c
parente6b9e97e92c4ac2044c0ba3aa469274eff695b1d (diff)
downloadpacredir-0f707e47a346cbace8f4a889ab85c819bb71df9b.tar.gz
pacredir-0f707e47a346cbace8f4a889ab85c819bb71df9b.tar.zst
make pacredir listen on localhost only
-rw-r--r--pacredir.c10
1 files changed, 9 insertions, 1 deletions
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 <arpa/inet.h>
#include <assert.h>
#include <math.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/socket.h>
#include <sys/stat.h>
#include <time.h>
@@ -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;
}