Add bind address and port to cmdline arguments. Add log of address and port.
[umurmur.git] / src / main.c
index cce178a1ffe458d90de0efd9fcb64aabc4ce580a..d1351ddc080f9c76a761023f1f43fb2e288975b6 100644 (file)
@@ -39,6 +39,8 @@
 #include <signal.h>
 #include <sched.h>
 #include <errno.h>
+#include <string.h>
+#include <stdlib.h>
 
 #include "server.h"
 #include "ssl.h"
@@ -49,6 +51,8 @@
 #include "version.h"
 
 char system_string[64], version_string[64];
+int bindport;
+char *bindaddr;
 
 void lockfile(const char *pidfile)
 {
@@ -127,6 +131,8 @@ void printhelp()
        printf("       -p <pidfile>   - Write PID to this file\n");
        printf("       -c <conf file> - Specify configuration file\n");
        printf("       -r             - Run with realtime priority\n");
+       printf("       -a <address>   - Bind to IP address\n");
+       printf("       -b <port>      - Bind to port\n");
        printf("       -h             - Print this help\n");
        exit(0);
 }
@@ -140,7 +146,7 @@ int main(int argc, char **argv)
        struct utsname utsbuf;
        
        /* Arguments */
-       while ((c = getopt(argc, argv, "drp:c:h")) != EOF) {
+       while ((c = getopt(argc, argv, "drp:c:a:b:h")) != EOF) {
                switch(c) {
                case 'c':
                        conffile = optarg;
@@ -148,6 +154,12 @@ int main(int argc, char **argv)
                case 'p':
                        pidfile = optarg;
                        break;
+               case 'a':
+                       bindaddr = optarg;
+                       break;
+               case 'b':
+                       bindport = atoi(optarg);
+                       break;
                case 'd':
                        nodaemon = true;
                        break;
@@ -182,6 +194,7 @@ int main(int argc, char **argv)
        signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
        signal(SIGTTOU, SIG_IGN);
        signal(SIGTTIN, SIG_IGN);
+       signal(SIGPIPE, SIG_IGN);
        signal(SIGHUP, signal_handler); /* catch hangup signal */
        signal(SIGTERM, signal_handler); /* catch kill signal */
        
@@ -196,7 +209,7 @@ int main(int argc, char **argv)
        }
        
        /* Initializing */
-       SSL_init();
+       SSLi_init();
        Chan_init();
        Client_init();
 
@@ -205,7 +218,7 @@ int main(int argc, char **argv)
        
        Server_run();
        
-       SSL_deinit();
+       SSLi_deinit();
        Chan_free();
        Log_free();
        Conf_deinit();