diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-02-10 20:22:13 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-02-10 20:22:13 +0100 |
commit | c2aeb69c46a8f0222aed935afc46e0b27cbc94a0 (patch) | |
tree | d217e5bfc2dbfe7e0d50dbcd7a0b24b032681441 /src/plugins/relay/relay-config.c | |
parent | eb11921f1633db940df4b0c02a43df1360d39b96 (diff) | |
download | weechat-c2aeb69c46a8f0222aed935afc46e0b27cbc94a0.zip |
relay: add experimental websocket server support (RFC 6455) for irc and weechat protocols, new option relay.network.websocket_allowed_origins
It is a partial implementation of RFC 6455: fragmentation and control frames are
not yet supported.
Text and binary frames are supported.
Diffstat (limited to 'src/plugins/relay/relay-config.c')
-rw-r--r-- | src/plugins/relay/relay-config.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c index d38c22f5e..d6092d279 100644 --- a/src/plugins/relay/relay-config.c +++ b/src/plugins/relay/relay-config.c @@ -57,6 +57,7 @@ struct t_config_option *relay_config_network_ipv6; struct t_config_option *relay_config_network_max_clients; struct t_config_option *relay_config_network_password; struct t_config_option *relay_config_network_ssl_cert_key; +struct t_config_option *relay_config_network_websocket_allowed_origins; /* relay config, irc section */ @@ -69,6 +70,7 @@ struct t_config_option *relay_config_irc_backlog_time_format; /* other */ regex_t *relay_config_regex_allowed_ips = NULL; +regex_t *relay_config_regex_websocket_allowed_origins = NULL; struct t_hashtable *relay_config_hashtable_irc_backlog_tags = NULL; @@ -188,6 +190,44 @@ relay_config_change_network_ssl_cert_key (void *data, } /* + * Callback for changes on option "relay.network.websocker_allowed_origins". + */ + +void +relay_config_change_network_websocket_allowed_origins (void *data, + struct t_config_option *option) +{ + const char *allowed_origins; + + /* make C compiler happy */ + (void) data; + (void) option; + + if (relay_config_regex_websocket_allowed_origins) + { + regfree (relay_config_regex_websocket_allowed_origins); + free (relay_config_regex_websocket_allowed_origins); + relay_config_regex_websocket_allowed_origins = NULL; + } + + allowed_origins = weechat_config_string (relay_config_network_websocket_allowed_origins); + if (allowed_origins && allowed_origins[0]) + { + relay_config_regex_websocket_allowed_origins = malloc (sizeof (*relay_config_regex_websocket_allowed_origins)); + if (relay_config_regex_websocket_allowed_origins) + { + if (weechat_string_regcomp (relay_config_regex_websocket_allowed_origins, + allowed_origins, + REG_EXTENDED | REG_ICASE) != 0) + { + free (relay_config_regex_websocket_allowed_origins); + relay_config_regex_websocket_allowed_origins = NULL; + } + } + } +} + +/* * Callback for changes on option "relay.irc.backlog_tags". */ @@ -606,6 +646,14 @@ relay_config_init () "with SSL)"), NULL, 0, 0, "%h/ssl/relay.pem", NULL, 0, NULL, NULL, &relay_config_change_network_ssl_cert_key, NULL, NULL, NULL); + relay_config_network_websocket_allowed_origins = weechat_config_new_option ( + relay_config_file, ptr_section, + "websocket_allowed_origins", "string", + N_("regular expression with origins allowed in websockets (case " + "insensitive, use \"(?-i)\" at beginning to make it case sensitive), " + "example: \"^http://(www\\.)?example\\.(com|org)\""), + NULL, 0, 0, "", NULL, 0, NULL, NULL, + &relay_config_change_network_websocket_allowed_origins, NULL, NULL, NULL); /* section irc */ ptr_section = weechat_config_new_section (relay_config_file, "irc", |