Version 0.41
This commit is contained in:
parent
6557d31b7d
commit
cb90132d40
@ -21,14 +21,20 @@
|
||||
#include "plugin.h"
|
||||
|
||||
struct scan_ports port_arr[] = {
|
||||
{ 27960, 27969, 6 }, /* Quake3(6), Elite Force(7) */
|
||||
{ 28960, 28963, 31 }, /* Call of Duty(31) */
|
||||
{ 27960, 27969, 6 }, /* Quake3(6), Elite Force(7), Enemy Territory(25) */
|
||||
{ 28960, 28963, 31 }, /* Call of Duty(31), Call of Duty: United Offensive (42) */
|
||||
{ 0,0,0 }
|
||||
};
|
||||
|
||||
static char scanmsg[] = "\xff\xff\xff\xffgetStatus";
|
||||
static char replymsg[] = "\xff\xff\xff\xffstatusResponse";
|
||||
|
||||
static char q3_reply[] = "\\version\\Q3 ";
|
||||
static char ef_reply[] = "\\version\\ST:V ";
|
||||
static char et_reply[] = "\\version\\ET ";
|
||||
static char cod_reply[] = "\\gamename\\Call of Duty\\";
|
||||
static char coduo_reply[] = "\\gamename\\CoD:United Offensive\\";
|
||||
|
||||
int scan(void) {
|
||||
pkt_send_portarr(NULL, port_arr, scanmsg, strlen(scanmsg));
|
||||
return 1;
|
||||
@ -43,16 +49,33 @@ int parse(struct net_pkt *pkt) {
|
||||
if (pkt_memcmp(pkt, 0, replymsg, strlen(replymsg)))
|
||||
return 0;
|
||||
|
||||
if (gameid == 6) {
|
||||
if (pkt_memmem(pkt, 0, "\\version\\Q3 ", 12)) {
|
||||
switch (gameid) {
|
||||
case 6: /* q3, ef, et */
|
||||
if (pkt_memmem(pkt, 0, q3_reply, strlen(q3_reply))) {
|
||||
gameid = 6;
|
||||
|
||||
} else if (pkt_memmem(pkt, 0, "\\version\\ST:V ", 14)) {
|
||||
} else if (pkt_memmem(pkt, 0, ef_reply, strlen(ef_reply))) {
|
||||
gameid = 7;
|
||||
|
||||
} else if (pkt_memmem(pkt, 0, et_reply, strlen(et_reply))) {
|
||||
gameid = 25;
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 31: /* cod, cod:uo */
|
||||
if (pkt_memmem(pkt, 0, cod_reply, strlen(cod_reply))) {
|
||||
gameid = 31;
|
||||
|
||||
} else if (pkt_memmem(pkt, 0, coduo_reply, strlen(coduo_reply))) {
|
||||
gameid = 42;
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
server_add_pkt(gameid, pkt);
|
||||
|
16
plugins/ut.c
16
plugins/ut.c
@ -21,12 +21,13 @@
|
||||
#include "plugin.h"
|
||||
|
||||
struct scan_ports port_arr[] = {
|
||||
{ 8777, 8786, 5 }, /* Unreal Tournament */
|
||||
{ 8777, 8786, 5 }, /* Unreal Tournament (5), Ravenshield (-) */
|
||||
{ 0,0,0 }
|
||||
};
|
||||
|
||||
static char scanmsg[] = "REPORTQUERY";
|
||||
static char ut_reply[] = "ut ";
|
||||
static char rvs_reply[] = "rvnshld 0";
|
||||
|
||||
int scan(void) {
|
||||
pkt_send_portarr(NULL, port_arr, scanmsg, strlen(scanmsg));
|
||||
@ -41,14 +42,15 @@ int parse(struct net_pkt *pkt) {
|
||||
return 0;
|
||||
|
||||
switch (gameid) {
|
||||
case 5: /* Unreal Tournament */
|
||||
p = pkt_memmem(pkt, 0, ut_reply, strlen(ut_reply));
|
||||
if (!p)
|
||||
return 0;
|
||||
case 5: /* ut, rvs */
|
||||
if ((p = pkt_memmem(pkt, 0, ut_reply, strlen(ut_reply)))) {
|
||||
port = pkt_atoi(pkt, p + strlen(ut_reply));
|
||||
server_add(gameid, pkt->addr.sin_addr.s_addr, port -1, port);
|
||||
|
||||
port = pkt_atoi(pkt, p + strlen(ut_reply));
|
||||
} else if ((p = pkt_memmem(pkt, 0, rvs_reply, strlen(rvs_reply)))) {
|
||||
server_add_pkt(0, pkt);
|
||||
|
||||
server_add(gameid, pkt->addr.sin_addr.s_addr, port -1, port);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
|
||||
// plugin_load("plugins/hlswproxy.so");
|
||||
plugin_load("plugins/hlswproxy.so");
|
||||
plugin_load("plugins/q3engine.so");
|
||||
plugin_load("plugins/quake2.so");
|
||||
plugin_load("plugins/gamespy1.so");
|
||||
|
@ -24,6 +24,8 @@
|
||||
#define __USE_GNU
|
||||
#include <string.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
@ -183,10 +185,17 @@ unsigned short pkt_getport(struct net_pkt *pkt) {
|
||||
* @return int
|
||||
*/
|
||||
int pkt_atoi(struct net_pkt *pkt, void *p) {
|
||||
/* check buffer bounds */
|
||||
if ((void *)pkt->buf > p || ((void *)pkt->buf + pkt->size) < p)
|
||||
int val = 0;
|
||||
void *max = ((void *)pkt->buf + pkt->size);
|
||||
char *c = p;
|
||||
|
||||
/* check lower bounds */
|
||||
if ((void *)pkt->buf > p || p > max)
|
||||
return 0;
|
||||
|
||||
// TODO: kann ueber paketlaenge lesen
|
||||
return atoi(p);
|
||||
while (isdigit(*c) && (void *)c < max)
|
||||
val = (val * 10) + (*c++ - 0x30);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -104,9 +104,11 @@ void scan_receive(void) {
|
||||
i = sizeof(struct sockaddr_in);
|
||||
pkt->size = recvfrom(scan_sock, pkt->buf, recvsize, 0, (struct sockaddr *)&pkt->addr, &i);
|
||||
|
||||
if (!plugins_parse(pkt))
|
||||
log_print("scan_receive(): received unknown packet");
|
||||
|
||||
if (!plugins_parse(pkt)) {
|
||||
log_print("scan_receive(): unknown packet: %s:%d size:%d",
|
||||
inet_ntoa(pkt->addr.sin_addr), ntohs(pkt->addr.sin_port), pkt->size);
|
||||
}
|
||||
|
||||
free(pkt);
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ int server_add(u_int16_t gameid, u_int32_t ip, u_int16_t port1, u_int16_t port2)
|
||||
{
|
||||
struct in_addr tmp;
|
||||
tmp.s_addr = server.ip;
|
||||
printf("server_add_new: gameid=%d ip=%s port1=%d port2=%d\n",
|
||||
printf("server_add_new: gameid=%2d ip=%15s port1=%5d port2=%5d\n",
|
||||
server.gameid, inet_ntoa(tmp), server.port1, server.port2);
|
||||
}
|
||||
#endif
|
||||
@ -123,7 +123,7 @@ void server_collector(void) {
|
||||
{
|
||||
struct in_addr tmp2;
|
||||
tmp2.s_addr = server->ip;
|
||||
printf("server timeout: gameid=%d ip=%s port1=%d port2=%d\n",
|
||||
printf("server timeout: gameid=%2d ip=%15s port1=%5d port2=%5d\n",
|
||||
server->gameid, inet_ntoa(tmp2), server->port1, server->port2);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user