mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 11:10:39 +00:00
git-svn-id: https://svn.eduke32.com/eduke32@631 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
f13385cf86
commit
aa5360a235
2 changed files with 14 additions and 7 deletions
|
@ -821,14 +821,15 @@ int getpacket(int *retother, char *bufptr)
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getexternaladdress(char *buffer)
|
int getexternaladdress(char *buffer, const char *host, int port)
|
||||||
{
|
{
|
||||||
int bytes_sent, i=0, j=0;
|
int bytes_sent, i=0, j=0;
|
||||||
struct sockaddr_in dest_addr;
|
struct sockaddr_in dest_addr;
|
||||||
struct hostent *h;
|
struct hostent *h;
|
||||||
char *host = "checkip.dyndns.org";
|
|
||||||
char *req = "GET / HTTP/1.0\r\n\r\n";
|
char *req = "GET / HTTP/1.0\r\n\r\n";
|
||||||
char tempbuf[512], ipaddr[32];
|
char tempbuf[1024], ipaddr[32];
|
||||||
|
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (wsainitialized == 0)
|
if (wsainitialized == 0)
|
||||||
|
@ -852,7 +853,7 @@ int getexternaladdress(char *buffer)
|
||||||
|
|
||||||
dest_addr.sin_addr.s_addr = ((struct in_addr *)(h->h_addr))->s_addr;
|
dest_addr.sin_addr.s_addr = ((struct in_addr *)(h->h_addr))->s_addr;
|
||||||
dest_addr.sin_family = AF_INET;
|
dest_addr.sin_family = AF_INET;
|
||||||
dest_addr.sin_port = htons(8245);
|
dest_addr.sin_port = htons(port);
|
||||||
|
|
||||||
memset(&(dest_addr.sin_zero), '\0', 8);
|
memset(&(dest_addr.sin_zero), '\0', 8);
|
||||||
|
|
||||||
|
@ -884,6 +885,8 @@ int getexternaladdress(char *buffer)
|
||||||
|
|
||||||
for (i=0;(unsigned)i<strlen(tempbuf);i++)
|
for (i=0;(unsigned)i<strlen(tempbuf);i++)
|
||||||
{
|
{
|
||||||
|
if (tempbuf[i] == ':' && tempbuf[i+1] == ' ')
|
||||||
|
i += 2;
|
||||||
if (isdigit(tempbuf[i]) && (isdigit(tempbuf[i+1]) || (tempbuf[i+1] == '.')) && (isdigit(tempbuf[i+2]) || (tempbuf[i+2] == '.')) && (isdigit(tempbuf[i+3]) || (tempbuf[i+3] == '.')))
|
if (isdigit(tempbuf[i]) && (isdigit(tempbuf[i+1]) || (tempbuf[i+1] == '.')) && (isdigit(tempbuf[i+2]) || (tempbuf[i+2] == '.')) && (isdigit(tempbuf[i+3]) || (tempbuf[i+3] == '.')))
|
||||||
{
|
{
|
||||||
while (isdigit(tempbuf[i]) || (tempbuf[i] == '.'))
|
while (isdigit(tempbuf[i]) || (tempbuf[i] == '.'))
|
||||||
|
@ -891,7 +894,7 @@ int getexternaladdress(char *buffer)
|
||||||
ipaddr[j] = tempbuf[i];
|
ipaddr[j] = tempbuf[i];
|
||||||
i++, j++;
|
i++, j++;
|
||||||
}
|
}
|
||||||
ipaddr[j] = '\0';
|
ipaddr[j++] = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8386,7 +8386,7 @@ static void comlinehelp(void)
|
||||||
static signed int rancid_players = 0;
|
static signed int rancid_players = 0;
|
||||||
static char rancid_ip_strings[MAXPLAYERS][32], rancid_local_port_string[8];
|
static char rancid_ip_strings[MAXPLAYERS][32], rancid_local_port_string[8];
|
||||||
|
|
||||||
extern int getexternaladdress(char *buffer);
|
extern int getexternaladdress(char *buffer, const char *host, int port);
|
||||||
|
|
||||||
static int load_rancid_net(const char *fn)
|
static int load_rancid_net(const char *fn)
|
||||||
{
|
{
|
||||||
|
@ -8528,7 +8528,11 @@ static void setup_rancid_net(const char *fn)
|
||||||
Bstrcpy(tmp,strtok(tempbuf,"."));
|
Bstrcpy(tmp,strtok(tempbuf,"."));
|
||||||
if (i == rancid_players && ((Bstrcmp(tmp,"192") == 0) || (Bstrcmp(tmp,"172") == 0) || (Bstrcmp(tmp,"169") == 0) || (Bstrcmp(tmp,"10") == 0)))
|
if (i == rancid_players && ((Bstrcmp(tmp,"192") == 0) || (Bstrcmp(tmp,"172") == 0) || (Bstrcmp(tmp,"169") == 0) || (Bstrcmp(tmp,"10") == 0)))
|
||||||
{
|
{
|
||||||
if (getexternaladdress(tempbuf))
|
int ii = getexternaladdress(tempbuf, "checkip.dyndns.org", 80);
|
||||||
|
|
||||||
|
if (!ii)
|
||||||
|
ii = getexternaladdress(tempbuf, "checkip.dyndns.org", 8245);
|
||||||
|
if (ii)
|
||||||
{
|
{
|
||||||
if (tempbuf[0])
|
if (tempbuf[0])
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue