summaryrefslogtreecommitdiff
path: root/src/irc/dcc
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2006-01-28 16:04:44 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2006-01-28 16:04:44 +0000
commita975788d15f34ad56c82bcc8c08bb4f9de8bbdd8 (patch)
tree8b9f04dea44d02fb0a7dadaf88eb615f610e8b59 /src/irc/dcc
parentf517f0cd4620753e8166840ff82f0d7a105ac557 (diff)
downloadirssi-a975788d15f34ad56c82bcc8c08bb4f9de8bbdd8.zip
If dcc_own_ip contains IPv4 address, listen only in IPv4.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4228 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/dcc')
-rw-r--r--src/irc/dcc/dcc.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/irc/dcc/dcc.c b/src/irc/dcc/dcc.c
index a71d95d8..7805e222 100644
--- a/src/irc/dcc/dcc.c
+++ b/src/irc/dcc/dcc.c
@@ -198,22 +198,31 @@ void dcc_str2ip(const char *str, IPADDR *ip)
GIOChannel *dcc_listen(GIOChannel *iface, IPADDR *ip, int *port)
{
GIOChannel *handle;
- const char *dcc_port, *p;
+ IPADDR *listen_ip = NULL;
+ const char *dcc_port, *p, *own_ip;
int first, last;
if (net_getsockname(iface, ip, NULL) == -1)
return NULL;
+ /* figure out if we want to listen in IPv4 address or in "any" address,
+ which may mean IPv4+IPv6 or just IPv6 depending on OS. */
+ own_ip = settings_get_str("dcc_own_ip");
+ if (*own_ip != '\0') {
+ if (is_ipv4_address(own_ip))
+ listen_ip = &ip4_any;
+ } else {
+ if (!IPADDR_IS_V6(ip))
+ listen_ip = &ip4_any;
+ }
+
/* get first port */
dcc_port = settings_get_str("dcc_port");
first = atoi(dcc_port);
if (first == 0) {
/* random port */
*port = 0;
- if (IPADDR_IS_V6(ip))
- return net_listen(NULL, port);
- else
- return net_listen(&ip4_any, port);
+ return net_listen(listen_ip, port);
}
/* get last port */
@@ -231,10 +240,7 @@ GIOChannel *dcc_listen(GIOChannel *iface, IPADDR *ip, int *port)
/* use the first available port */
for (*port = first; *port <= last; (*port)++) {
- if (IPADDR_IS_V6(ip))
- handle = net_listen(NULL, port);
- else
- handle = net_listen(&ip4_any, port);
+ handle = net_listen(listen_ip, port);
if (handle != NULL)
return handle;
}