From 2921f33c24eaa578113b8fea593f50aad6659269 Mon Sep 17 00:00:00 2001 From: Nelson Chan <3271800+chakflying@users.noreply.github.com> Date: Tue, 8 Aug 2023 03:14:21 +0800 Subject: [PATCH] Feat: add givenPortOnly as gamedig option (#3532) --- 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 000000000..897a9c72f --- /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 ed4e4d1b1..c00f950be 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 152a2c72a..5b0481fdb 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 da3fb5ba1..d2af1cf41 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 f093af501..772e57299 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -804,5 +804,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 0e1faf372..bc98741b5 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 {