mirror of
https://github.com/irssi/irssi.git
synced 2026-08-18 16:12:30 +02:00
/SET resolve_prefer_ipv6 - should we prefer IPv6 or IPv4 addresses in
host name resolving. /SERVER ADD: added options -4 and -6. Fixed crash at startup if server didn't have chat network set. "Connecting to xxx [ip]" is now displayed before calling connect(), so if it fails we'll still get the IP it's trying to connect to. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1268 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
2aeb9259e0
commit
481f4bc327
6 changed files with 58 additions and 13 deletions
|
|
@ -47,6 +47,8 @@ union sockaddr_union {
|
|||
# define g_io_channel_new(handle) g_io_channel_unix_new(handle)
|
||||
#endif
|
||||
|
||||
static unsigned short default_family = 0;
|
||||
|
||||
/* Cygwin need this, don't know others.. */
|
||||
/*#define BLOCKING_SOCKETS 1*/
|
||||
|
||||
|
|
@ -332,8 +334,9 @@ int net_getsockname(GIOChannel *handle, IPADDR *addr, int *port)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Get IP address for host, returns 0 = ok,
|
||||
others = error code for net_gethosterror() */
|
||||
/* Get IP address for host. family specifies if we should prefer to
|
||||
IPv4 or IPv6 address (0 = default, AF_INET or AF_INET6).
|
||||
returns 0 = ok, others = error code for net_gethosterror() */
|
||||
int net_gethostbyname(const char *addr, IPADDR *ip, int family)
|
||||
{
|
||||
#ifdef HAVE_IPV6
|
||||
|
|
@ -352,7 +355,7 @@ int net_gethostbyname(const char *addr, IPADDR *ip, int family)
|
|||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_family = family;
|
||||
hints.ai_family = family != 0 ? family : default_family;
|
||||
|
||||
/* save error to host_error for later use */
|
||||
host_error = getaddrinfo(addr, NULL, &hints, &ai);
|
||||
|
|
@ -377,6 +380,13 @@ int net_gethostbyname(const char *addr, IPADDR *ip, int family)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Set the default address family to use with host resolving
|
||||
(AF_INET or AF_INET6) */
|
||||
void net_host_resolver_set_default_family(unsigned short family)
|
||||
{
|
||||
default_family = family;
|
||||
}
|
||||
|
||||
/* Get name for host, *name should be g_free()'d unless it's NULL.
|
||||
Return values are the same as with net_gethostbyname() */
|
||||
int net_gethostbyaddr(IPADDR *ip, char **name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue