diff options
author | Simon Rettberg | 2014-05-27 02:01:04 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-05-27 02:01:04 +0200 |
commit | b0d9fd5a5c7bb93d69bb693dd630f097ab396322 (patch) | |
tree | 20d91d74011c46d205564cd8148b73a446577dea | |
parent | daemon optional (diff) | |
download | ldadp-b0d9fd5a5c7bb93d69bb693dd630f097ab396322.tar.gz ldadp-b0d9fd5a5c7bb93d69bb693dd630f097ab396322.tar.xz ldadp-b0d9fd5a5c7bb93d69bb693dd630f097ab396322.zip |
Port configurable
-rw-r--r-- | ldadp.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -16,6 +16,8 @@ static void listen_callback(void *data, int haveIn, int haveOut, int doCleanup); static void loadConfig(char *file); +static int localPort = 1234; + int main(int argc, char **argv) { BOOL isdaemon = TRUE; @@ -30,6 +32,7 @@ int main(int argc, char **argv) argc--; } loadConfig(argv[1]); + if (localPort < 1 || localPort > 65535) bail("Invalid port given in config"); proxy_init(); char listen_addr[4] = {0, 0, 0, 0}; // Setup socket @@ -37,7 +40,7 @@ int main(int argc, char **argv) lsn.callback = &listen_callback; lsn.fd = socket_tcp4(); if (lsn.fd == -1) bail("Could not create listen socket"); - if (socket_bind4_reuse(lsn.fd, listen_addr, 1234) == -1) bail("Could not bind to listening port"); + if (socket_bind4_reuse(lsn.fd, listen_addr, localPort) == -1) bail("Could not bind to listening port"); if (socket_listen(lsn.fd, 10) == -1) bail("Could not listen"); // Setup epoll if (ePoll_init() == -1) bail("epoll_create failed"); @@ -87,6 +90,9 @@ static int loadConfig_handler(void *stuff, const char *section, const char *key, if (strcmp(key, "home") == 0 && *value != '\0') { server_setHomeTemplate(section, value); } + if (strcmp(key, "port") == 0) { + localPort = atoi(value); + } return 1; } |