Merge pull request #1170 from ailin-nemui/starttls

use starttls / enable tls_verify
This commit is contained in:
ailin-nemui 2021-04-18 12:01:14 +02:00 committed by GitHub
commit 4432b0bf0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 643 additions and 234 deletions

View file

@ -51,12 +51,13 @@ const char *get_visible_target(IRC_SERVER_REC *server, const char *target)
return target;
}
/* SYNTAX: SERVER ADD|MODIFY [-4 | -6] [-tls] [-tls_cert <cert>] [-tls_pkey <pkey>] [-tls_pass <password>]
[-tls_verify] [-tls_cafile <cafile>] [-tls_capath <capath>]
[-tls_ciphers <list>]
/* SYNTAX: SERVER ADD|MODIFY [-4 | -6] [-tls_cert <cert>] [-tls_pkey <pkey>]
[-tls_pass <password>] [-tls_verify] [-tls_cafile <cafile>]
[-tls_capath <capath>] [-tls_ciphers <list>] [-tls | -notls]
[-starttls | -nostarttls | -disallow_starttls | -nodisallow_starttls]
[-auto | -noauto] [-network <network>] [-host <hostname>]
[-cmdspeed <ms>] [-cmdmax <count>] [-port <port>]
<address> [<port> [<password>]] */
[-cmdspeed <ms>] [-cmdmax <count>] [-port <port>] <address> [<port>
[<password>]] */
/* NOTE: -network replaces the old -ircnet flag. */
static void sig_server_add_fill(IRC_SERVER_SETUP_REC *rec,
GHashTable *optlist)
@ -85,6 +86,28 @@ static void sig_server_add_fill(IRC_SERVER_SETUP_REC *rec,
if (value != NULL && *value != '\0') rec->max_cmds_at_once = atoi(value);
value = g_hash_table_lookup(optlist, "querychans");
if (value != NULL && *value != '\0') rec->max_query_chans = atoi(value);
if (g_hash_table_lookup(optlist, "nodisallow_starttls") ||
g_hash_table_lookup(optlist, "nostarttls"))
rec->starttls = STARTTLS_NOTSET;
if (g_hash_table_lookup(optlist, "disallow_starttls"))
rec->starttls = STARTTLS_DISALLOW;
if (g_hash_table_lookup(optlist, "starttls")) {
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 */
@ -108,29 +131,35 @@ static void cmd_server_list(const char *data)
g_string_append(str, "autoconnect, ");
if (rec->no_proxy)
g_string_append(str, "noproxy, ");
if (rec->use_tls) {
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)
g_string_append(str, "starttls, ");
if (rec->use_tls)
g_string_append(str, "tls, ");
if (rec->tls_cert) {
g_string_append_printf(str, "tls_cert: %s, ", rec->tls_cert);
if (rec->tls_pkey)
g_string_append_printf(str, "tls_pkey: %s, ", rec->tls_pkey);
if (rec->tls_pass)
g_string_append_printf(str, "(pass), ");
}
if (rec->tls_verify)
g_string_append(str, "tls_verify, ");
if (rec->tls_cafile)
g_string_append_printf(str, "tls_cafile: %s, ", rec->tls_cafile);
if (rec->tls_capath)
g_string_append_printf(str, "tls_capath: %s, ", rec->tls_capath);
if (rec->tls_ciphers)
g_string_append_printf(str, "tls_ciphers: %s, ", rec->tls_ciphers);
if (rec->tls_pinned_cert)
g_string_append_printf(str, "tls_pinned_cert: %s, ", rec->tls_pinned_cert);
if (rec->tls_pinned_pubkey)
g_string_append_printf(str, "tls_pinned_pubkey: %s, ", rec->tls_pinned_pubkey);
if (rec->tls_cert) {
g_string_append_printf(str, "tls_cert: %s, ", rec->tls_cert);
if (rec->tls_pkey)
g_string_append_printf(str, "tls_pkey: %s, ", rec->tls_pkey);
if (rec->tls_pass)
g_string_append_printf(str, "(pass), ");
}
if (!rec->tls_verify)
g_string_append(str, "notls_verify, ");
if (rec->tls_cafile)
g_string_append_printf(str, "tls_cafile: %s, ", rec->tls_cafile);
if (rec->tls_capath)
g_string_append_printf(str, "tls_capath: %s, ", rec->tls_capath);
if (rec->tls_ciphers)
g_string_append_printf(str, "tls_ciphers: %s, ", rec->tls_ciphers);
if (rec->tls_pinned_cert)
g_string_append_printf(str, "tls_pinned_cert: %s, ", rec->tls_pinned_cert);
if (rec->tls_pinned_pubkey)
g_string_append_printf(str, "tls_pinned_pubkey: %s, ",
rec->tls_pinned_pubkey);
if (rec->max_cmds_at_once > 0)
g_string_append_printf(str, "cmdmax: %d, ", rec->max_cmds_at_once);
if (rec->cmd_queue_speed > 0)
@ -153,13 +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");
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 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);
}

View file

@ -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 } },

View file

@ -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,