mirror of
https://github.com/a-sync/game-server-watcher.git
synced 2026-07-29 08:52:34 -04:00
gamedig: add support for token query field
This commit is contained in:
@@ -111,6 +111,13 @@ $(async () => {
|
||||
"grid_columns": 6
|
||||
}
|
||||
},
|
||||
"token": {
|
||||
"title": "Terraria tshock REST user token",
|
||||
"type": "string",
|
||||
"options": {
|
||||
"grid_columns": 12
|
||||
}
|
||||
},
|
||||
"updateIntervalMinutes": {
|
||||
"title": "Update interval (minutes) [NOT IMPLEMENTED]",
|
||||
"type": "integer",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import { Player, query, QueryResult } from 'gamedig';
|
||||
import { Player, query, QueryResult, Type } from 'gamedig';
|
||||
import { Low, JSONFile } from '@commonify/lowdb';
|
||||
import ipRegex from './lib/ipregex';
|
||||
import getIP from './lib/getip';
|
||||
@@ -48,6 +48,20 @@ interface qRes extends QueryResult {
|
||||
numplayers: number;
|
||||
}
|
||||
|
||||
interface QueryOptions {
|
||||
type: Type;
|
||||
host: string;
|
||||
port?: number;
|
||||
ipfamily?: number;
|
||||
maxAttempts?: number;
|
||||
socketTimeout?: number;
|
||||
attemptTimeout?: number;
|
||||
givenPortOnly?: boolean;
|
||||
debug?: boolean;
|
||||
requestRules?: boolean;
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export class GameServer {
|
||||
public ip: string;
|
||||
public info?: Info;
|
||||
@@ -97,7 +111,9 @@ export class GameServer {
|
||||
host: this.config.host,
|
||||
port: this.config.port,
|
||||
type: this.config.type,
|
||||
}) as qRes;
|
||||
requestRules: false,
|
||||
token: this.config.token
|
||||
} as QueryOptions) as qRes;
|
||||
|
||||
const raw = res.raw as { game: string; folder: string; };
|
||||
const game = raw.game || raw.folder || this.config.type;
|
||||
|
||||
@@ -27,8 +27,9 @@ export interface GameServerConfig {
|
||||
updateIntervalMinutes?: number;//5
|
||||
graphHistoryHours?: number;//12
|
||||
timezoneOffset?: number;//0
|
||||
discord?: DiscordConfig[],
|
||||
discord?: DiscordConfig[];
|
||||
telegram?: TelegramConfig[];
|
||||
token?: string;
|
||||
}
|
||||
|
||||
const adapter = new JSONFile<GameServerConfig[]>(DATA_PATH + 'default.config.json');
|
||||
|
||||
Reference in New Issue
Block a user