Browse Source

ildm6 update

master
Olaf Rempel 14 years ago
parent
commit
aee280ca5c
6 changed files with 35 additions and 19 deletions
  1. +3
    -2
      .gitignore
  2. +2
    -3
      hlswmaster.conf
  3. +12
    -7
      masterquery.c
  4. +7
    -0
      p_gamespy1.c
  5. +8
    -4
      scanner.c
  6. +3
    -3
      server.c

+ 3
- 2
.gitignore View File

@@ -1,5 +1,6 @@
*.d
*.o
*.o
*.so
masterquery
hlswmaster
*.so
hlswmaster.log

+ 2
- 3
hlswmaster.conf View File

@@ -33,11 +33,10 @@ plugin p_ut2k4.so

[hlswproxy]
## ask these hlswmasters
scan 10.10.0.1:7140
scan 10.10.0.2:7140
#scan 10.10.0.1:7140
#scan 10.10.0.2:7140

[halflife]
## allow these nets
valid_net 10.10.0.0/16
valid_net 172.16.0.0/16


+ 12
- 7
masterquery.c View File

@@ -21,6 +21,7 @@ struct _entry {

static char hlswheader[] = "\xFF\xFF\xFF\xFFHLSWLANSEARCH";

#define id2name_count (sizeof(id2name) / sizeof(char *) -1)
static char *id2name[] = {
"Unknown", // 0
"Halflife",
@@ -68,9 +69,12 @@ static char *id2name[] = {
"Starwars: Battlefront (?)",
"SWAT 4",
"Battlefield 2", // 45
"(unknown)",
"Quake 4 (?)",
"Call of Duty 2"
"unknown",
"Quake 4",
"Call of Duty 2",
"unknown",
"FEAR", // 50
"Warsow(?)"
};

static int sock, verbose = 0;
@@ -93,9 +97,10 @@ static void parse_pkt(struct sockaddr_in *src, void *pkt, unsigned int size)
server = pkt + sizeof(hlswheader);
while ((void *)server < pkt + size) {
tmp.s_addr = server->ip;

printf(" ip=%15s port1=%5d port2=%5d gameid=%2d (%s)\n",
inet_ntoa(tmp), server->port1, server->port2,
server->gameid, id2name[server->gameid]);
server->gameid, server->gameid <= id2name_count ? id2name[server->gameid] : "unknown");
server++;
}
}
@@ -104,13 +109,13 @@ static void parse_pkt(struct sockaddr_in *src, void *pkt, unsigned int size)

static int scan_init()
{
int i = 1;

if ((sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
sock = socket(PF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
perror("socket()");
return -1;
}

unsigned int i = 1;
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &i, sizeof(i))) {
perror("setsockopt()");
return -1;


+ 7
- 0
p_gamespy1.c View File

@@ -33,6 +33,7 @@ static struct scan_ports port_arr[] = {
{ 23000, 23010, 35 }, /* bfv(35) */
{ 26001, 26011, 19 }, /* igi2(19) */
{ 27888, 27888, 17 }, /* avp2(17) (nur der standart-port..) */
{ 44400, 44400, 51 },
{ 0, 0, 0 }
};

@@ -66,6 +67,7 @@ static char reply_avp2[] = "avp2\\";
static char reply_igi2[] = "projectigi2r\\";
static char reply_aao[] = "armygame\\";
static char reply_rune[] = "rune\\";
static char reply_postal2[] ="postal2\\";

static int scan(void)
{
@@ -152,6 +154,11 @@ static int parse_real(struct net_pkt *pkt, int gameid)
/* americas army operations */
else if (!pkt_memcmp(pkt, pos1, reply_aao, strlen(reply_aao)))
gameid = 15;

/* postal2 */
else if (!pkt_memcmp(pkt, pos1, reply_postal2, strlen(reply_postal2)))
gameid = 9;

else
return PARSE_REJECT;
break;


+ 8
- 4
scanner.c View File

@@ -101,7 +101,7 @@ static int scanner_receive(int fd, void *privdata)
return 0;
}

int i = sizeof(struct sockaddr_in);
unsigned int i = sizeof(struct sockaddr_in);
pkt->size = recvfrom(fd, pkt->buf, recvsize, 0, (struct sockaddr *)&pkt->addr, &i);

if (pkt->size < 0) {
@@ -111,11 +111,15 @@ static int scanner_receive(int fd, void *privdata)
}

switch (plugins_parse(pkt)) {
case PARSE_REJECT:
log_print(LOG_INFO, "scanner_receive(): unknown packet: %s:%d size:%d",
case PARSE_REJECT: {
char *pkt_str = pkt_print(pkt);
log_print(LOG_INFO, "scanner_receive(): unknown packet: %s:%d size:%d\n%s",
inet_ntoa(pkt->addr.sin_addr),
ntohs(pkt->addr.sin_port),
pkt->size);
pkt->size, pkt_str);

free(pkt_str);
}

case PARSE_ACCEPT:
free(pkt);


+ 3
- 3
server.c View File

@@ -34,8 +34,8 @@
#include "netpkt.h"
#include "gamelist.h"

#define HLSW_HEADER "\xFF\xFF\xFF\xFFHLSWLANSEARCH\x00"
#define HLSW_HEADER_LEN 0x12
#define HLSW_HEADER "\xFF\xFF\xFF\xFFHLSWLANSEARCH"
#define HLSW_HEADER_LEN 0x11
#define HLSW_ENTRY_LEN 10
#define MAX_PKT_LEN (HLSW_HEADER_LEN + HLSW_ENTRY_LEN * 140)

@@ -89,7 +89,7 @@ static int server_handler(int fd, void *privdata)
struct sockaddr_in client;
unsigned char buf[32];

int i = sizeof(client);
unsigned int i = sizeof(client);
int ret = recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *)&client, &i);
if (ret <= 0) {
log_print(LOG_WARN, "server_handler(): recvfrom()");


Loading…
Cancel
Save