1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 08:43:13 +02:00

core: fix IP address returned by hook_connect (return IP really used, not first IP for hostname)

This commit is contained in:
Sebastien Helleu
2012-08-25 18:51:25 +02:00
parent 4a3756e753
commit e767346a19
2 changed files with 25 additions and 22 deletions
+3 -1
View File
@@ -1,12 +1,14 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.9-dev, 2012-08-22
v0.3.9-dev, 2012-08-25
Version 0.3.9 (under dev!)
--------------------------
* core: fix IP address returned by hook_connect (return IP really used, not
first IP for hostname)
* core: display spaces at the end of messages in chat area (bug #37024)
* core: fix infinite loop in display when chat area has width of 1 with
a bar displayed on the right (nicklist by default) (bug #37089)
+22 -21
View File
@@ -657,6 +657,8 @@ network_connect_child (struct t_hook *hook_connect)
status_str[1] = '\0';
ptr_address = NULL;
ptr_proxy = NULL;
if (HOOK_CONNECT(hook_connect, proxy)
&& HOOK_CONNECT(hook_connect, proxy)[0])
@@ -930,6 +932,26 @@ network_connect_child (struct t_hook *hook_connect)
ptr_res->ai_addr, ptr_res->ai_addrlen))
{
status_str[0] = '0' + WEECHAT_HOOK_CONNECT_OK;
if (HOOK_CONNECT(hook_connect, ipv6))
{
if (inet_ntop (AF_INET6,
&((struct sockaddr_in6 *)(ptr_res->ai_addr))->sin6_addr,
ipv6_address,
INET6_ADDRSTRLEN))
{
ptr_address = ipv6_address;
}
}
else
{
if (inet_ntop (AF_INET,
&((struct sockaddr_in *)(ptr_res->ai_addr))->sin_addr,
ipv4_address,
INET_ADDRSTRLEN))
{
ptr_address = ipv4_address;
}
}
break;
}
else
@@ -940,27 +962,6 @@ network_connect_child (struct t_hook *hook_connect)
if (status_str[0] == '0' + WEECHAT_HOOK_CONNECT_OK)
{
status_with_string = NULL;
ptr_address = NULL;
if (HOOK_CONNECT(hook_connect, ipv6))
{
if (inet_ntop (AF_INET6,
&((struct sockaddr_in6 *)(res->ai_addr))->sin6_addr,
ipv6_address,
INET6_ADDRSTRLEN))
{
ptr_address = ipv6_address;
}
}
else
{
if (inet_ntop (AF_INET,
&((struct sockaddr_in *)(res->ai_addr))->sin_addr,
ipv4_address,
INET_ADDRSTRLEN))
{
ptr_address = ipv4_address;
}
}
if (ptr_address)
{
length = strlen (status_str) + 5 + strlen (ptr_address) + 1;