diff options
author | Timo Sirainen <cras@irssi.org> | 2002-06-06 20:14:31 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-06-06 20:14:31 +0000 |
commit | 964ff29779cbd8ea879f0cf0bca2434290aa9934 (patch) | |
tree | dda808377cc19e2918cae0a70174ee949a0a221b /src/irc | |
parent | 694251442c84f37470da7bb609a27e773d0175d6 (diff) | |
download | irssi-964ff29779cbd8ea879f0cf0bca2434290aa9934.zip |
/SET irssiproxy_bind specifies the IP where to listen in, patch by BC-bd
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2843 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/proxy/listen.c | 23 | ||||
-rw-r--r-- | src/irc/proxy/proxy.c | 1 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c index 5531720c..811d747f 100644 --- a/src/irc/proxy/listen.c +++ b/src/irc/proxy/listen.c @@ -538,15 +538,32 @@ static LISTEN_REC *find_listen(const char *ircnet, int port) static void add_listen(const char *ircnet, int port) { LISTEN_REC *rec; + IPADDR ip4, ip6, *my_ip; - if (port <= 0 || *ircnet == '\0') return; + if (port <= 0 || *ircnet == '\0') + return; + + /* bind to specific host/ip? */ + my_ip = NULL; + if (*settings_get_str("irssiproxy_bind") != '\0') { + if (net_gethostbyname(settings_get_str("irssiproxy_bind"), + &ip4, &ip6) != 0) { + printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, + "Proxy: can not resolve '%s' - aborting", + settings_get_str("irssiproxy_bind")); + return; + } + + my_ip = ip6.family == 0 ? &ip4 : ip4.family == 0 || + settings_get_bool("resolve_prefer_ipv6") ? &ip6 : &ip4; + } rec = g_new0(LISTEN_REC, 1); rec->ircnet = g_strdup(ircnet); rec->port = port; - /* start listening */ - rec->handle = net_listen(NULL, &rec->port); + rec->handle = net_listen(my_ip, &rec->port); + if (rec->handle == NULL) { printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Proxy: Listen in port %d failed: %s", diff --git a/src/irc/proxy/proxy.c b/src/irc/proxy/proxy.c index f75a5b39..2240f63b 100644 --- a/src/irc/proxy/proxy.c +++ b/src/irc/proxy/proxy.c @@ -27,6 +27,7 @@ void irc_proxy_init(void) { settings_add_str("irssiproxy", "irssiproxy_ports", ""); settings_add_str("irssiproxy", "irssiproxy_password", ""); + settings_add_str("irssiproxy", "irssiproxy_bind", ""); if (*settings_get_str("irssiproxy_password") == '\0') { /* no password - bad idea! */ |