degesch: allow changing the list of used CAPs

Bump liberty.
This commit is contained in:
Přemysl Eric Janouch 2016-02-01 21:57:43 +01:00
parent a850ee45f1
commit 333ad2c981
3 changed files with 19 additions and 8 deletions

2
NEWS
View File

@ -12,6 +12,8 @@
* degesch: backlog limit was made configurable * degesch: backlog limit was made configurable
* degesch: allow changing the list IRC capabilities to use
* degesch: optimize buffer memory usage * degesch: optimize buffer memory usage
* kike: add support for IRCv3.2 server-time * kike: add support for IRCv3.2 server-time

View File

@ -1802,6 +1802,12 @@ static struct config_schema g_config_server[] =
.comment = "Password to connect to the server, if any", .comment = "Password to connect to the server, if any",
.type = CONFIG_ITEM_STRING, .type = CONFIG_ITEM_STRING,
.validate = config_validate_nonjunk_string }, .validate = config_validate_nonjunk_string },
// XXX: if we add support for new capabilities, the value stays unchanged
{ .name = "capabilities",
.comment = "Capabilities to use if supported by server",
.type = CONFIG_ITEM_STRING_ARRAY,
.validate = config_validate_nonjunk_string,
.default_ = "\"multi-prefix,invite-notify,server-time,echo-message\"" },
{ .name = "tls", { .name = "tls",
.comment = "Whether to use TLS", .comment = "Whether to use TLS",
@ -5470,22 +5476,25 @@ irc_handle_cap (struct server *s, const struct irc_message *msg)
log_server_status (s, s->buffer, log_server_status (s, s->buffer,
"#s: #S", "Capabilities supported", args); "#s: #S", "Capabilities supported", args);
struct str_vector chosen; struct str_vector chosen; str_vector_init (&chosen);
str_vector_init (&chosen); struct str_vector use; str_vector_init (&use);
cstr_split_ignore_empty
(get_config_string (s->config, "capabilities"), ',', &use);
// Filter server capabilities for ones we can make use of // Filter server capabilities for ones we can make use of
for (size_t i = 0; i < v.len; i++) for (size_t i = 0; i < v.len; i++)
{ {
const char *cap = v.vector[i]; const char *cap = v.vector[i];
if (!strcasecmp_ascii (cap, "multi-prefix") for (size_t k = 0; k < use.len; k++)
|| !strcasecmp_ascii (cap, "invite-notify") if (!strcasecmp_ascii (use.vector[k], cap))
|| !strcasecmp_ascii (cap, "server-time") str_vector_add (&chosen, cap);
|| !strcasecmp_ascii (cap, "echo-message"))
str_vector_add (&chosen, cap);
} }
char *chosen_str = join_str_vector (&chosen, ' '); char *chosen_str = join_str_vector (&chosen, ' ');
str_vector_free (&chosen); str_vector_free (&chosen);
str_vector_free (&use);
irc_send (s, "CAP REQ :%s", chosen_str); irc_send (s, "CAP REQ :%s", chosen_str);
log_server_status (s, s->buffer, log_server_status (s, s->buffer,
"#s: #S", "Capabilities requested", chosen_str); "#s: #S", "Capabilities requested", chosen_str);

@ -1 +1 @@
Subproject commit f213a76ad494efe150a786b195a744e4b87c5ca9 Subproject commit 9bff16f5ec777d3f4a9f7e8e8140907f3b404fa2