1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Add boolean toggle for irssiproxy being enabled

This commit is contained in:
Hans Nielsen 2014-06-25 22:29:05 -07:00
parent aaa0f73eac
commit 6a28bad814
2 changed files with 33 additions and 1 deletions

View File

@ -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);

View File

@ -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");
}