mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
add nocap flag
This commit is contained in:
parent
61237ee6c0
commit
8a5d5d384e
@ -95,6 +95,19 @@ static void sig_server_add_fill(IRC_SERVER_SETUP_REC *rec,
|
||||
rec->starttls = STARTTLS_ENABLED;
|
||||
rec->use_tls = 0;
|
||||
}
|
||||
if (g_hash_table_lookup(optlist, "nocap"))
|
||||
rec->no_cap = 1;
|
||||
if (g_hash_table_lookup(optlist, "cap"))
|
||||
rec->no_cap = 0;
|
||||
}
|
||||
|
||||
static void sig_server_waiting_info(IRC_SERVER_REC *server, const char *version)
|
||||
{
|
||||
if (!IS_IRC_SERVER(server))
|
||||
return;
|
||||
|
||||
printformat(server, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_SERVER_WAITING_CAP_LS, server,
|
||||
version);
|
||||
}
|
||||
|
||||
/* SYNTAX: SERVER LIST */
|
||||
@ -118,6 +131,8 @@ static void cmd_server_list(const char *data)
|
||||
g_string_append(str, "autoconnect, ");
|
||||
if (rec->no_proxy)
|
||||
g_string_append(str, "noproxy, ");
|
||||
if (rec->no_cap)
|
||||
g_string_append(str, "nocap, ");
|
||||
if (rec->starttls == STARTTLS_DISALLOW)
|
||||
g_string_append(str, "disallow_starttls, ");
|
||||
if (rec->starttls == STARTTLS_ENABLED)
|
||||
@ -167,17 +182,20 @@ static void cmd_server_list(const char *data)
|
||||
void fe_irc_server_init(void)
|
||||
{
|
||||
signal_add("server add fill", (SIGNAL_FUNC) sig_server_add_fill);
|
||||
signal_add("server waiting cap ls", (SIGNAL_FUNC) sig_server_waiting_info);
|
||||
command_bind("server list", NULL, (SIGNAL_FUNC) cmd_server_list);
|
||||
|
||||
command_set_options("server add", "-ircnet -network -cmdspeed -cmdmax -querychans starttls "
|
||||
"nostarttls disallow_starttls nodisallow_starttls");
|
||||
command_set_options("server add",
|
||||
"-ircnet -network -cmdspeed -cmdmax -querychans starttls "
|
||||
"nostarttls disallow_starttls nodisallow_starttls cap nocap");
|
||||
command_set_options("server modify",
|
||||
"-ircnet -network -cmdspeed -cmdmax -querychans starttls nostarttls "
|
||||
"disallow_starttls nodisallow_starttls");
|
||||
"disallow_starttls nodisallow_starttls cap nocap");
|
||||
}
|
||||
|
||||
void fe_irc_server_deinit(void)
|
||||
{
|
||||
signal_remove("server add fill", (SIGNAL_FUNC) sig_server_add_fill);
|
||||
signal_remove("server waiting cap ls", (SIGNAL_FUNC) sig_server_waiting_info);
|
||||
command_unbind("server list", (SIGNAL_FUNC) cmd_server_list);
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ FORMAT_REC fecommon_irc_formats[] = {
|
||||
{ "setupserver_header", "%#Server Port Network Settings", 0 },
|
||||
{ "setupserver_line", "%#%|$[!20]0 $[5]1 $[10]2 $3", 4, { 0, 1, 0, 0 } },
|
||||
{ "setupserver_footer", "", 0 },
|
||||
{ "server_waiting_cap_ls", "Waiting for CAP LS response...", 2, { 0, 0 } },
|
||||
{ "sasl_success", "SASL authentication succeeded", 0 },
|
||||
{ "sasl_error", "Cannot authenticate via SASL ($0)", 1, { 0 } },
|
||||
{ "cap_req", "Capabilities requested: $0", 1, { 0 } },
|
||||
|
@ -23,6 +23,7 @@ enum {
|
||||
IRCTXT_SETUPSERVER_HEADER,
|
||||
IRCTXT_SETUPSERVER_LINE,
|
||||
IRCTXT_SETUPSERVER_FOOTER,
|
||||
IRCTXT_SERVER_WAITING_CAP_LS,
|
||||
IRCTXT_SASL_SUCCESS,
|
||||
IRCTXT_SASL_ERROR,
|
||||
IRCTXT_CAP_REQ,
|
||||
|
@ -1053,7 +1053,7 @@ void irc_commands_init(void)
|
||||
signal_add("whois end", (SIGNAL_FUNC) event_end_of_whois);
|
||||
signal_add("whowas event", (SIGNAL_FUNC) event_whowas);
|
||||
|
||||
command_set_options("connect", "+ircnet starttls disallow_starttls");
|
||||
command_set_options("connect", "+ircnet starttls disallow_starttls nocap");
|
||||
command_set_options("topic", "delete");
|
||||
command_set_options("list", "yes");
|
||||
command_set_options("away", "one all");
|
||||
|
@ -53,6 +53,7 @@ static void sig_server_connect_copy(SERVER_CONNECT_REC **dest,
|
||||
rec->sasl_password = g_strdup(src->sasl_password);
|
||||
rec->disallow_starttls = src->disallow_starttls;
|
||||
rec->starttls = src->starttls;
|
||||
rec->no_cap = src->no_cap;
|
||||
*dest = (SERVER_CONNECT_REC *) rec;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,8 @@ static void sig_server_setup_fill_reconn(IRC_SERVER_CONNECT_REC *conn,
|
||||
conn->disallow_starttls = 1;
|
||||
else if (sserver->starttls == STARTTLS_ENABLED)
|
||||
conn->starttls = 1;
|
||||
if (sserver->no_cap)
|
||||
conn->no_cap = 1;
|
||||
}
|
||||
|
||||
static void sig_server_setup_fill_connect(IRC_SERVER_CONNECT_REC *conn, GHashTable *optlist)
|
||||
@ -77,6 +79,10 @@ static void sig_server_setup_fill_optlist(IRC_SERVER_CONNECT_REC *conn, GHashTab
|
||||
} else if (g_hash_table_lookup(optlist, "disallow_starttls") != NULL) {
|
||||
conn->disallow_starttls = 1;
|
||||
}
|
||||
if (g_hash_table_lookup(optlist, "nocap"))
|
||||
conn->no_cap = 1;
|
||||
if (g_hash_table_lookup(optlist, "cap"))
|
||||
conn->no_cap = 0;
|
||||
}
|
||||
|
||||
static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn,
|
||||
@ -195,6 +201,7 @@ static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node)
|
||||
if (rec->starttls == STARTTLS_ENABLED) {
|
||||
rec->use_tls = 0;
|
||||
}
|
||||
rec->no_cap = config_node_get_bool(node, "no_cap", FALSE);
|
||||
}
|
||||
|
||||
static void sig_server_setup_saved(IRC_SERVER_SETUP_REC *rec,
|
||||
@ -213,6 +220,8 @@ static void sig_server_setup_saved(IRC_SERVER_SETUP_REC *rec,
|
||||
iconfig_node_set_bool(node, "starttls", rec->starttls);
|
||||
else
|
||||
iconfig_node_set_str(node, "starttls", NULL);
|
||||
if (rec->no_cap)
|
||||
iconfig_node_set_bool(node, "no_cap", TRUE);
|
||||
}
|
||||
|
||||
void irc_servers_setup_init(void)
|
||||
|
@ -25,6 +25,7 @@ typedef struct {
|
||||
int cmd_queue_speed;
|
||||
int max_query_chans;
|
||||
int starttls;
|
||||
int no_cap : 1;
|
||||
} IRC_SERVER_SETUP_REC;
|
||||
|
||||
void irc_servers_setup_init(void);
|
||||
|
@ -309,11 +309,16 @@ static void server_init_1(IRC_SERVER_REC *server)
|
||||
server->wait_cmd = g_get_real_time();
|
||||
server->wait_cmd += 120 * G_USEC_PER_SEC;
|
||||
|
||||
irc_send_cmd_now(server, "CAP LS " CAP_LS_VERSION);
|
||||
/* to detect non-CAP servers, send this bogus join */
|
||||
irc_send_cmd_now(server, "JOIN ");
|
||||
if (!conn->no_cap) {
|
||||
signal_emit("server waiting cap ls", 2, server, CAP_LS_VERSION);
|
||||
irc_send_cmd_now(server, "CAP LS " CAP_LS_VERSION);
|
||||
/* to detect non-CAP servers, send this bogus join */
|
||||
irc_send_cmd_now(server, "JOIN ");
|
||||
}
|
||||
if (conn->starttls)
|
||||
irc_server_send_starttls(server);
|
||||
else if (conn->no_cap)
|
||||
server_init_2(server);
|
||||
}
|
||||
|
||||
static void init_ssl_loop(IRC_SERVER_REC *server, GIOChannel *handle)
|
||||
|
@ -63,6 +63,7 @@ struct _IRC_SERVER_CONNECT_REC {
|
||||
int max_kicks, max_msgs, max_modes, max_whois;
|
||||
int disallow_starttls:1;
|
||||
int starttls:1;
|
||||
int no_cap:1;
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
|
@ -87,6 +87,7 @@ static void sig_session_save_server(IRC_SERVER_REC *server, CONFIG_REC *config,
|
||||
server->connrec->starttls ? STARTTLS_ENABLED :
|
||||
STARTTLS_NOTSET);
|
||||
|
||||
config_node_set_bool(config, node, "no_cap", server->connrec->no_cap);
|
||||
config_node_set_bool(config, node, "isupport_sent", server->isupport_sent);
|
||||
isupport = config_node_section(config, node, "isupport", NODE_TYPE_BLOCK);
|
||||
isupport_data.config = config;
|
||||
@ -115,6 +116,7 @@ static void sig_session_restore_server(IRC_SERVER_REC *server,
|
||||
server->emode_known = config_node_get_bool(node, "emode_known", FALSE);
|
||||
server->isupport_sent = config_node_get_bool(node, "isupport_sent", FALSE);
|
||||
|
||||
server->connrec->no_cap = config_node_get_bool(node, "no_cap", FALSE);
|
||||
server->connrec->sasl_mechanism = config_node_get_int(node, "sasl_mechanism", SASL_MECHANISM_NONE);
|
||||
/* The fields below might have been filled when loading the chatnet
|
||||
* description from the config and we favor the content that's been saved
|
||||
|
Loading…
Reference in New Issue
Block a user