diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/relay/relay-client.c | 15 | ||||
-rw-r--r-- | src/plugins/relay/relay-config.c | 10 | ||||
-rw-r--r-- | src/plugins/relay/relay-config.h | 1 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/plugins/relay/relay-client.c b/src/plugins/relay/relay-client.c index acc6363d8..d3d157e9e 100644 --- a/src/plugins/relay/relay-client.c +++ b/src/plugins/relay/relay-client.c @@ -1209,7 +1209,7 @@ int relay_client_timer_cb (const void *pointer, void *data, int remaining_calls) { struct t_relay_client *ptr_client, *ptr_next_client; - int purge_delay; + int purge_delay, auth_timeout; time_t current_time; /* make C compiler happy */ @@ -1218,6 +1218,7 @@ relay_client_timer_cb (const void *pointer, void *data, int remaining_calls) (void) remaining_calls; purge_delay = weechat_config_integer (relay_config_network_clients_purge_delay); + auth_timeout = weechat_config_integer (relay_config_network_auth_timeout); current_time = time (NULL); @@ -1237,7 +1238,19 @@ relay_client_timer_cb (const void *pointer, void *data, int remaining_calls) } else if (ptr_client->sock >= 0) { + /* send messages in outqueue */ relay_client_send_outqueue (ptr_client); + + /* disconnect clients not authenticated */ + if ((auth_timeout > 0) + && (ptr_client->status == RELAY_STATUS_WAITING_AUTH)) + { + if (current_time - ptr_client->start_time > auth_timeout) + { + relay_client_set_status (ptr_client, + RELAY_STATUS_AUTH_FAILED); + } + } } ptr_client = ptr_next_client; diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c index 6f9e66667..f9c66ce47 100644 --- a/src/plugins/relay/relay-config.c +++ b/src/plugins/relay/relay-config.c @@ -60,6 +60,7 @@ struct t_config_option *relay_config_color_text_selected; struct t_config_option *relay_config_network_allow_empty_password; struct t_config_option *relay_config_network_allowed_ips; +struct t_config_option *relay_config_network_auth_timeout; struct t_config_option *relay_config_network_bind_address; struct t_config_option *relay_config_network_clients_purge_delay; struct t_config_option *relay_config_network_compression_level; @@ -1031,6 +1032,15 @@ relay_config_init () NULL, NULL, NULL, &relay_config_change_network_allowed_ips, NULL, NULL, NULL, NULL, NULL); + relay_config_network_auth_timeout = weechat_config_new_option ( + relay_config_file, ptr_section, + "auth_timeout", "integer", + N_("timeout (in seconds) for client authentication: connection is " + "closed if the client is still not authenticated after this delay " + "and the client status is set to \"authentication failed\" " + "(0 = wait forever)"), + NULL, 0, INT_MAX, "60", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); relay_config_network_bind_address = weechat_config_new_option ( relay_config_file, ptr_section, "bind_address", "string", diff --git a/src/plugins/relay/relay-config.h b/src/plugins/relay/relay-config.h index 355c4ab41..35253abb9 100644 --- a/src/plugins/relay/relay-config.h +++ b/src/plugins/relay/relay-config.h @@ -39,6 +39,7 @@ extern struct t_config_option *relay_config_color_text_selected; extern struct t_config_option *relay_config_network_allow_empty_password; extern struct t_config_option *relay_config_network_allowed_ips; +extern struct t_config_option *relay_config_network_auth_timeout; extern struct t_config_option *relay_config_network_bind_address; extern struct t_config_option *relay_config_network_clients_purge_delay; extern struct t_config_option *relay_config_network_compression_level; |