mirror of
https://github.com/irssi/irssi.git
synced 2026-08-21 01:22:26 +02:00
Add boolean toggle for irssiproxy being enabled
This commit is contained in:
parent
aaa0f73eac
commit
6a28bad814
2 changed files with 33 additions and 1 deletions
|
|
@ -37,6 +37,8 @@ GSList *proxy_clients;
|
||||||
static GString *next_line;
|
static GString *next_line;
|
||||||
static int ignore_next;
|
static int ignore_next;
|
||||||
|
|
||||||
|
static int enabled = FALSE;
|
||||||
|
|
||||||
static void remove_client(CLIENT_REC *rec)
|
static void remove_client(CLIENT_REC *rec)
|
||||||
{
|
{
|
||||||
g_return_if_fail(rec != NULL);
|
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)
|
void proxy_listen_init(void)
|
||||||
{
|
{
|
||||||
|
if (enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
enabled = TRUE;
|
||||||
|
|
||||||
next_line = g_string_new(NULL);
|
next_line = g_string_new(NULL);
|
||||||
|
|
||||||
proxy_clients = NULL;
|
proxy_clients = NULL;
|
||||||
|
|
@ -703,6 +710,11 @@ void proxy_listen_init(void)
|
||||||
|
|
||||||
void proxy_listen_deinit(void)
|
void proxy_listen_deinit(void)
|
||||||
{
|
{
|
||||||
|
if (!enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
enabled = FALSE;
|
||||||
|
|
||||||
while (proxy_listens != NULL)
|
while (proxy_listens != NULL)
|
||||||
remove_listen(proxy_listens->data);
|
remove_listen(proxy_listens->data);
|
||||||
g_string_free(next_line, TRUE);
|
g_string_free(next_line, TRUE);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,12 @@
|
||||||
|
|
||||||
static void cmd_proxy_status(const char *data, IRC_SERVER_REC *server)
|
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;
|
GSList *tmp;
|
||||||
|
|
||||||
printtext(server, NULL, MSGLEVEL_CLIENTNOTICE,
|
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);
|
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)
|
void irc_proxy_init(void)
|
||||||
{
|
{
|
||||||
settings_add_str("irssiproxy", "irssiproxy_ports", "");
|
settings_add_str("irssiproxy", "irssiproxy_ports", "");
|
||||||
settings_add_str("irssiproxy", "irssiproxy_password", "");
|
settings_add_str("irssiproxy", "irssiproxy_password", "");
|
||||||
settings_add_str("irssiproxy", "irssiproxy_bind", "");
|
settings_add_str("irssiproxy", "irssiproxy_bind", "");
|
||||||
|
settings_add_bool("irssiproxy", "irssiproxy", TRUE);
|
||||||
|
|
||||||
if (*settings_get_str("irssiproxy_password") == '\0') {
|
if (*settings_get_str("irssiproxy_password") == '\0') {
|
||||||
/* no password - bad idea! */
|
/* no password - bad idea! */
|
||||||
|
|
@ -77,7 +93,11 @@ void irc_proxy_init(void)
|
||||||
command_bind("proxy", NULL, (SIGNAL_FUNC) cmd_proxy);
|
command_bind("proxy", NULL, (SIGNAL_FUNC) cmd_proxy);
|
||||||
command_bind("proxy status", NULL, (SIGNAL_FUNC) cmd_proxy_status);
|
command_bind("proxy status", NULL, (SIGNAL_FUNC) cmd_proxy_status);
|
||||||
|
|
||||||
|
signal_add_first("setup changed", (SIGNAL_FUNC) irc_proxy_setup_changed);
|
||||||
|
|
||||||
|
if (settings_get_bool("irssiproxy")) {
|
||||||
proxy_listen_init();
|
proxy_listen_init();
|
||||||
|
}
|
||||||
settings_check();
|
settings_check();
|
||||||
module_register("proxy", "irc");
|
module_register("proxy", "irc");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue