diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-09-17 20:16:08 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-09-17 20:16:08 +0200 |
commit | a20ae821da20824b3549d6c8c78d04201eda342b (patch) | |
tree | e66eeedac686637948418c6fe58ddfd30f639b0e /src/plugins | |
parent | bf98885506ed66c862e84dfd03f0ad9979cc767b (diff) | |
download | weechat-a20ae821da20824b3549d6c8c78d04201eda342b.zip |
Add new option relay.network.bind_address
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/relay/relay-config.c | 34 | ||||
-rw-r--r-- | src/plugins/relay/relay-config.h | 1 | ||||
-rw-r--r-- | src/plugins/relay/relay-server.c | 10 | ||||
-rw-r--r-- | src/plugins/relay/relay-server.h | 2 |
4 files changed, 45 insertions, 2 deletions
diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c index 1248a9391..3dce1bae5 100644 --- a/src/plugins/relay/relay-config.c +++ b/src/plugins/relay/relay-config.c @@ -49,6 +49,7 @@ struct t_config_option *relay_config_color_status[RELAY_NUM_STATUS]; /* relay config, network section */ +struct t_config_option *relay_config_network_bind_address; struct t_config_option *relay_config_network_max_clients; struct t_config_option *relay_config_network_password; @@ -70,6 +71,29 @@ relay_config_refresh_cb (void *data, struct t_config_option *option) } /* + * relay_config_change_network_bind_address_cb: callback called when user changes + * network bind address option + */ + +void +relay_config_change_network_bind_address_cb (void *data, + struct t_config_option *option) +{ + struct t_relay_server *ptr_server; + + /* make C compiler happy */ + (void) data; + (void) option; + + for (ptr_server = relay_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + relay_server_close_socket (ptr_server); + relay_server_create_socket (ptr_server); + } +} + +/* * relay_config_change_port_cb: callback called when relay port option is * modified */ @@ -336,7 +360,15 @@ relay_config_init () weechat_config_free (relay_config_file); return 0; } - + + relay_config_network_bind_address = weechat_config_new_option ( + relay_config_file, ptr_section, + "bind_address", "string", + N_("address for bind (if empty, connection is possible on all " + "interfaces, use \"127.0.0.1\" to allow connections from " + "local machine only)"), + NULL, 0, 0, "", NULL, 0, NULL, NULL, + &relay_config_change_network_bind_address_cb, NULL, NULL, NULL); relay_config_network_max_clients = weechat_config_new_option ( relay_config_file, ptr_section, "max_clients", "integer", diff --git a/src/plugins/relay/relay-config.h b/src/plugins/relay/relay-config.h index 781ffb881..247d1598d 100644 --- a/src/plugins/relay/relay-config.h +++ b/src/plugins/relay/relay-config.h @@ -33,6 +33,7 @@ extern struct t_config_option *relay_config_color_text_bg; extern struct t_config_option *relay_config_color_text_selected; extern struct t_config_option *relay_config_color_status[]; +extern struct t_config_option *relay_config_network_bind_address; extern struct t_config_option *relay_config_network_max_clients; extern struct t_config_option *relay_config_network_password; diff --git a/src/plugins/relay/relay-server.c b/src/plugins/relay/relay-server.c index b8cff7dc7..a02ef474d 100644 --- a/src/plugins/relay/relay-server.c +++ b/src/plugins/relay/relay-server.c @@ -248,7 +248,15 @@ relay_server_create_socket (struct t_relay_server *server) memset(&server_addr, 0, sizeof(struct sockaddr_in)); server_addr.sin_family = AF_INET; - server_addr.sin_addr.s_addr = INADDR_ANY; + if (weechat_config_string (relay_config_network_bind_address) + && weechat_config_string (relay_config_network_bind_address)[0]) + { + server_addr.sin_addr.s_addr = inet_addr (weechat_config_string (relay_config_network_bind_address)); + } + else + { + server_addr.sin_addr.s_addr = INADDR_ANY; + } server_addr.sin_port = htons (server->port); if (bind (server->sock, (struct sockaddr *) &server_addr, diff --git a/src/plugins/relay/relay-server.h b/src/plugins/relay/relay-server.h index bb57a2e5f..a35f1ccf2 100644 --- a/src/plugins/relay/relay-server.h +++ b/src/plugins/relay/relay-server.h @@ -41,6 +41,8 @@ extern void relay_server_get_protocol_string (const char *protocol_and_string, char **protocol_string); extern struct t_relay_server *relay_server_search (const char *protocol_and_string); extern struct t_relay_server *relay_server_search_port (int port); +extern void relay_server_close_socket (struct t_relay_server *server); +extern int relay_server_create_socket (struct t_relay_server *server); extern struct t_relay_server *relay_server_new (enum t_relay_protocol protocol, const char *protocol_string, int port); |