From 257d3a39f7831f3be98838aab04322e80d71bcb4 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 7 Aug 2023 05:48:48 +0800 Subject: [PATCH] Feat: add givenPortOnly as gamedig option --- db/patch-add-gamedig-given-port.sql | 7 +++++++ server/database.js | 1 + server/model/monitor.js | 7 ++++++- server/server.js | 1 + src/lang/en.json | 4 +++- src/pages/EditMonitor.vue | 11 +++++++++++ 6 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 db/patch-add-gamedig-given-port.sql diff --git a/db/patch-add-gamedig-given-port.sql b/db/patch-add-gamedig-given-port.sql new file mode 100644 index 0000000000..897a9c72f7 --- /dev/null +++ b/db/patch-add-gamedig-given-port.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD gamedig_given_port_only BOOLEAN default 1 not null; + +COMMIT; diff --git a/server/database.js b/server/database.js index ed4e4d1b1b..c00f950be4 100644 --- a/server/database.js +++ b/server/database.js @@ -80,6 +80,7 @@ class Database { "patch-add-certificate-expiry-status-page.sql": true, "patch-monitor-oauth-cc.sql": true, "patch-add-timeout-monitor.sql": true, + "patch-add-gamedig-given-port.sql": true, }; /** diff --git a/server/model/monitor.js b/server/model/monitor.js index 152a2c72a6..5b0481fdba 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -135,6 +135,7 @@ class Monitor extends BeanModel { radiusCalledStationId: this.radiusCalledStationId, radiusCallingStationId: this.radiusCallingStationId, game: this.game, + gamedigGivenPortOnly: this.getGameDigGivenPortOnly(), httpBodyEncoding: this.httpBodyEncoding, jsonPath: this.jsonPath, expectedValue: this.expectedValue, @@ -280,6 +281,10 @@ class Monitor extends BeanModel { return JSON.parse(this.accepted_statuscodes_json); } + getGameDigGivenPortOnly() { + return Boolean(this.gamedigGivenPortOnly); + } + /** * Start monitor * @param {Server} io Socket server instance @@ -687,7 +692,7 @@ class Monitor extends BeanModel { type: this.game, host: this.hostname, port: this.port, - givenPortOnly: true, + givenPortOnly: this.getGameDigGivenPortOnly(), }); bean.msg = state.name; diff --git a/server/server.js b/server/server.js index b5f15f67d8..db1dc879c8 100644 --- a/server/server.js +++ b/server/server.js @@ -775,6 +775,7 @@ let needSetup = false; bean.kafkaProducerAllowAutoTopicCreation = monitor.kafkaProducerAllowAutoTopicCreation; bean.kafkaProducerSaslOptions = JSON.stringify(monitor.kafkaProducerSaslOptions); bean.kafkaProducerMessage = monitor.kafkaProducerMessage; + bean.gamedigGivenPortOnly = monitor.gamedigGivenPortOnly; bean.validate(); diff --git a/src/lang/en.json b/src/lang/en.json index 003e7596b1..fda976e83a 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -801,5 +801,7 @@ "nostrRecipients": "Recipients Public Keys (npub)", "nostrRecipientsHelp": "npub format, one per line", "showCertificateExpiry": "Show Certificate Expiry", - "noOrBadCertificate": "No/Bad Certificate" + "noOrBadCertificate": "No/Bad Certificate", + "gamedigGuessPort": "Gamedig: Guess Port", + "gamedigGuessPortDescription": "The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server." } diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index c13ecc7a6f..fe2392b50c 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -455,6 +455,16 @@ +
+ + +
+ {{ $t("gamedigGuessPortDescription") }} +
+
+
@@ -870,6 +880,7 @@ const monitorDefaults = { kafkaProducerSaslOptions: { mechanism: "None", }, + gamedigGivenPortOnly: true, }; export default {