Change connect_by_number() so that SERVICE_SERVER sockets are always bound to
IPv4 even on an IPv6-enabled client. This fixes /detach and wserv when compiling with --enable-ipv6. This does also mean that the internal identd, if used, won't listen on IPv6 either. This isn't a problem yet, since the internal identd is used only on WINNT and we don't support IPv6 there yet. This will also need tweaking to support initiating DCC-over-IPv6. Thanks to snadge and packet for working on this bug. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@162 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
[Changes 1.2c01]
|
[Changes 1.2c01]
|
||||||
|
|
||||||
|
* Fix /detach and wserv with IPv6 enabled. (caf, snadge, packet)
|
||||||
|
|
||||||
* Make default for NICK_COMPLETION_CHAR explicit. (caf)
|
* Make default for NICK_COMPLETION_CHAR explicit. (caf)
|
||||||
|
|
||||||
* Reduce footprint when starting up disconnected. (caf)
|
* Reduce footprint when starting up disconnected. (caf)
|
||||||
|
|||||||
@@ -454,22 +454,18 @@ int BX_connect_by_number(char *hostn, unsigned short *portnum, int service, int
|
|||||||
#ifdef IP_PORTRANGE
|
#ifdef IP_PORTRANGE
|
||||||
int ports;
|
int ports;
|
||||||
#endif
|
#endif
|
||||||
struct sockaddr_foobar name;
|
/* Even on an IPv6 client this opens up a IPv4 socket... for now.
|
||||||
#ifdef IPV6
|
* (Some OSes need two sockets to be able to accept both IPv4 and
|
||||||
struct in6_addr any = IN6ADDR_ANY_INIT;
|
* IPv6 connections). */
|
||||||
|
struct sockaddr_in name;
|
||||||
|
|
||||||
memset(&name, 0, sizeof(struct sockaddr_foobar));
|
memset(&name, 0, sizeof name);
|
||||||
name.sf_family = AF_INET6;
|
name.sin_family = AF_INET;
|
||||||
memcpy(&name.sf_addr6, &any, sizeof(struct in6_addr));
|
name.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
#else
|
|
||||||
memset(&name, 0, sizeof(struct sockaddr_foobar));
|
|
||||||
name.sf_family = AF_INET;
|
|
||||||
name.sf_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
name.sf_port = htons(*portnum);
|
name.sin_port = htons(*portnum);
|
||||||
#ifdef PARANOID
|
#ifdef PARANOID
|
||||||
name.sf_port += (unsigned short)(rand() & 255);
|
name.sin_port += (unsigned short)(rand() & 255);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IP_PORTRANGE
|
#ifdef IP_PORTRANGE
|
||||||
@@ -488,7 +484,7 @@ int BX_connect_by_number(char *hostn, unsigned short *portnum, int service, int
|
|||||||
if (getsockname(fd, (struct sockaddr *)&name, &length))
|
if (getsockname(fd, (struct sockaddr *)&name, &length))
|
||||||
return close(fd), -5;
|
return close(fd), -5;
|
||||||
|
|
||||||
*portnum = ntohs(name.sf_port);
|
*portnum = ntohs(name.sin_port);
|
||||||
|
|
||||||
if (protocol == PROTOCOL_TCP)
|
if (protocol == PROTOCOL_TCP)
|
||||||
if (listen(fd, 4) < 0)
|
if (listen(fd, 4) < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user