summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2003-11-16 16:33:25 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2003-11-16 16:33:25 +0000
commitaa78361f24a63b18df292a70a889b1d3c64d5a8e (patch)
treeb0df5c4f987ba2f6c6296d281ee2225919222785 /src
parentf764a8665c9a9c70a6d9f1a08b4a7ee1c0bafa16 (diff)
downloadirssi-aa78361f24a63b18df292a70a889b1d3c64d5a8e.zip
Allow /SET dcc_own_ip to be non-local address.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3140 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/irc/dcc/dcc.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/irc/dcc/dcc.c b/src/irc/dcc/dcc.c
index 2fd6317f..8b07b86d 100644
--- a/src/irc/dcc/dcc.c
+++ b/src/irc/dcc/dcc.c
@@ -245,16 +245,28 @@ GIOChannel *dcc_listen(GIOChannel *iface, IPADDR *ip, int *port)
GIOChannel *dcc_connect_ip(IPADDR *ip, int port)
{
IPADDR *own_ip, temp_ip;
+ const char *own_ip_str;
+ GIOChannel *handle;
- if (*settings_get_str("dcc_own_ip") == '\0') {
- own_ip = IPADDR_IS_V6(ip) ? source_host_ip6 : source_host_ip4;
- } else {
+ own_ip_str = settings_get_str("dcc_own_ip");
+ own_ip = NULL;
+ if (*own_ip_str != '\0') {
/* use the specified interface for connecting */
- net_host2ip(settings_get_str("dcc_own_ip"), &temp_ip);
- own_ip = &temp_ip;
+ net_host2ip(own_ip_str, &temp_ip);
+ if (IPADDR_IS_V6(ip) == IPADDR_IS_V6(&temp_ip))
+ own_ip = &temp_ip;
}
- return net_connect_ip(ip, port, own_ip);
+ if (own_ip == NULL)
+ own_ip = IPADDR_IS_V6(ip) ? source_host_ip6 : source_host_ip4;
+
+ handle = net_connect_ip(ip, port, own_ip);
+ if (handle == NULL && errno == EADDRNOTAVAIL && own_ip != NULL) {
+ /* dcc_own_ip is external address */
+ own_ip = IPADDR_IS_V6(ip) ? source_host_ip6 : source_host_ip4;
+ handle = net_connect_ip(ip, port, own_ip);
+ }
+ return handle;
}
/* Server connected - update server for DCC records that have