diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-12-15 10:13:37 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-12-15 10:13:37 +0100 |
commit | 507adbe42e3978a4f9685af67e3b2d4267049867 (patch) | |
tree | b074ec3cf052e7be877260d1a9831901ed0d810b /src/plugins/xfer | |
parent | 891d2e3c5153671493481aecaae1a8adb8ea8028 (diff) | |
download | weechat-507adbe42e3978a4f9685af67e3b2d4267049867.zip |
Fix bug with option xfer.network.own_ip when sending DCC file
Diffstat (limited to 'src/plugins/xfer')
-rw-r--r-- | src/plugins/xfer/xfer.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c index c04d0d113..071dc4878 100644 --- a/src/plugins/xfer/xfer.c +++ b/src/plugins/xfer/xfer.c @@ -835,6 +835,10 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, void *signal /* get local IP address */ sscanf (weechat_infolist_string (infolist, "address"), "%lu", &local_addr); + memset (&addr, 0, sizeof (struct sockaddr_in)); + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = htonl (local_addr); + /* look up the IP address from network_own_ip, if set */ if (weechat_config_string(xfer_config_network_own_ip) && weechat_config_string(xfer_config_network_own_ip)[0]) @@ -844,6 +848,15 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, void *signal { memcpy (&tmpaddr, host->h_addr_list[0], sizeof(struct in_addr)); local_addr = ntohl (tmpaddr.s_addr); + + sock = weechat_infolist_integer (infolist, "socket"); + if (sock > 0) + { + memset (&addr, 0, sizeof (struct sockaddr_in)); + length = sizeof (addr); + getsockname (sock, (struct sockaddr *) &addr, &length); + addr.sin_family = AF_INET; + } } else { @@ -868,11 +881,6 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, void *signal } /* look for port */ - - memset (&addr, 0, sizeof (struct sockaddr_in)); - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = htonl (local_addr); - port = 0; if (weechat_config_string (xfer_config_network_port_range) |