Merge pull request #207 from illwieckz/games
alternate game id in master server list / never trust qstat for game id
This commit is contained in:
commit
5dc02b93e8
@ -100,7 +100,8 @@ static void master_okbutton_callback (GtkWidget *widget, GtkWidget* window) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
master_to_add = add_master (master_addr_result, master_name_result, master_type, NULL, TRUE, FALSE);
|
// FIXME: gui does not allow to set server_query_type (defaults here as UNKNOWN_SERVER)
|
||||||
|
master_to_add = add_master (master_addr_result, master_name_result, master_type, UNKNOWN_SERVER, NULL, TRUE, FALSE);
|
||||||
if (!master_to_add) {
|
if (!master_to_add) {
|
||||||
dialog_ok (NULL, _("Master address \"%s\" is not valid."),
|
dialog_ok (NULL, _("Master address \"%s\" is not valid."),
|
||||||
master_addr_result);
|
master_addr_result);
|
||||||
|
@ -115,6 +115,7 @@ struct server {
|
|||||||
int ref_count;
|
int ref_count;
|
||||||
|
|
||||||
enum server_type type;
|
enum server_type type;
|
||||||
|
enum server_type server_query_type;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
|
|
||||||
unsigned short maxplayers;
|
unsigned short maxplayers;
|
||||||
@ -135,7 +136,8 @@ struct userver {
|
|||||||
struct server *s;
|
struct server *s;
|
||||||
int ref_count;
|
int ref_count;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
unsigned char type; // enum server_type type;
|
enum server_type type; // enum server_type type;
|
||||||
|
enum server_type server_query_type; // enum server_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -146,6 +148,7 @@ typedef struct {
|
|||||||
typedef struct master {
|
typedef struct master {
|
||||||
char *name;
|
char *name;
|
||||||
enum server_type type;
|
enum server_type type;
|
||||||
|
enum server_type server_query_type;
|
||||||
int isgroup; // is it a real master or master group?
|
int isgroup; // is it a real master or master group?
|
||||||
int user; // is it added or edited by user?
|
int user; // is it added or edited by user?
|
||||||
QFMasterOptions options;
|
QFMasterOptions options;
|
||||||
|
12
src/game.c
12
src/game.c
@ -116,7 +116,7 @@ static int ottd_exec (const struct condef *con, int forkit);
|
|||||||
|
|
||||||
static GList *quake_custom_cfgs (struct game* this, const char *path, const char *mod);
|
static GList *quake_custom_cfgs (struct game* this, const char *path, const char *mod);
|
||||||
|
|
||||||
static void quake_save_info (FILE *f, struct server *s);
|
static void save_server_info (FILE *f, struct server *s);
|
||||||
|
|
||||||
char **get_custom_arguments(enum server_type type, const char *gamestring);
|
char **get_custom_arguments(enum server_type type, const char *gamestring);
|
||||||
|
|
||||||
@ -3599,7 +3599,7 @@ static void quake_save_server_rules (FILE *f, struct server *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void quake_save_info (FILE *f, struct server *s) {
|
static void save_server_info (FILE *f, struct server *s) {
|
||||||
struct player *p;
|
struct player *p;
|
||||||
GSList *list;
|
GSList *list;
|
||||||
|
|
||||||
@ -3615,7 +3615,7 @@ static void quake_save_info (FILE *f, struct server *s) {
|
|||||||
case Q1_SERVER:
|
case Q1_SERVER:
|
||||||
case H2_SERVER:
|
case H2_SERVER:
|
||||||
fprintf (f,
|
fprintf (f,
|
||||||
"%s" QSTAT_DELIM_STR
|
"%s%s%s" QSTAT_DELIM_STR
|
||||||
"%s:%d" QSTAT_DELIM_STR
|
"%s:%d" QSTAT_DELIM_STR
|
||||||
"%s" QSTAT_DELIM_STR
|
"%s" QSTAT_DELIM_STR
|
||||||
"%s:%d" QSTAT_DELIM_STR
|
"%s:%d" QSTAT_DELIM_STR
|
||||||
@ -3626,6 +3626,8 @@ static void quake_save_info (FILE *f, struct server *s) {
|
|||||||
"%d" QSTAT_DELIM_STR
|
"%d" QSTAT_DELIM_STR
|
||||||
"%d\n",
|
"%d\n",
|
||||||
games[s->type].id,
|
games[s->type].id,
|
||||||
|
s->server_query_type != UNKNOWN_SERVER? "|" : "",
|
||||||
|
s->server_query_type != UNKNOWN_SERVER? games[s->server_query_type].id : "",
|
||||||
inet_ntoa (s->host->ip), s->port,
|
inet_ntoa (s->host->ip), s->port,
|
||||||
(s->name)? s->name : "",
|
(s->name)? s->name : "",
|
||||||
inet_ntoa (s->host->ip), s->port,
|
inet_ntoa (s->host->ip), s->port,
|
||||||
@ -3640,7 +3642,7 @@ static void quake_save_info (FILE *f, struct server *s) {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf (f,
|
fprintf (f,
|
||||||
"%s" QSTAT_DELIM_STR
|
"%s%s%s" QSTAT_DELIM_STR
|
||||||
"%s:%d" QSTAT_DELIM_STR
|
"%s:%d" QSTAT_DELIM_STR
|
||||||
"%s" QSTAT_DELIM_STR
|
"%s" QSTAT_DELIM_STR
|
||||||
"%s" QSTAT_DELIM_STR
|
"%s" QSTAT_DELIM_STR
|
||||||
@ -3649,6 +3651,8 @@ static void quake_save_info (FILE *f, struct server *s) {
|
|||||||
"%d" QSTAT_DELIM_STR
|
"%d" QSTAT_DELIM_STR
|
||||||
"%d\n",
|
"%d\n",
|
||||||
games[s->type].id,
|
games[s->type].id,
|
||||||
|
s->server_query_type != UNKNOWN_SERVER? "|" : "",
|
||||||
|
s->server_query_type != UNKNOWN_SERVER? games[s->server_query_type].id : "",
|
||||||
inet_ntoa (s->host->ip), s->port,
|
inet_ntoa (s->host->ip), s->port,
|
||||||
(s->name)? s->name : "",
|
(s->name)? s->name : "",
|
||||||
(s->map)? s->map : "",
|
(s->map)? s->map : "",
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<write_config/>
|
<write_config/>
|
||||||
<exec_client>exec_generic</exec_client>
|
<exec_client>exec_generic</exec_client>
|
||||||
<custom_cfgs/>
|
<custom_cfgs/>
|
||||||
<save_info>quake_save_info</save_info>
|
<save_info>save_server_info</save_info>
|
||||||
<init_maps/>
|
<init_maps/>
|
||||||
<has_map/>
|
<has_map/>
|
||||||
<get_mapshot/>
|
<get_mapshot/>
|
||||||
|
@ -22,6 +22,24 @@ static char *builtin_masters_update_info[] = {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// uses http list instead, replaced 2018-03-24
|
||||||
|
"DELETE AMS,-gsm,armygame gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
"DELETE BF1942,-gsm,bfield1942 gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
"DELETE MHS,-gsm,mohaa gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
"DELETE Q2S:KP,-gsm,kingpin gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
"DELETE RUNESRV,-gsm,rune gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
"DELETE SMS,-gsm,serioussam gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
"DELETE SMSSE,-gsm,serioussamse gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
"DELETE UNS,-gsm,ut gmaster://gsm.qtracker.com:28900 qtracker.com (ut99)",
|
||||||
|
"DELETE UNS,-gsm,unreal gmaster://gsm.qtracker.com:28900 qtracker.com (unreal)",
|
||||||
|
"DELETE UT2004S,-gsm,ut2004 gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
"DELETE UT2S,-gsm,ut2 gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
"DELETE SNS,-gsm,sin gmaster://gsm.qtracker.com:28900 qtracker.com",
|
||||||
|
|
||||||
|
// does no longer work, removed 2018-03-24
|
||||||
|
"DELETE Q2S master://netdome.biz:27900 netdome.biz",
|
||||||
|
"DELETE Q2S master://masterserver.exhale.de:27900 exhale.de", // down since 2011
|
||||||
|
|
||||||
// does no longer work, removed 2018-03-21
|
// does no longer work, removed 2018-03-21
|
||||||
"DELETE UNS,-gsm,ut gmaster://master.noccer.de:28900 noccer.de",
|
"DELETE UNS,-gsm,ut gmaster://master.noccer.de:28900 noccer.de",
|
||||||
|
|
||||||
@ -160,6 +178,22 @@ static char *builtin_masters_update_info[] = {
|
|||||||
|
|
||||||
// added 2018-03-24
|
// added 2018-03-24
|
||||||
"ADD DDAYS http://q2servers.com/?g=dday&raw=1 q2servers.com",
|
"ADD DDAYS http://q2servers.com/?g=dday&raw=1 q2servers.com",
|
||||||
|
"ADD MHS,-gsm,mohaa gmaster://master.x-null.net:28900 x-null.net",
|
||||||
|
"ADD Q2S master://master.rlogin.dk:27900 rlogin.dk",
|
||||||
|
"ADD Q2S http://q2servers.com/?raw=1 q2servers.com",
|
||||||
|
"ADD Q3S master://master.huxxer.de:27950 huxxer.de",
|
||||||
|
"ADD AMS|GPS http://www.qtracker.com/server_list_details.php?game=armyoperations qtracker.com",
|
||||||
|
"ADD BF1942|GPS http://www.qtracker.com/server_list_details.php?game=battlefield1942 qtracker.com",
|
||||||
|
"ADD MHS|GPS http://www.qtracker.com/server_list_details.php?game=medalofhonoralliedassault qtracker.com",
|
||||||
|
"ADD Q2S:KP|GPS http://www.qtracker.com/server_list_details.php?game=kingpin qtracker.com",
|
||||||
|
"ADD RUNESRV|GPS http://www.qtracker.com/server_list_details.php?game=rune qtracker.com",
|
||||||
|
"ADD SMS|GPS http://www.qtracker.com/server_list_details.php?game=serioussam qtracker.com",
|
||||||
|
"ADD SMSSE|GPS http://www.qtracker.com/server_list_details.php?game=serioussamse qtracker.com",
|
||||||
|
"ADD UNS|GPS http://www.qtracker.com/server_list_details.php?game=unrealtournament qtracker.com (ut99)",
|
||||||
|
"ADD UNS|GPS http://www.qtracker.com/server_list_details.php?game=unreal qtracker.com (unreal)",
|
||||||
|
"ADD UT2004S|GPS http://www.qtracker.com/server_list_details.php?game=unrealtournament2004 qtracker.com",
|
||||||
|
"ADD UT2S|GPS http://www.qtracker.com/server_list_details.php?game=unrealtournament2003 qtracker.com",
|
||||||
|
"ADD SNS|GPS http://www.qtracker.com/server_list_details.php?game=sin qtracker.com",
|
||||||
|
|
||||||
// added 2018-03-21
|
// added 2018-03-21
|
||||||
"ADD UNS,-gsm,unreal gmaster://master.hlkclan.net:28900 master.hlkclan.net (unreal)",
|
"ADD UNS,-gsm,unreal gmaster://master.hlkclan.net:28900 master.hlkclan.net (unreal)",
|
||||||
@ -194,20 +228,6 @@ static char *builtin_masters_update_info[] = {
|
|||||||
"ADD UNS,-gsm,ut gmaster://master.333networks.com:28900 333networks.com",
|
"ADD UNS,-gsm,ut gmaster://master.333networks.com:28900 333networks.com",
|
||||||
"ADD UNS,-gsm,ut gmaster://master.errorist.tk:28900 errorist.tk",
|
"ADD UNS,-gsm,ut gmaster://master.errorist.tk:28900 errorist.tk",
|
||||||
|
|
||||||
// added 2015-08-20
|
|
||||||
"ADD AMS,-gsm,armygame gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
"ADD BF1942,-gsm,bfield1942 gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
"ADD MHS,-gsm,mohaa gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
"ADD Q2S:KP,-gsm,kingpin gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
"ADD RUNESRV,-gsm,rune gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
"ADD SMS,-gsm,serioussam gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
"ADD SMSSE,-gsm,serioussamse gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
"ADD UNS,-gsm,ut gmaster://gsm.qtracker.com:28900 qtracker.com (ut99)",
|
|
||||||
"ADD UNS,-gsm,unreal gmaster://gsm.qtracker.com:28900 qtracker.com (unreal)",
|
|
||||||
"ADD UT2004S,-gsm,ut2004 gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
"ADD UT2S,-gsm,ut2 gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
"ADD SNS,-gsm,sin gmaster://gsm.qtracker.com:28900 qtracker.com",
|
|
||||||
|
|
||||||
// added 2015-08-19
|
// added 2015-08-19
|
||||||
"ADD ETLS master://master.etlegacy.com:27950 etlegacy.com",
|
"ADD ETLS master://master.etlegacy.com:27950 etlegacy.com",
|
||||||
|
|
||||||
@ -352,9 +372,6 @@ static char *builtin_masters_update_info[] = {
|
|||||||
// added 2004-10-14
|
// added 2004-10-14
|
||||||
"ADD D3G http://d3.descent.cx/d3cxraw.d3?terse=y descent.cx",
|
"ADD D3G http://d3.descent.cx/d3cxraw.d3?terse=y descent.cx",
|
||||||
|
|
||||||
// added 2004-09-26
|
|
||||||
"ADD Q2S master://netdome.biz netdome.biz",
|
|
||||||
|
|
||||||
// added 2004-08-07
|
// added 2004-08-07
|
||||||
"ADD DM3S master://idnet.ua-corp.com:27650 ua-corp.com",
|
"ADD DM3S master://idnet.ua-corp.com:27650 ua-corp.com",
|
||||||
|
|
||||||
@ -425,6 +442,7 @@ static char *builtin_masters_update_info[] = {
|
|||||||
"ADD RUNESRV lan://255.255.255.255 LAN",
|
"ADD RUNESRV lan://255.255.255.255 LAN",
|
||||||
"ADD SFS lan://255.255.255.255 LAN",
|
"ADD SFS lan://255.255.255.255 LAN",
|
||||||
"ADD SMOKINGUNSS lan://255.255.255.255 LAN",
|
"ADD SMOKINGUNSS lan://255.255.255.255 LAN",
|
||||||
|
"ADD TEES lan://255.255.255.255 LAN",
|
||||||
"ADD T2S lan://255.255.255.255 LAN",
|
"ADD T2S lan://255.255.255.255 LAN",
|
||||||
"ADD TREMFUSIONS lan://255.255.255.255 LAN",
|
"ADD TREMFUSIONS lan://255.255.255.255 LAN",
|
||||||
"ADD TREMULOUSGPPS lan://255.255.255.255 LAN",
|
"ADD TREMULOUSGPPS lan://255.255.255.255 LAN",
|
||||||
|
@ -95,6 +95,7 @@ static struct server *server_new (struct host *h, unsigned short port,
|
|||||||
server->type = type;
|
server->type = type;
|
||||||
server->ping = -1;
|
server->ping = -1;
|
||||||
server->retries = -1;
|
server->retries = -1;
|
||||||
|
server->server_query_type = UNKNOWN_SERVER;
|
||||||
|
|
||||||
#ifdef USE_GEOIP
|
#ifdef USE_GEOIP
|
||||||
server->country_id = geoip_id_by_ip(h->ip);
|
server->country_id = geoip_id_by_ip(h->ip);
|
||||||
@ -116,6 +117,7 @@ static struct userver *userver_new (const char *hostname, unsigned short port,
|
|||||||
userver->hostname = g_strdup (hostname);
|
userver->hostname = g_strdup (hostname);
|
||||||
userver->port = port;
|
userver->port = port;
|
||||||
userver->type = type;
|
userver->type = type;
|
||||||
|
userver->server_query_type = UNKNOWN_SERVER;
|
||||||
|
|
||||||
return userver;
|
return userver;
|
||||||
}
|
}
|
||||||
@ -473,6 +475,7 @@ struct server *userver_set_host (struct userver *us, struct host *h) {
|
|||||||
server = server_add (h, us->port, us->type);
|
server = server_add (h, us->port, us->type);
|
||||||
if (server) {
|
if (server) {
|
||||||
us->s = server;
|
us->s = server;
|
||||||
|
us->s->server_query_type = us->server_query_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
|
86
src/source.c
86
src/source.c
@ -102,7 +102,12 @@ static void save_list (FILE *f, struct master *m) {
|
|||||||
|
|
||||||
for (srv = m->servers; srv; srv = srv->next) {
|
for (srv = m->servers; srv; srv = srv->next) {
|
||||||
s = (struct server *) srv->data;
|
s = (struct server *) srv->data;
|
||||||
fprintf (f, "%s %s:%d\n", games[s->type].id, inet_ntoa (s->host->ip), s->port);
|
fprintf (f, "%s%s%s %s:%d\n",
|
||||||
|
games[s->type].id,
|
||||||
|
s->server_query_type != UNKNOWN_SERVER? "|":"",
|
||||||
|
s->server_query_type != UNKNOWN_SERVER? games[s->server_query_type].id : "",
|
||||||
|
inet_ntoa (s->host->ip),
|
||||||
|
s->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (f, "\n");
|
fprintf (f, "\n");
|
||||||
@ -455,7 +460,7 @@ static void read_lists (const char *filename) {
|
|||||||
char buf[4096];
|
char buf[4096];
|
||||||
char *ch;
|
char *ch;
|
||||||
struct master *m = NULL;
|
struct master *m = NULL;
|
||||||
char *token[8];
|
char *token[8], *pipe;
|
||||||
int n;
|
int n;
|
||||||
enum server_type type;
|
enum server_type type;
|
||||||
|
|
||||||
@ -469,16 +474,18 @@ static void read_lists (const char *filename) {
|
|||||||
|
|
||||||
while (fgets (buf, 4096, z.f)) {
|
while (fgets (buf, 4096, z.f)) {
|
||||||
n = tokenize (buf, token, 8, " \t\n\r");
|
n = tokenize (buf, token, 8, " \t\n\r");
|
||||||
if (n < 1)
|
if (n < 1) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (token[0][0] == '[') { // line is a master
|
if (token[0][0] == '[') { // line is a master
|
||||||
ch = strchr (token[0] + 1, ']'); // does token 0 have a ]?
|
ch = strchr (token[0] + 1, ']'); // does token 0 have a ]?
|
||||||
if (ch) { // it's a favorites or pre 0.9.4e lists file
|
if (ch) { // it's a favorites or pre 0.9.4e lists file
|
||||||
*ch = '\0';
|
*ch = '\0';
|
||||||
|
|
||||||
if (m && m->servers)
|
if (m && m->servers) {
|
||||||
m->servers = g_slist_reverse (m->servers);
|
m->servers = g_slist_reverse (m->servers);
|
||||||
|
}
|
||||||
|
|
||||||
m = read_list_parse_master (token[0] + 1, NULL);
|
m = read_list_parse_master (token[0] + 1, NULL);
|
||||||
}
|
}
|
||||||
@ -488,26 +495,42 @@ static void read_lists (const char *filename) {
|
|||||||
|
|
||||||
*ch = '\0';
|
*ch = '\0';
|
||||||
|
|
||||||
if (m && m->servers)
|
if (m && m->servers) {
|
||||||
m->servers = g_slist_reverse (m->servers);
|
m->servers = g_slist_reverse (m->servers);
|
||||||
|
}
|
||||||
|
|
||||||
m = read_list_parse_master (token[1], token[0] + 1); // master, type
|
m = read_list_parse_master (token[1], token[0] + 1); // master, type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!m || n < 2)
|
if (!m || n < 2) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe = strchr(token[0], '|');
|
||||||
|
|
||||||
|
if (pipe != NULL) {
|
||||||
|
// DESTRUCTIVE
|
||||||
|
*pipe = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
type = id2type (token[0]);
|
type = id2type (token[0]);
|
||||||
|
|
||||||
if (type != UNKNOWN_SERVER)
|
if (type != UNKNOWN_SERVER) {
|
||||||
master_add_server (m, token[1], type);
|
master_add_server (m, token[1], type);
|
||||||
|
|
||||||
|
if (pipe != NULL) {
|
||||||
|
m->server_query_type = id2type(++pipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m && m->servers)
|
if (m && m->servers) {
|
||||||
m->servers = g_slist_reverse (m->servers);
|
m->servers = g_slist_reverse (m->servers);
|
||||||
|
}
|
||||||
|
|
||||||
zstream_close (&z);
|
zstream_close (&z);
|
||||||
g_free (realname);
|
g_free (realname);
|
||||||
@ -807,7 +830,7 @@ static void master_options_release(QFMasterOptions* o, gboolean doit) {
|
|||||||
g_free(o->gsmtype);
|
g_free(o->gsmtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct master *add_master (char *path, char *name, enum server_type type, const char* qstat_query_arg, int user, int lookup_only) {
|
struct master *add_master (char *path, char *name, enum server_type type, enum server_type server_query_type, const char* qstat_query_arg, int user, int lookup_only) {
|
||||||
char *addr = NULL;
|
char *addr = NULL;
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
struct master *m = NULL;
|
struct master *m = NULL;
|
||||||
@ -949,6 +972,7 @@ struct master *add_master (char *path, char *name, enum server_type type, const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m->server_query_type = server_query_type;
|
||||||
m->master_type = query_type;
|
m->master_type = query_type;
|
||||||
m->options = options;
|
m->options = options;
|
||||||
freeoptions = FALSE;
|
freeoptions = FALSE;
|
||||||
@ -1000,13 +1024,22 @@ void free_master (struct master *m) {
|
|||||||
* DESTRUCTIVE
|
* DESTRUCTIVE
|
||||||
* @return qstat_master_option or NULL
|
* @return qstat_master_option or NULL
|
||||||
*/
|
*/
|
||||||
char* master_id2type(char* token, enum server_type* type) {
|
char* master_id2type(char* token, enum server_type* type, enum server_type* server_query_type) {
|
||||||
char* ret = NULL;
|
char* ret = NULL;
|
||||||
char* coma = strchr(token, ',');
|
char* comma = strchr(token, ',');
|
||||||
|
char* pipe = strchr(token, '|');
|
||||||
|
|
||||||
if (coma) {
|
if (comma != NULL) {
|
||||||
*coma = '\0';
|
*comma = '\0';
|
||||||
ret = ++coma;
|
ret = ++comma;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pipe != NULL) {
|
||||||
|
*pipe = '\0';
|
||||||
|
*server_query_type = id2type(++pipe);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*server_query_type = UNKNOWN_SERVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
*type = id2type(token);
|
*type = id2type(token);
|
||||||
@ -1023,6 +1056,7 @@ static void update_master_list_action (const char *action) {
|
|||||||
char *token[4];
|
char *token[4];
|
||||||
int n;
|
int n;
|
||||||
enum server_type type;
|
enum server_type type;
|
||||||
|
enum server_type server_query_type;
|
||||||
struct master *m;
|
struct master *m;
|
||||||
|
|
||||||
str = strdup_strip (action);
|
str = strdup_strip (action);
|
||||||
@ -1033,16 +1067,16 @@ static void update_master_list_action (const char *action) {
|
|||||||
n = tokenize (str, token, 4, " \t\n\r");
|
n = tokenize (str, token, 4, " \t\n\r");
|
||||||
|
|
||||||
if (n == 4) {
|
if (n == 4) {
|
||||||
char* qstat_query_arg = master_id2type (token[1], &type);
|
char* qstat_query_arg = master_id2type (token[1], &type, &server_query_type);
|
||||||
if (type != UNKNOWN_SERVER) {
|
if (type != UNKNOWN_SERVER) {
|
||||||
|
|
||||||
if (g_ascii_strcasecmp (token[0], ACTION_ADD) == 0) {
|
if (g_ascii_strcasecmp (token[0], ACTION_ADD) == 0) {
|
||||||
m = add_master (token[2], token[3], type, qstat_query_arg, FALSE, FALSE);
|
m = add_master (token[2], token[3], type, server_query_type, qstat_query_arg, FALSE, FALSE);
|
||||||
if (m && source_ctree != NULL)
|
if (m && source_ctree != NULL)
|
||||||
source_ctree_add_master (source_ctree, m);
|
source_ctree_add_master (source_ctree, m);
|
||||||
}
|
}
|
||||||
else if (g_ascii_strcasecmp (token[0], ACTION_DELETE) == 0) {
|
else if (g_ascii_strcasecmp (token[0], ACTION_DELETE) == 0) {
|
||||||
m = add_master (token[2], token[3], type, qstat_query_arg, FALSE, TRUE);
|
m = add_master (token[2], token[3], type, server_query_type, qstat_query_arg, FALSE, TRUE);
|
||||||
if (m) {
|
if (m) {
|
||||||
if (source_ctree != NULL)
|
if (source_ctree != NULL)
|
||||||
source_ctree_delete_master (source_ctree, m);
|
source_ctree_delete_master (source_ctree, m);
|
||||||
@ -1125,6 +1159,7 @@ void update_master_list_web (void) {
|
|||||||
static void load_master_list (void) {
|
static void load_master_list (void) {
|
||||||
struct master *m;
|
struct master *m;
|
||||||
enum server_type type;
|
enum server_type type;
|
||||||
|
enum server_type server_query_type;
|
||||||
char* qstat_query_arg = NULL;
|
char* qstat_query_arg = NULL;
|
||||||
char conf[64];
|
char conf[64];
|
||||||
char *token[3];
|
char *token[3];
|
||||||
@ -1151,10 +1186,11 @@ static void load_master_list (void) {
|
|||||||
tmp = strrchr (token[0], ',');
|
tmp = strrchr (token[0], ',');
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
user = (g_ascii_strcasecmp (tmp+1, "USER") == 0);
|
user = (g_ascii_strcasecmp (tmp+1, "USER") == 0);
|
||||||
if (user)
|
if (user) {
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
qstat_query_arg = master_id2type (token[0], &type);
|
qstat_query_arg = master_id2type (token[0], &type, &server_query_type);
|
||||||
|
|
||||||
if (type != UNKNOWN_SERVER) {
|
if (type != UNKNOWN_SERVER) {
|
||||||
|
|
||||||
@ -1162,7 +1198,7 @@ static void load_master_list (void) {
|
|||||||
* and fix m->user after that.
|
* and fix m->user after that.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
m = add_master (token[1], token[2], type, qstat_query_arg, TRUE, FALSE);
|
m = add_master (token[1], token[2], type, server_query_type, qstat_query_arg, TRUE, FALSE);
|
||||||
if (m)
|
if (m)
|
||||||
m->user = user;
|
m->user = user;
|
||||||
}
|
}
|
||||||
@ -1197,11 +1233,13 @@ static void save_master_list (void) {
|
|||||||
|
|
||||||
g_snprintf (conf, 64, "master%d", n);
|
g_snprintf (conf, 64, "master%d", n);
|
||||||
|
|
||||||
g_snprintf (typeid, sizeof(typeid), "%s%s%s%s",
|
g_snprintf (typeid, sizeof(typeid), "%s%s%s%s%s%s",
|
||||||
type2id (m->type),
|
type2id (m->type),
|
||||||
m->_qstat_master_option?",":"",
|
m->server_query_type != UNKNOWN_SERVER? "|" : "",
|
||||||
m->_qstat_master_option?m->_qstat_master_option:"",
|
m->server_query_type != UNKNOWN_SERVER? type2id (m->server_query_type) : "",
|
||||||
m->user?",USER":"");
|
m->_qstat_master_option? "," : "",
|
||||||
|
m->_qstat_master_option? m->_qstat_master_option : "",
|
||||||
|
m->user? ",USER" : "");
|
||||||
|
|
||||||
str = master_to_url(m);
|
str = master_to_url(m);
|
||||||
confstr = g_strjoin (" ", typeid, str, m->name, NULL);
|
confstr = g_strjoin (" ", typeid, str, m->name, NULL);
|
||||||
|
@ -26,10 +26,6 @@
|
|||||||
#define FILENAME_LISTS "lists"
|
#define FILENAME_LISTS "lists"
|
||||||
#define FILENAME_SRVINFO "srvinfo"
|
#define FILENAME_SRVINFO "srvinfo"
|
||||||
|
|
||||||
// #define PREFIX_MASTER "master://"
|
|
||||||
// #define PREFIX_GMASTER "gmaster://"
|
|
||||||
// #define PREFIX_URL_HTTP "http://"
|
|
||||||
|
|
||||||
#define ACTION_ADD "ADD"
|
#define ACTION_ADD "ADD"
|
||||||
#define ACTION_DELETE "DELETE"
|
#define ACTION_DELETE "DELETE"
|
||||||
|
|
||||||
@ -42,6 +38,7 @@ extern GSList *master_groups;
|
|||||||
extern struct master *add_master (char *path,
|
extern struct master *add_master (char *path,
|
||||||
char *name,
|
char *name,
|
||||||
enum server_type type,
|
enum server_type type,
|
||||||
|
enum server_type server_query_type,
|
||||||
const char* qstat_query_arg,
|
const char* qstat_query_arg,
|
||||||
int user,
|
int user,
|
||||||
int lookup_only);
|
int lookup_only);
|
||||||
|
91
src/stat.c
91
src/stat.c
@ -144,7 +144,7 @@ static int parse_master_output (char *str, struct stat_conn *conn) {
|
|||||||
debug (6, "parse_master_output(%s,%p)",str,conn);
|
debug (6, "parse_master_output(%s,%p)",str,conn);
|
||||||
n = tokenize_bychar (str, token, 8, QSTAT_DELIM);
|
n = tokenize_bychar (str, token, 8, QSTAT_DELIM);
|
||||||
|
|
||||||
// UGLY HACK UGLY HACK UGLY HACK UGLY HACK
|
// HACK: UGLY HACK UGLY HACK UGLY HACK UGLY HACK
|
||||||
// output from UT 2003 http server is formatted as
|
// output from UT 2003 http server is formatted as
|
||||||
// ip port gamespy_port
|
// ip port gamespy_port
|
||||||
// not the standard ip:port
|
// not the standard ip:port
|
||||||
@ -170,7 +170,15 @@ static int parse_master_output (char *str, struct stat_conn *conn) {
|
|||||||
if (n <= 3) {
|
if (n <= 3) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
type = id2type (token[0]);
|
|
||||||
|
// never do that: qstat returns the qstat_str, not the game id
|
||||||
|
// for example we use -cods for COD:UO that will return CODS
|
||||||
|
// instead of CODUOS and XQF will mark the server for the
|
||||||
|
// wrong game, never trust qstat, always trust XQF
|
||||||
|
// type = id2type (token[0]);
|
||||||
|
|
||||||
|
type = conn->master->type;
|
||||||
|
|
||||||
n = 2; // we only need type and ip
|
n = 2; // we only need type and ip
|
||||||
}
|
}
|
||||||
else if (n >= 3) {
|
else if (n >= 3) {
|
||||||
@ -210,15 +218,29 @@ static int parse_master_output (char *str, struct stat_conn *conn) {
|
|||||||
|
|
||||||
switch (n) {
|
switch (n) {
|
||||||
|
|
||||||
|
// line in the form:
|
||||||
|
// <hostname>:<port>
|
||||||
|
// expected to be found in both http list and file list
|
||||||
case 1:
|
case 1:
|
||||||
type = conn->master->type;
|
type = conn->master->type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// line in the form:
|
||||||
|
// <type>\0<hostname>:<port>
|
||||||
|
// expected to be found in qstat output
|
||||||
case 2:
|
case 2:
|
||||||
type = id2type (token[0]);
|
// never do that: qstat returns the qstat_str, not the game id
|
||||||
|
// for example we use -cods for COD:UO that will return CODS
|
||||||
|
// instead of CODUOS and XQF will mark the server for the
|
||||||
|
// wrong game, never trust qstat, always trust XQF
|
||||||
|
// type = id2type (token[0]);
|
||||||
|
|
||||||
|
type = conn->master->type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// this is not expected at all
|
||||||
default:
|
default:
|
||||||
|
debug(3, "parse_master_output() -- bad string %s",str);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -253,6 +275,9 @@ static int parse_master_output (char *str, struct stat_conn *conn) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (conn->master->server_query_type != UNKNOWN_SERVER) {
|
||||||
|
s->server_query_type = conn->master->server_query_type;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
When the "conn" is freed, it will call the function
|
When the "conn" is freed, it will call the function
|
||||||
@ -273,6 +298,11 @@ static int parse_master_output (char *str, struct stat_conn *conn) {
|
|||||||
|
|
||||||
port += conn->master->options.portadjust;
|
port += conn->master->options.portadjust;
|
||||||
if ((us = userver_add (addr, port, type)) != NULL) {
|
if ((us = userver_add (addr, port, type)) != NULL) {
|
||||||
|
|
||||||
|
if (conn->master->server_query_type != UNKNOWN_SERVER) {
|
||||||
|
us->server_query_type = conn->master->server_query_type;
|
||||||
|
}
|
||||||
|
|
||||||
// conn->uservers = userver_list_add (conn->uservers, us);
|
// conn->uservers = userver_list_add (conn->uservers, us);
|
||||||
conn->uservers = g_slist_prepend (conn->uservers, us);
|
conn->uservers = g_slist_prepend (conn->uservers, us);
|
||||||
userver_ref(us);
|
userver_ref(us);
|
||||||
@ -336,6 +366,7 @@ static gboolean stat_master_input_callback (GIOChannel *chan, GIOCondition condi
|
|||||||
} else {
|
} else {
|
||||||
stat_master_update_done (conn, job, conn->master, SOURCE_UP);
|
stat_master_update_done (conn, job, conn->master, SOURCE_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
stat_update_masters (job);
|
stat_update_masters (job);
|
||||||
debug_decrease_indent();
|
debug_decrease_indent();
|
||||||
g_free(buf);
|
g_free(buf);
|
||||||
@ -413,13 +444,20 @@ static struct server *parse_server (char *token[], int n, time_t refreshed, int
|
|||||||
struct host *h;
|
struct host *h;
|
||||||
struct server *server;
|
struct server *server;
|
||||||
enum server_type type;
|
enum server_type type;
|
||||||
char *addr;
|
char *addr, *pipe;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
|
|
||||||
if (n < 3) {
|
if (n < 3) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pipe = strchr(token[0], '|');
|
||||||
|
|
||||||
|
if (pipe != NULL) {
|
||||||
|
// DESTRUCTIVE
|
||||||
|
*pipe = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
type = id2type (token[0]);
|
type = id2type (token[0]);
|
||||||
|
|
||||||
if (type == UNKNOWN_SERVER) {
|
if (type == UNKNOWN_SERVER) {
|
||||||
@ -438,7 +476,11 @@ static struct server *parse_server (char *token[], int n, time_t refreshed, int
|
|||||||
|
|
||||||
server = server_add (h, port, type);
|
server = server_add (h, port, type);
|
||||||
|
|
||||||
debug (6, "server %lx retreived", server);
|
if (pipe != NULL) {
|
||||||
|
server->server_query_type = id2type(++pipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug (6, "server %lx retrieved", server);
|
||||||
|
|
||||||
server->flt_mask &= ~FILTER_SERVER_MASK;
|
server->flt_mask &= ~FILTER_SERVER_MASK;
|
||||||
|
|
||||||
@ -475,7 +517,7 @@ static struct server *parse_server (char *token[], int n, time_t refreshed, int
|
|||||||
/*
|
/*
|
||||||
We have a function to parse the server information,
|
We have a function to parse the server information,
|
||||||
so first we free all of the data elements of this
|
so first we free all of the data elements of this
|
||||||
structure but not the structure its self. This
|
structure but not the structure itself. This
|
||||||
is because the *_analyse functions should assign values
|
is because the *_analyse functions should assign values
|
||||||
to each of the elemets.
|
to each of the elemets.
|
||||||
*/
|
*/
|
||||||
@ -1076,7 +1118,7 @@ static struct stat_conn *stat_update_master_qstat (struct stat_job *job, struct
|
|||||||
int argi = 0;
|
int argi = 0;
|
||||||
char buf1[64];
|
char buf1[64];
|
||||||
char* arg_type = NULL;
|
char* arg_type = NULL;
|
||||||
char buf3[64];
|
char buf2[64];
|
||||||
char buf_rawarg[] = { QSTAT_DELIM, '\0' };
|
char buf_rawarg[] = { QSTAT_DELIM, '\0' };
|
||||||
struct stat_conn *conn = NULL;
|
struct stat_conn *conn = NULL;
|
||||||
char *cmd = NULL;
|
char *cmd = NULL;
|
||||||
@ -1222,6 +1264,7 @@ static struct stat_conn *stat_update_master_qstat (struct stat_job *job, struct
|
|||||||
startprog = 0;
|
startprog = 0;
|
||||||
file=strdup_strip(m->url + strlen(master_prefixes[MASTER_FILE]));
|
file=strdup_strip(m->url + strlen(master_prefixes[MASTER_FILE]));
|
||||||
}
|
}
|
||||||
|
// if MASTER_HTTP
|
||||||
else {
|
else {
|
||||||
cmd = strdup_strip (HTTP_HELPER);
|
cmd = strdup_strip (HTTP_HELPER);
|
||||||
|
|
||||||
@ -1362,11 +1405,10 @@ static struct stat_conn *stat_update_master_qstat (struct stat_job *job, struct
|
|||||||
arg_type = g_strdup_printf ("%s,outfile", master_qstat_option(m));
|
arg_type = g_strdup_printf ("%s,outfile", master_qstat_option(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
argv[argi++] = arg_type;
|
argv[argi++] = arg_type;
|
||||||
|
|
||||||
argv[argi++] = buf3;
|
argv[argi++] = buf2;
|
||||||
g_snprintf (buf3, 64, "%s%s:%d,-", m->master_type == MASTER_LAN?"+":"" ,inet_ntoa (m->host->ip), m->port);
|
g_snprintf (buf2, 64, "%s%s:%d,-", m->master_type == MASTER_LAN?"+":"" ,inet_ntoa (m->host->ip), m->port);
|
||||||
|
|
||||||
argv[argi] = NULL;
|
argv[argi] = NULL;
|
||||||
|
|
||||||
@ -1400,8 +1442,7 @@ out:
|
|||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX_SERVERS_IN_CMDLINE 16
|
||||||
#define MAX_SERVERS_IN_CMDLINE 8
|
|
||||||
|
|
||||||
static struct stat_conn *stat_open_conn_qstat (struct stat_job *job) {
|
static struct stat_conn *stat_open_conn_qstat (struct stat_job *job) {
|
||||||
struct server *s = NULL;
|
struct server *s = NULL;
|
||||||
@ -1412,6 +1453,8 @@ static struct stat_conn *stat_open_conn_qstat (struct stat_job *job) {
|
|||||||
char *fn = NULL;
|
char *fn = NULL;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
struct stat_conn *conn;
|
struct stat_conn *conn;
|
||||||
|
char *qstat_query_option;
|
||||||
|
char *qstat_query_str;
|
||||||
char srcport[12] = {0};
|
char srcport[12] = {0};
|
||||||
|
|
||||||
if (!job->servers) {
|
if (!job->servers) {
|
||||||
@ -1467,8 +1510,14 @@ static struct stat_conn *stat_open_conn_qstat (struct stat_job *job) {
|
|||||||
for (tmp = job->servers; tmp; tmp = tmp->next) {
|
for (tmp = job->servers; tmp; tmp = tmp->next) {
|
||||||
s = (struct server *) tmp->data;
|
s = (struct server *) tmp->data;
|
||||||
|
|
||||||
if (games[s->type].qstat_option)
|
if (s->server_query_type != UNKNOWN_SERVER) {
|
||||||
argv[argi++] = games[s->type].qstat_option;
|
qstat_query_option = games[s->server_query_type].qstat_option;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qstat_query_option = games[s->type].qstat_option;
|
||||||
|
}
|
||||||
|
|
||||||
|
argv[argi++] = qstat_query_option;
|
||||||
|
|
||||||
argv[argi++] = &buf[bufi];
|
argv[argi++] = &buf[bufi];
|
||||||
bufi += 1 + g_snprintf (&buf[bufi], sizeof (buf) - bufi, "%s:%d", inet_ntoa (s->host->ip), s->port);
|
bufi += 1 + g_snprintf (&buf[bufi], sizeof (buf) - bufi, "%s:%d", inet_ntoa (s->host->ip), s->port);
|
||||||
@ -1491,9 +1540,17 @@ static struct stat_conn *stat_open_conn_qstat (struct stat_job *job) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tmp =job-> servers; tmp; tmp = tmp->next) {
|
for (tmp =job->servers; tmp; tmp = tmp->next) {
|
||||||
s = (struct server *) tmp->data;
|
s = (struct server *) tmp->data;
|
||||||
fprintf (f, "%s %s:%d\n", games[s->type].qstat_str, inet_ntoa (s->host->ip), s->port);
|
|
||||||
|
if (s->server_query_type != UNKNOWN_SERVER) {
|
||||||
|
qstat_query_str = games[s->server_query_type].qstat_str;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qstat_query_str = games[s->type].qstat_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (f, "%s %s:%d\n", qstat_query_str, inet_ntoa (s->host->ip), s->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
@ -1726,6 +1783,8 @@ static void stat_name_resolved_callback (char *id, struct host *h, enum dns_stat
|
|||||||
server_free_info (us->s);
|
server_free_info (us->s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
us->s->server_query_type = us->server_query_type;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
o When the job is freed, the list will
|
o When the job is freed, the list will
|
||||||
be freed as well. This will take care of
|
be freed as well. This will take care of
|
||||||
|
Loading…
x
Reference in New Issue
Block a user