clean up ip byte mangling
for now, censored IPs just show a '0' at the end...
This commit is contained in:
@@ -292,11 +292,8 @@ void playerinfo(int *cn, const char *attr)
|
||||
ATTR_INT(skin_rvsf, p->skin(TEAM_RVSF));
|
||||
ATTR_INT(skin, p->skin(player1->team));
|
||||
|
||||
string addrstr = "";
|
||||
uint2ip(p->address, addr);
|
||||
if(addr[3] != 0 || player1->clientrole==CR_ADMIN)
|
||||
formatstring(addrstr)("%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); // full IP
|
||||
else formatstring(addrstr)("%d.%d.%d.x", addr[0], addr[1], addr[2]); // censored IP
|
||||
string addrstr;
|
||||
iptoa(p->address, addrstr);
|
||||
ATTR_STR(ip, addrstr);
|
||||
|
||||
conoutf("invalid attribute: %s", attr);
|
||||
@@ -1626,13 +1623,11 @@ void cleanplayervotes(playerent *p)
|
||||
|
||||
void whois(int *cn)
|
||||
{
|
||||
string tmp;
|
||||
loopv(players) if(players[i] && players[i]->type == ENT_PLAYER && (*cn == -1 || players[i]->clientnum == *cn))
|
||||
{
|
||||
playerent *p = players[i];
|
||||
uint2ip(p->address, ip);
|
||||
if(ip[3] != 0 || player1->clientrole==CR_ADMIN)
|
||||
conoutf("WHOIS client %d:\tname %s , IP %d.%d.%d.%d , %d teamkill%s", p->clientnum, colorname(p), ip[0], ip[1], ip[2], ip[3], p->tks, p->tks == 1 ? "" : "s"); // full IP
|
||||
else conoutf("WHOIS client %d:\tname %s , IP %d.%d.%d.x , %d teamkill%s", p->clientnum, colorname(p), ip[0], ip[1], ip[2], p->tks, p->tks == 1 ? "" : "s"); // censored IP
|
||||
conoutf("WHOIS client %d:\tname %s , IP %s , %d teamkill%s", p->clientnum, colorname(p), iptoa(p->address, tmp), p->tks, p->tks == 1 ? "" : "s"); // full IP
|
||||
}
|
||||
}
|
||||
COMMAND(whois, "i");
|
||||
|
||||
@@ -2774,7 +2774,7 @@ void sendiplist(int receiver, int cn)
|
||||
&& (clients[i]->clientnum == cn || cn == -1))
|
||||
{
|
||||
putint(p, i);
|
||||
putint(p, isbigendian() ? endianswap(clients[i]->peer->address.host) : clients[i]->peer->address.host);
|
||||
putint(p, clients[i]->ip);
|
||||
}
|
||||
putint(p, -1);
|
||||
sendpacket(receiver, 1, p.finalize());
|
||||
@@ -2829,9 +2829,7 @@ void putinitclient(client &c, packetbuf &p)
|
||||
putint(p, c.skin[TEAM_CLA]);
|
||||
putint(p, c.skin[TEAM_RVSF]);
|
||||
putint(p, c.team);
|
||||
enet_uint32 ip = 0;
|
||||
if(c.type == ST_TCPIP) ip = c.peer->address.host & 0xFFFFFF;
|
||||
putint(p, isbigendian() ? endianswap(ip) : ip);
|
||||
putint(p, c.ip_censored);
|
||||
}
|
||||
|
||||
void sendinitclient(client &c)
|
||||
|
||||
@@ -845,14 +845,6 @@ template<class T> inline void endiansame(T *buf, int len) {}
|
||||
template<class T> inline void bigswap(T *buf, int len) { if(*(const uchar *)&islittleendian) endianswap(buf, len); }
|
||||
#endif
|
||||
|
||||
#define uint2ip(address, ip) uchar ip[4]; \
|
||||
if(isbigendian())\
|
||||
{ \
|
||||
enet_uint32 big = endianswap(address);\
|
||||
memcpy(&ip, &big, 4);\
|
||||
}\
|
||||
else memcpy(&ip, &address, 4);\
|
||||
|
||||
/* workaround for some C platforms that have these two functions as macros - not used anywhere */
|
||||
#ifdef getchar
|
||||
#undef getchar
|
||||
@@ -943,7 +935,6 @@ extern void zipmanualclose(void *a);
|
||||
extern bool cmpb(void *b, int n, enet_uint32 c);
|
||||
extern bool cmpf(char *fn, enet_uint32 c);
|
||||
extern enet_uint32 adler(unsigned char *data, size_t len);
|
||||
extern void endianswap(void *, int, int);
|
||||
extern bool isbigendian();
|
||||
extern void strtoupper(char *t, const char *s = NULL);
|
||||
extern void seedMT(uint seed);
|
||||
|
||||
Reference in New Issue
Block a user