diff options
Diffstat (limited to 'network/main.c')
-rw-r--r-- | network/main.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/network/main.c b/network/main.c index 6260ac4e..3ede75fe 100644 --- a/network/main.c +++ b/network/main.c @@ -52,13 +52,12 @@ static struct network_conf conf = { .connection_enabled = TRUE, .server_enabled = TRUE, .iface_prefix = NULL, - .conn.panu_script = NULL, - .conn.gn_script = NULL, - .conn.nap_script = NULL, - .server.panu_iface = NULL, - .server.gn_iface = NULL, - .server.nap_iface = NULL, - .server.disable_security = FALSE + .panu_script = NULL, + .gn_script = NULL, + .nap_script = NULL, + .gn_iface = NULL, + .nap_iface = NULL, + .security = TRUE }; static void sig_term(int sig) @@ -70,6 +69,7 @@ static void read_config(const char *file) { GKeyFile *keyfile; GError *err = NULL; + const char *disabled; keyfile = g_key_file_new(); @@ -80,72 +80,75 @@ static void read_config(const char *file) return; } - conf.iface_prefix = g_key_file_get_string(keyfile, "Connection", - "InterfacePrefix", &err); - if (!conf.iface_prefix) - conf.iface_prefix = g_strdup(IFACE_PREFIX); + disabled = g_key_file_get_string(keyfile, "General", + "Disable", &err); if (err) { debug("%s: %s", file, err->message); g_error_free(err); err = NULL; + } else { + if (strstr(disabled, "Connection")) + conf.connection_enabled = FALSE; + if (strstr(disabled, "Server")) + conf.server_enabled = FALSE; } - conf.conn.panu_script = g_key_file_get_string(keyfile, "Connection", - "PANUScript", &err); + conf.iface_prefix = g_key_file_get_string(keyfile, "General", + "InterfacePrefix", &err); + if (!conf.iface_prefix) + conf.iface_prefix = g_strdup(IFACE_PREFIX); if (err) { debug("%s: %s", file, err->message); g_error_free(err); err = NULL; } - conf.conn.gn_script = g_key_file_get_string(keyfile, "Connection", - "GNScript", &err); + conf.security = g_key_file_get_boolean(keyfile, "General", + "DisableSecurity", &err); if (err) { debug("%s: %s", file, err->message); g_error_free(err); err = NULL; } - conf.conn.nap_script = g_key_file_get_string(keyfile, "Connection", - "NAPScript", &err); + conf.panu_script = g_key_file_get_string(keyfile, "PANU Role", + "Script", &err); if (err) { debug("%s: %s", file, err->message); g_error_free(err); err = NULL; } - conf.server.panu_iface = g_key_file_get_string(keyfile, "Server", - "PANUInterface", &err); - if (!conf.server.panu_iface) - conf.server.panu_iface = g_strdup(PANU_IFACE); + conf.gn_script = g_key_file_get_string(keyfile, "GN Role", + "Script", &err); if (err) { debug("%s: %s", file, err->message); g_error_free(err); err = NULL; } - conf.server.gn_iface = g_key_file_get_string(keyfile, "Server", - "GNInterface", &err); - if (!conf.server.gn_iface) - conf.server.gn_iface = g_strdup(GN_IFACE); + conf.nap_script = g_key_file_get_string(keyfile, "NAP Role", + "Script", &err); if (err) { debug("%s: %s", file, err->message); g_error_free(err); err = NULL; } - conf.server.nap_iface = g_key_file_get_string(keyfile, "Server", - "NAPInterface", &err); - if (!conf.server.nap_iface) - conf.server.nap_iface = g_strdup(NAP_IFACE); + conf.gn_iface = g_key_file_get_string(keyfile, "GN Role", + "Interface", &err); + if (!conf.gn_iface) + conf.gn_iface = g_strdup(GN_IFACE); if (err) { debug("%s: %s", file, err->message); g_error_free(err); err = NULL; } - conf.server.disable_security = g_key_file_get_boolean(keyfile, "Server", - "DisableSecurity", &err); + conf.nap_iface = g_key_file_get_string(keyfile, "NAP Role", + "Interface", &err); + if (!conf.nap_iface) + conf.nap_iface = g_strdup(NAP_IFACE); if (err) { debug("%s: %s", file, err->message); g_error_free(err); @@ -153,12 +156,10 @@ static void read_config(const char *file) } debug("Config options: InterfacePrefix=%s, PANUScript=%s, GNScript=%s, " - "NAPScript=%s, PANUInterface=%s, GNInterface=%s, " - "NAPInterface=%s, DisableSecurity=%s", conf.iface_prefix, - conf.conn.panu_script, conf.conn.gn_script, conf.conn.nap_script, - conf.server.panu_iface, conf.server.gn_iface, - conf.server.nap_iface, - conf.server.disable_security ? "true" : "false"); + "NAPScript=%s, GNInterface=%s, NAPInterface=%s, Security=%s", + conf.iface_prefix, conf.panu_script, conf.gn_script, + conf.nap_script, conf.gn_iface, conf.nap_iface, + conf.security ? "true" : "false"); g_key_file_free(keyfile); } |