Skip to content

Commit

Permalink
Feat: add givenPortOnly as gamedig option (#3532)
Browse files Browse the repository at this point in the history
  • Loading branch information
chakflying authored Aug 7, 2023
1 parent 4e0bb39 commit 2921f33
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions db/patch-add-gamedig-given-port.sql
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions server/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

/**
Expand Down
7 changes: 6 additions & 1 deletion server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 3 additions & 1 deletion src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
11 changes: 11 additions & 0 deletions src/pages/EditMonitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,16 @@
</div>
</div>

<div v-if="monitor.type === 'gamedig'" class="my-3 form-check">
<input id="gamedig-guess-port" v-model="monitor.gamedigGivenPortOnly" :true-value="false" :false-value="true" class="form-check-input" type="checkbox">
<label class="form-check-label" for="gamedig-guess-port">
{{ $t("gamedigGuessPort") }}
</label>
<div class="form-text">
{{ $t("gamedigGuessPortDescription") }}
</div>
</div>

<!-- Ping packet size -->
<div v-if="monitor.type === 'ping'" class="my-3">
<label for="packet-size" class="form-label">{{ $t("Packet Size") }}</label>
Expand Down Expand Up @@ -870,6 +880,7 @@ const monitorDefaults = {
kafkaProducerSaslOptions: {
mechanism: "None",
},
gamedigGivenPortOnly: true,
};
export default {
Expand Down

0 comments on commit 2921f33

Please sign in to comment.