host: deal with host/peer null pointers in debug messages
[project/unetd.git] / main.c
diff --git a/main.c b/main.c
index 3bd774471b8fd8baf3d4917b61de59a548dc566f..c9ce132a2cfa616d88f92c619cfd9d2b5cec4c14 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 2022 Felix Fietkau <nbd@nbd.name>
  */
@@ -17,7 +17,8 @@ struct cmdline_network {
 static struct cmdline_network *cmd_nets;
 static const char *hosts_file;
 const char *mssfix_path = UNETD_MSS_BPF_PATH;
-bool dummy_mode;
+const char *data_dir = UNETD_DATA_DIR;
+int global_pex_port = UNETD_GLOBAL_PEX_PORT;
 bool debug;
 
 static void
@@ -98,14 +99,14 @@ int main(int argc, char **argv)
        struct cmdline_network *net;
        int ch;
 
-       while ((ch = getopt(argc, argv, "Ddh:M:N:")) != -1) {
+       while ((ch = getopt(argc, argv, "D:dh:M:N:P:")) != -1) {
                switch (ch) {
+               case 'D':
+                       data_dir = optarg;
+                       break;
                case 'd':
                        debug = true;
                        break;
-               case 'D':
-                       dummy_mode = true;
-                       break;
                case 'h':
                        hosts_file = optarg;
                        break;
@@ -118,14 +119,19 @@ int main(int argc, char **argv)
                case 'M':
                        mssfix_path = optarg;
                        break;
+               case 'P':
+                       global_pex_port = atoi(optarg);
+                       break;
                }
        }
 
        uloop_init();
        unetd_ubus_init();
        unetd_write_hosts();
+       global_pex_open();
        add_networks();
        uloop_run();
+       pex_close();
        network_free_all();
        uloop_done();