diff options
author | Hans Nielsen <hans@stackallocated.com> | 2014-06-25 22:29:05 -0700 |
---|---|---|
committer | Hans Nielsen <hans@stackallocated.com> | 2015-02-24 19:52:17 -0800 |
commit | 6a28bad81440290e799c4d4985f31bea6493f58b (patch) | |
tree | e4f685a7bf37f9ee7b38efeabc40b86af28a9ea6 /src/irc | |
parent | aaa0f73eac88316978c65fb0f0c8b5d23d1dc100 (diff) | |
download | irssi-6a28bad81440290e799c4d4985f31bea6493f58b.zip |
Add boolean toggle for irssiproxy being enabled
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/proxy/listen.c | 12 | ||||
-rw-r--r-- | src/irc/proxy/proxy.c | 22 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c index df0d7479..a5772301 100644 --- a/src/irc/proxy/listen.c +++ b/src/irc/proxy/listen.c @@ -37,6 +37,8 @@ GSList *proxy_clients; static GString *next_line; static int ignore_next; +static int enabled = FALSE; + static void remove_client(CLIENT_REC *rec) { g_return_if_fail(rec != NULL); @@ -682,6 +684,11 @@ static void sig_dump(CLIENT_REC *client, const char *data) void proxy_listen_init(void) { + if (enabled) { + return; + } + enabled = TRUE; + next_line = g_string_new(NULL); proxy_clients = NULL; @@ -703,6 +710,11 @@ void proxy_listen_init(void) void proxy_listen_deinit(void) { + if (!enabled) { + return; + } + enabled = FALSE; + while (proxy_listens != NULL) remove_listen(proxy_listens->data); g_string_free(next_line, TRUE); diff --git a/src/irc/proxy/proxy.c b/src/irc/proxy/proxy.c index 75da112c..1cc8aebe 100644 --- a/src/irc/proxy/proxy.c +++ b/src/irc/proxy/proxy.c @@ -27,6 +27,12 @@ static void cmd_proxy_status(const char *data, IRC_SERVER_REC *server) { + if (!settings_get_bool("irssiproxy")) { + printtext(server, NULL, MSGLEVEL_CLIENTNOTICE, + "Proxy is currently disabled"); + return; + } + GSList *tmp; printtext(server, NULL, MSGLEVEL_CLIENTNOTICE, @@ -54,11 +60,21 @@ static void cmd_proxy(const char *data, IRC_SERVER_REC *server, void *item) command_runsub("proxy", data, server, item); } +static void irc_proxy_setup_changed(void) +{ + if (settings_get_bool("irssiproxy")) { + proxy_listen_init(); + } else { + proxy_listen_deinit(); + } +} + void irc_proxy_init(void) { settings_add_str("irssiproxy", "irssiproxy_ports", ""); settings_add_str("irssiproxy", "irssiproxy_password", ""); settings_add_str("irssiproxy", "irssiproxy_bind", ""); + settings_add_bool("irssiproxy", "irssiproxy", TRUE); if (*settings_get_str("irssiproxy_password") == '\0') { /* no password - bad idea! */ @@ -77,7 +93,11 @@ void irc_proxy_init(void) command_bind("proxy", NULL, (SIGNAL_FUNC) cmd_proxy); command_bind("proxy status", NULL, (SIGNAL_FUNC) cmd_proxy_status); - proxy_listen_init(); + signal_add_first("setup changed", (SIGNAL_FUNC) irc_proxy_setup_changed); + + if (settings_get_bool("irssiproxy")) { + proxy_listen_init(); + } settings_check(); module_register("proxy", "irc"); } |