mirror of
https://github.com/skylord123/node-red-contrib-gamedig.git
synced 2026-05-19 13:43:18 -06:00
Compare commits
2 Commits
a5498a4ba9
..
2.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
| facf77e1fa | |||
| f6078118c0 |
@@ -1,21 +1,16 @@
|
||||
# node-red-contrib-gamedig
|
||||
|
||||
Query for server information of most game/voice servers using Node-RED.
|
||||
Query for the status of most game/voice servers using Node-RED.
|
||||
|
||||
This package adds the node "Query Game Server" that uses the NPM package [GameDig](https://www.npmjs.com/package/gamedig) to query if a server is online or not and if so returns the data of the server.
|
||||
|
||||
You can pass the server type, host, and port on the input message or define them on the node (settings defined on the node will override msg values).
|
||||
|
||||
[Click here](https://github.com/gamedig/node-gamedig#return-value) if you want more information about what this library parses and standardizes from the server response.
|
||||
|
||||
### Usage Examples
|
||||
- #### Inserting query data into InfluxDB and using Grafana to view results
|
||||

|
||||
I created a post on my website about how to use this node to query gameservers and store the results in InfluxDB. I then give a dashboard in Grafana that can be used to display the data. Check it out here:
|
||||
https://skylar.tech/tracking-game-server-statistics-using-node-red-influxdb-and-grafana/
|
||||
|
||||
- #### Automatically restarting servers when unavailable
|
||||
Ever host a server and have it stop responding but the process doesn't crash so it doesn't auto restart? If you pair this with something like [node-red-contrib-dockerode](https://flows.nodered.org/node/node-red-contrib-dockerode) you can automatically restart the container/process if the query fails X times to respond.
|
||||
#### Inserting query data into InfluxDB and using Grafana to view results
|
||||

|
||||
I created a post on my website about how to use this node to query gameservers and store the results in InfluxDB. I then give a dashboard in Grafana that can be used to display the data. Check it out here:
|
||||
https://skylar.tech/tracking-game-server-statistics-using-node-red-influxdb-and-grafana/
|
||||
|
||||
### Other Packages
|
||||
|
||||
|
||||
+3
-77
@@ -11,10 +11,6 @@
|
||||
max_attempts: { value: '' },
|
||||
socket_timeout: { value: '' },
|
||||
attempt_timeout: { value: '' },
|
||||
given_port_only: { value: '' },
|
||||
ip_family: { value: '0' },
|
||||
debug: { value: '' },
|
||||
request_rules: { value: '' }
|
||||
},
|
||||
inputs:1,
|
||||
outputs:1,
|
||||
@@ -83,7 +79,7 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-port"><i class="fa fa-server"></i> Port</label>
|
||||
<label for="node-input-port"><i class="fa fa-ethernet"></i> Port</label>
|
||||
<input type="text" id="node-input-port" placeholder="msg.host" />
|
||||
</div>
|
||||
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
|
||||
@@ -121,63 +117,13 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-attempt_timeout"><i class="fa fa-cogs"></i> Attempt Timeout</label>
|
||||
<label for="node-input-attempt_timeout"><i class="fas fa-cogs"></i> Attempt Timeout</label>
|
||||
<input type="text" id="node-input-attempt_timeout" placeholder="10000" />
|
||||
</div>
|
||||
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
|
||||
Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first.
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-given_port_only"><i class="fa fa-lock"></i> Lock port</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-given_port_only"
|
||||
style="width: auto; vertical-align: top"
|
||||
/>
|
||||
<span>
|
||||
Only attempt to query server on given port (default: false).
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-debug"><i class="fa fa-bug"></i> Debug mode</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-debug"
|
||||
style="width: auto; vertical-align: top"
|
||||
/>
|
||||
<span>
|
||||
Enables massive amounts of debug logging to stdout.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-request_rules" style="vertical-align: top"><i class="fa fa-server"></i> Request rules</label>
|
||||
<div style="width: 50%;display: inline-block;">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="node-input-request_rules"
|
||||
style="width: auto; vertical-align: top"
|
||||
/>
|
||||
For many valve games, additional 'rules' may be fetched into the unstable raw field by setting this to true. Beware that this may increase query time and this is for Valve games only.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-ip_family"><i class="fa fa-server"></i> IP Rules</label>
|
||||
<select
|
||||
id="node-input-ip_family"
|
||||
style="width: auto; vertical-align: top">
|
||||
<option value="0">IPv4 and IPv6</option>
|
||||
<option value="4">IPv4</option>
|
||||
<option value="6">IPv6</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
|
||||
IP family/version returned when looking up hostnames via DNS, can be IPv4 and IPv6, IPv4 only or IPv6 only.
|
||||
</div>
|
||||
|
||||
<h3 id="gamdig-types">Server Types</h3>
|
||||
<p>
|
||||
Search available types below.<br>
|
||||
@@ -209,7 +155,7 @@
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="query-game-server">
|
||||
<p>Query most Game/Voice server's using the <a href="https://github.com/gamedig/node-gamedig" target="_blank">GameDig</a> library. I recommend visiting the <a href="https://github.com/gamedig/node-gamedig" target="_blank">node-gamedig GitHub page</a> for more documentation.</p>
|
||||
<p>Query most Game/Voice server's using the <a href="https://github.com/gamedig/node-gamedig" target="_blank">GameDig</a> library.</p>
|
||||
|
||||
<h3>Inputs</h3>
|
||||
<dl class="message-properties">
|
||||
@@ -242,26 +188,6 @@
|
||||
msg.attempt_timeout <span class="property-type">integer | null</span>
|
||||
</dt>
|
||||
<dd>Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first. Ignored if configured on the node.</dd>
|
||||
|
||||
<dt class="optional">
|
||||
msg.given_port_only <span class="property-type">boolean</span>
|
||||
</dt>
|
||||
<dd>Only attempt to query server on given port. Ignored if configured on the node.</dd>
|
||||
|
||||
<dt class="optional">
|
||||
msg.ip_family <span class="property-type">number</span>
|
||||
</dt>
|
||||
<dd>IP family/version returned when looking up hostnames via DNS, can be 0 (IPv4 and IPv6), 4 (IPv4 only) or 6 (IPv6 only). (default 0).</dd>
|
||||
|
||||
<dt class="optional">
|
||||
msg.debug <span class="property-type">boolean</span>
|
||||
</dt>
|
||||
<dd>Enables massive amounts of debug logging to stdout. (default false)</dd>
|
||||
|
||||
<dt class="optional">
|
||||
msg.request_rules <span class="property-type">boolean</span>
|
||||
</dt>
|
||||
<dd>For many valve games, additional 'rules' may be fetched into the unstable raw field by setting this to true. Beware that this may increase query time and this is for Valve games only.</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Outputs</h3>
|
||||
|
||||
+1
-25
@@ -12,10 +12,6 @@ module.exports = function(RED) {
|
||||
this.max_attempts = config.max_attempts || 1;
|
||||
this.socket_timeout = config.socket_timeout || 2000;
|
||||
this.attempt_timeout = config.attempt_timeout || 10000;
|
||||
this.given_port_only = config.given_port_only || false;
|
||||
this.ip_family = config.ip_family || 0;
|
||||
this.debug = config.debug || false;
|
||||
this.request_rules = config.request_rules || false;
|
||||
node.on('input', function(msg) {
|
||||
if(node.server_type) {
|
||||
msg.server_type = node.server_type;
|
||||
@@ -49,33 +45,13 @@ module.exports = function(RED) {
|
||||
msg.attempt_timeout = node.attempt_timeout;
|
||||
}
|
||||
|
||||
if(node.given_port_only) {
|
||||
msg.given_port_only = node.given_port_only;
|
||||
}
|
||||
|
||||
if(node.ip_family) {
|
||||
msg.ip_family = node.ip_family;
|
||||
}
|
||||
|
||||
if(node.debug) {
|
||||
msg.debug = node.debug;
|
||||
}
|
||||
|
||||
if(node.request_rules) {
|
||||
msg.request_rules = node.request_rules;
|
||||
}
|
||||
|
||||
gamedig.query({
|
||||
'type': msg.server_type,
|
||||
'host': msg.host,
|
||||
'port': msg.port,
|
||||
'maxAttempts': msg.max_attempts,
|
||||
'socketTimeout': msg.socket_timeout,
|
||||
'attemptTimeout': msg.attempt_timeout,
|
||||
'givenPortOnly': msg.given_port_only,
|
||||
'ipFamily': msg.ip_family,
|
||||
'debug': msg.debug,
|
||||
'requestRules': msg.request_rules
|
||||
'attemptTimeout': msg.attempt_timeout
|
||||
})
|
||||
.then(function(state) {
|
||||
msg.payload = 'online';
|
||||
|
||||
Reference in New Issue
Block a user