-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
query-game-server.html
362 lines (317 loc) · 16.5 KB
/
query-game-server.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<script type="text/javascript">
RED.nodes.registerType('query-game-server', {
category: 'advanced',
color: '#a6bbcf',
defaults: {
name: { value: '' },
server_type: { value: '' },
host: { value: '' },
address: { value: '' },
port: { value: '' },
halt_if: { value: '' },
max_attempts: { value: '' },
socket_timeout: { value: '' },
attempt_timeout: { value: '' },
given_port_only: { value: '' },
ip_family: { value: '0' },
debug: { value: '' },
strip_colors: { type: "checkbox", value: true },
request_rules: { value: '' },
output_options: { value: '' }
},
inputs:1,
outputs:1,
icon: "icons/server.png",
paletteLabel: "Query Game Server",
label: function() {
if(this.name){
return this.name;
}
if(this.host || this.address) {
return (this.server_type ? this.server_type : 'Query') + ': ' + (this.host || this.address) + (this.port ? ":" + this.port : '');
}
return 'Query Game Server';
},
oneditprepare: function() {
let server_types = null;
console.log("THIS:", this);
if(typeof this.strip_colors === "undefined") {
this.strip_colors = true;
$("#node-input-strip_colors").prop('checked', true);
}
$.getJSON('/gamedig/types', function(data) {
if(data.result !== 'ok' || !data.hasOwnProperty("server_types"))
{
console.error("server_types failed to load");
return;
}
server_types = data.server_types;
});
$("#node-input-server_type").autoComplete({
search: function(val) {
if(!server_types) return false; // ignore until we have the types loaded
let matches = [];
server_types.forEach(v => {
if (
v.name.toLowerCase().indexOf(val.toLowerCase()) > -1 ||
v.type.toLowerCase().indexOf(val.toLowerCase()) > -1 ||
v.options.protocol.toLowerCase().indexOf(val.toLowerCase()) > -1
) {
matches.push({
value: v.type,
label: `${v.name} (${v.type})`,
protocol: v.protocol
});
}
});
return matches;
}
}).on('change', function () {
if(!server_types) return;
let val = $(this).val();
server_types.forEach(server_type => {
if(server_type['type'] !== val) return;
let query_port = server_type.options.port_query || server_type.options.port || null;
if(query_port && server_type.options.port_query_offset) {
query_port += server_type.options.port_query_offset;
}
$("#node-input-port").val(query_port);
});
});
}
});
</script>
<script type="text/html" data-template-name="query-game-server">
<style>
#query-game-server-types table, #query-game-server-types th, #query-game-server-types td {
border: 1px solid black;
border-collapse: collapse;
}
#query-game-server-types td {
padding: 3px;
}
</style>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-server_type"><i class="fa fa-cube"></i> Server Type</label>
<input type="text" id="node-input-server_type" placeholder="msg.server_type">
</div>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Recommend visiting the <a href="https://github.com/gamedig/node-gamedig#games-list" target="_blank" style="color:#0000EE;text-decoration: underline;">GameDig GitHub page</a> for more information about the server type you are trying to query. Some types require extra setup.
</div>
<div class="form-row">
<label for="node-input-host"><i class="fa fa-server"></i> Host</label>
<input type="text" id="node-input-host" placeholder="msg.host" />
</div>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Host without port. Uses <code>msg.host</code> if left blank.
</div>
<div class="form-row">
<label for="node-input-address"><i class="fa fa-server"></i> Address</label>
<input type="text" id="node-input-address" placeholder="msg.address" />
</div>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Override the IP address of the server skipping DNS resolution. When set, host will not be resolved, instead address will be connected to. However, some protocols still use host for other reasons e.g. as part of the query. Uses <code>msg.address</code> if left blank.
</div>
<div class="form-row">
<label for="node-input-port"><i class="fa fa-server"></i> Port</label>
<input type="text" id="node-input-port" placeholder="msg.port" />
</div>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Query port for the server (join and query port may differ).
If this is left blank it will use the default port for the server type specified.
Uses <code>msg.port</code> if left blank.
</div>
<div class="form-row">
<label for="node-input-halt_if"><i class="fa fa-hand-paper-o"></i> Halt If</label>
<select type="text" id="node-input-halt_if">
<option value="">Do not halt</option>
<option value="online">Online</option>
<option value="offline">Offline</option>
</select>
</div>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Filter messages based on server status
</div>
<div class="form-row">
<label for="node-input-max_attempts"><i class="fa fa-cogs"></i> Max Attempts</label>
<input type="text" id="node-input-max_attempts" placeholder="msg.max_attempts (default: 1)" />
</div>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Number of attempts to query server in case of failure.
</div>
<div class="form-row">
<label for="node-input-socket_timeout"><i class="fa fa-cogs"></i> Socket Timeout</label>
<input type="text" id="node-input-socket_timeout" placeholder="msg.socket_timeout (default: 2000)" />
</div>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online.
</div>
<div class="form-row">
<label for="node-input-attempt_timeout"><i class="fa fa-cogs"></i> Attempt Timeout</label>
<input type="text" id="node-input-attempt_timeout" placeholder="msg.attempt_timeout (default: 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-strip_colors" style="vertical-align: top"><i class="fa fa-server"></i> Strip colors</label>
<div style="width: 50%;display: inline-block;">
<input
type="checkbox"
id="node-input-strip_colors"
style="width: auto; vertical-align: top"
/>
for protocols that strips colors: unreal2, savage2, quake3, nadeo, gamespy2, doom3, armagetron.
</div>
</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-output_options" style="vertical-align: top"><i class="fa fa-server"></i> Output options</label>
<div style="width: 50%;display: inline-block;">
<input
type="checkbox"
id="node-input-output_options"
style="width: auto; vertical-align: top"
/>
Outputs <code style="white-space: normal;">msg.options</code> as an object that contains all the options used to query the server using GameDig. Note: If you pass <code style="white-space: normal;">msg.options</code> as an input it will override all set options so make sure you unset it if chaining multiple server query nodes together unless that is what you want.
</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>
</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>
<h3>Inputs</h3>
<dl class="message-properties">
<dt class="optional">
msg.server_type <span class="property-type">string | null</span>
</dt>
<dd>Server type to query. View available types either at the bottom of the node editor or <a href="https://github.com/sonicsnes/node-gamedig#games-list" style="color:#0000EE;" target="_blank">click here</a>. Ignored if configured on the node.</dd>
<dt class="optional">
msg.host <span class="property-type">string | null</span>
</dt>
<dd>Server IP/Hostname. Ignored if configured on the node.</dd>
<dt class="optional">
msg.address <span class="property-type">string | null</span>
</dt>
<dd>Override the IP address of the server skipping DNS resolution. When set, host will not be resolved, instead address will be connected to. However, some protocols still use host for other reasons e.g. as part of the query.</dd>
<dt class="optional">
msg.port <span class="property-type">integer | null</span>
</dt>
<dd>Query port of the server. Ignored if configured on the node. Uses default query port for the server type if left empty.</dd>
<dt class="optional">
msg.options <span class="property-type">object | null</span>
</dt>
<dd>Set additional GameDig options. This overrides all other methods of setting options. Can be used for example to set <code style="white-space: normal;">msg.options.guildId</code> that is required for querying Discord servers.</dd>
<dt class="optional">
msg.max_attempts <span class="property-type">integer | null</span>
</dt>
<dd>Number of attempts to query server in case of failure. Ignored if configured on the node.</dd>
<dt class="optional">
msg.socket_timeout <span class="property-type">integer | null</span>
</dt>
<dd>Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online. Ignored if configured on the node.</dd>
<dt class="optional">
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>
<dl class="message-properties">
<dt>
msg.payload <span class="property-type">string</span>
</dt>
<dd>Returns either <code>online</code> or <code>offline</code>.</dd>
<dt>
msg.data <span class="property-type">object</span>
</dt>
<dd>Returns back the results we got from GameDig. Click <a href="https://github.com/sonicsnes/node-gamedig#return-value" target="_blank" style="color:#0000EE;">here</a> for more information on what this contains.</dd>
<dt>
msg.data.error <span class="property-type">string</span>
</dt>
<dd>Reason the server failed to query. Only returns if <code>msg.payload</code> is <code>offline</code>.</dd>
<dt>
msg.server_type <span class="property-type">string</span>
</dt>
<dd>Server type to query. View available types either at the bottom of the node editor or <a href="https://github.com/sonicsnes/node-gamedig#games-list" style="color:#0000EE;" target="_blank">click here</a>. Ignored if configured on the node.</dd>
<dt>
msg.host <span class="property-type">string</span>
</dt>
<dd>Server IP/Hostname.</dd>
<dt>
msg.address <span class="property-type">string</span>
</dt>
<dd>Server address used to query.</dd>
<dt>
msg.port <span class="property-type">integer</span>
</dt>
<dd>Query port of the server. Ignored if configured on the node.</dd>
<dt>
msg.options <span class="property-type">object | undefined</span>
</dt>
<dd>Only set if configured to do so. Will return all the options passed to GameDig to query the server.</dd>
</dl>
</script>