minestat 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/minestat.rb +43 -36
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e0acf4a379eb97f4145d734b8f7d3b82b9b5f57d
|
4
|
+
data.tar.gz: 8fe0222fc8892a44eea98917e87eaad75f0fd8d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 071fd966c47fd93d01087a4c85d20ca2ca56c05cec1d22c8aeff824602c900f085d7c877e37b0dfe25d3105f74dab2a52d2fa1f19b8706d3a31d16bbb96a7af8
|
7
|
+
data.tar.gz: 4846ca755878fd8d81bddd5634916e83955b142ea587cb81c3ba55a629f04129a2eacdc11f7fa68d9b6d77f5ab8ed141628d330a7e33a5e2fc82e46d61b625ab
|
data/lib/minestat.rb
CHANGED
@@ -24,7 +24,7 @@ require 'timeout'
|
|
24
24
|
# Provides a ruby interface for polling Minecraft server status.
|
25
25
|
class MineStat
|
26
26
|
# MineStat version
|
27
|
-
VERSION = "2.2.
|
27
|
+
VERSION = "2.2.1"
|
28
28
|
# Number of values expected from server
|
29
29
|
NUM_FIELDS = 6
|
30
30
|
# Number of values expected from a 1.8b/1.3 server
|
@@ -32,7 +32,7 @@ class MineStat
|
|
32
32
|
# Maximum number of bytes a varint can be
|
33
33
|
MAX_VARINT_SIZE = 5
|
34
34
|
# Default TCP port
|
35
|
-
|
35
|
+
DEFAULT_TCP_PORT = 25565
|
36
36
|
# Bedrock/Pocket Edition default UDP port
|
37
37
|
DEFAULT_BEDROCK_PORT = 19132
|
38
38
|
# Default TCP/UDP timeout in seconds
|
@@ -79,7 +79,7 @@ class MineStat
|
|
79
79
|
|
80
80
|
##
|
81
81
|
# Instantiate an instance of MineStat and poll the specified server for information
|
82
|
-
def initialize(address, port =
|
82
|
+
def initialize(address, port = DEFAULT_TCP_PORT, timeout = DEFAULT_TIMEOUT, request_type = Request::NONE)
|
83
83
|
@address = address # address of server
|
84
84
|
@port = port # TCP/UDP port of server
|
85
85
|
@online # online or offline?
|
@@ -95,6 +95,9 @@ class MineStat
|
|
95
95
|
@timeout = timeout # TCP/UDP timeout
|
96
96
|
@server # server socket
|
97
97
|
@request_type # Protocol version
|
98
|
+
@try_all = false # try all protocols?
|
99
|
+
|
100
|
+
@try_all = true if request_type == Request::NONE
|
98
101
|
|
99
102
|
case request_type
|
100
103
|
when Request::BETA
|
@@ -108,7 +111,7 @@ class MineStat
|
|
108
111
|
when Request::BEDROCK
|
109
112
|
retval = bedrock_request()
|
110
113
|
else
|
111
|
-
# Attempt various
|
114
|
+
# Attempt various ping requests in a particular order. If the
|
112
115
|
# connection fails, there is no reason to continue with subsequent
|
113
116
|
# requests. Attempts should continue in the event of a timeout
|
114
117
|
# however since it may be due to an issue during the handshake.
|
@@ -127,7 +130,7 @@ class MineStat
|
|
127
130
|
unless retval == Retval::CONNFAIL
|
128
131
|
retval = json_request()
|
129
132
|
end
|
130
|
-
# Bedrock
|
133
|
+
# Bedrock/Pocket Edition
|
131
134
|
unless retval == Retval::CONNFAIL
|
132
135
|
retval = bedrock_request()
|
133
136
|
end
|
@@ -159,7 +162,7 @@ class MineStat
|
|
159
162
|
def connect()
|
160
163
|
begin
|
161
164
|
if @request_type == Request::BEDROCK || @request_type == "Bedrock/Pocket Edition"
|
162
|
-
@port = DEFAULT_BEDROCK_PORT if @port ==
|
165
|
+
@port = DEFAULT_BEDROCK_PORT if @port == DEFAULT_TCP_PORT && @try_all
|
163
166
|
start_time = Time.now
|
164
167
|
@server = UDPSocket.new
|
165
168
|
@server.connect(@address, @port)
|
@@ -260,9 +263,9 @@ class MineStat
|
|
260
263
|
# 2b. data length
|
261
264
|
# 2c. 3 fields delimited by \u00A7 (section symbol)
|
262
265
|
# The 3 fields, in order, are:
|
263
|
-
#
|
264
|
-
#
|
265
|
-
#
|
266
|
+
# * message of the day
|
267
|
+
# * current players
|
268
|
+
# * max players
|
266
269
|
def beta_request()
|
267
270
|
retval = nil
|
268
271
|
begin
|
@@ -293,12 +296,12 @@ class MineStat
|
|
293
296
|
# 2b. data length
|
294
297
|
# 2c. 6 fields delimited by \x00 (null)
|
295
298
|
# The 6 fields, in order, are:
|
296
|
-
#
|
297
|
-
#
|
298
|
-
#
|
299
|
-
#
|
300
|
-
#
|
301
|
-
#
|
299
|
+
# * the section symbol and 1
|
300
|
+
# * protocol version
|
301
|
+
# * server version
|
302
|
+
# * message of the day
|
303
|
+
# * current players
|
304
|
+
# * max players
|
302
305
|
#
|
303
306
|
# The protocol version corresponds with the server version and can be the
|
304
307
|
# same for different server versions.
|
@@ -340,12 +343,12 @@ class MineStat
|
|
340
343
|
# 2b. data length
|
341
344
|
# 2c. 6 fields delimited by \x00 (null)
|
342
345
|
# The 6 fields, in order, are:
|
343
|
-
#
|
344
|
-
#
|
345
|
-
#
|
346
|
-
#
|
347
|
-
#
|
348
|
-
#
|
346
|
+
# * the section symbol and 1
|
347
|
+
# * protocol version
|
348
|
+
# * server version
|
349
|
+
# * message of the day
|
350
|
+
# * current players
|
351
|
+
# * max players
|
349
352
|
#
|
350
353
|
# The protocol version corresponds with the server version and can be the
|
351
354
|
# same for different server versions.
|
@@ -486,20 +489,21 @@ class MineStat
|
|
486
489
|
# 2b. current time as a long
|
487
490
|
# 2c. server GUID as a long
|
488
491
|
# 2d. 16-bit magic number
|
489
|
-
# 2e. server ID
|
492
|
+
# 2e. server ID string length
|
493
|
+
# 2f. server ID as a string
|
490
494
|
# The fields from the pong response, in order, are:
|
491
|
-
#
|
492
|
-
#
|
493
|
-
#
|
494
|
-
#
|
495
|
-
#
|
496
|
-
#
|
497
|
-
#
|
498
|
-
#
|
499
|
-
#
|
500
|
-
#
|
501
|
-
#
|
502
|
-
#
|
495
|
+
# * edition
|
496
|
+
# * MotD line 1
|
497
|
+
# * protocol version
|
498
|
+
# * version name
|
499
|
+
# * current player count
|
500
|
+
# * maximum player count
|
501
|
+
# * unique server ID
|
502
|
+
# * MotD line 2
|
503
|
+
# * game mode as a string
|
504
|
+
# * game mode as a numeric
|
505
|
+
# * IPv4 port number
|
506
|
+
# * IPv6 port number
|
503
507
|
def bedrock_request()
|
504
508
|
retval = nil
|
505
509
|
begin
|
@@ -554,7 +558,7 @@ class MineStat
|
|
554
558
|
# Returns the maximum player count
|
555
559
|
attr_reader :max_players
|
556
560
|
|
557
|
-
# Returns the
|
561
|
+
# Returns the protocol level
|
558
562
|
#
|
559
563
|
# This is arbitrary and varies by Minecraft version.
|
560
564
|
# However, multiple Minecraft versions can share the same
|
@@ -568,6 +572,9 @@ class MineStat
|
|
568
572
|
# Returns the ping time to the server in ms
|
569
573
|
attr_reader :latency
|
570
574
|
|
571
|
-
# Returns the
|
575
|
+
# Returns the protocol version
|
572
576
|
attr_reader :request_type
|
577
|
+
|
578
|
+
# Returns whether or not all ping protocols should be attempted
|
579
|
+
attr_reader :try_all
|
573
580
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minestat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lloyd Dilley
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: MineStat polls Minecraft server data such as version, motd, current players,
|
14
14
|
and max players.
|
@@ -23,7 +23,7 @@ homepage: https://github.com/FragLand/minestat
|
|
23
23
|
licenses:
|
24
24
|
- GPL-3.0
|
25
25
|
metadata: {}
|
26
|
-
post_install_message:
|
26
|
+
post_install_message:
|
27
27
|
rdoc_options: []
|
28
28
|
require_paths:
|
29
29
|
- lib
|
@@ -38,8 +38,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
|
-
|
42
|
-
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.5.2.1
|
43
|
+
signing_key:
|
43
44
|
specification_version: 4
|
44
45
|
summary: Minecraft server status checker
|
45
46
|
test_files: []
|