Use IPv4 format for IPv4-mapped addresses
For instance, use "127.0.0.1" for IPv4 loopback instead of "::ffff:127.0.0.1". Simplifies use of econfig key privip: plain dotted decimal now just works regardless of IPv6 use, no need to add the IPv4-mapped form. Also affects how addresses are logged and shown to players, and nation selector ip. Nicer that way.
This commit is contained in:
parent
2d3bac803c
commit
372cdb136c
3 changed files with 16 additions and 6 deletions
|
@ -41,7 +41,7 @@ char *privname = "Deity forgot to edit econfig";
|
|||
/* E-mail of the deity */
|
||||
char *privlog = "careless@invalid";
|
||||
/* Divine hosts and networks */
|
||||
char *privip = "127.0.0.1 ::1 ::ffff:127.0.0.1";
|
||||
char *privip = "127.0.0.1 ::1";
|
||||
|
||||
char *post_crash_dump_hook = "";
|
||||
|
||||
|
|
|
@ -234,12 +234,21 @@ sockaddr_ntop(struct sockaddr *sap, char *buf, size_t bufsz)
|
|||
{
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
/* Assumes that if you got getaddrinfo(), you got inet_ntop() too */
|
||||
void *inaddr;
|
||||
sa_family_t af = sap->sa_family;
|
||||
void *addr;
|
||||
struct sockaddr_in6 *sap6;
|
||||
|
||||
inaddr = sap->sa_family == AF_INET
|
||||
? (void *)&((struct sockaddr_in *)sap)->sin_addr
|
||||
: (void *)&((struct sockaddr_in6 *)sap)->sin6_addr;
|
||||
return inet_ntop(sap->sa_family, inaddr, buf, bufsz);
|
||||
if (af == AF_INET)
|
||||
addr = &((struct sockaddr_in *)sap)->sin_addr;
|
||||
else {
|
||||
sap6 = (struct sockaddr_in6 *)sap;
|
||||
addr = &sap6->sin6_addr;
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sap6->sin6_addr)) {
|
||||
af = AF_INET;
|
||||
addr = sap6->sin6_addr.s6_addr + 12;
|
||||
}
|
||||
}
|
||||
return inet_ntop(af, addr, buf, bufsz);
|
||||
#else
|
||||
const char *p;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <winsock2.h>
|
||||
#undef NS_ALL
|
||||
|
||||
typedef unsigned short sa_family_t;
|
||||
typedef int socklen_t;
|
||||
|
||||
#define accept(fd, addr, addrlen) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue