diff options
-rw-r--r-- | src/plugins/irc/irc-command.c | 1 | ||||
-rw-r--r-- | src/plugins/xfer/xfer.c | 18 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 70bc20588..ddeecd03a 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -946,6 +946,7 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc, snprintf (str_address, sizeof (str_address), "%lu", address); weechat_infolist_new_var_string (item, "address", str_address); + weechat_infolist_new_var_integer (item, "socket", ptr_server->sock); weechat_hook_signal_send ("xfer_add", WEECHAT_HOOK_SIGNAL_POINTER, infolist); 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) |