takumi-server_list_ping 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/bin/takumi-server_list_ping +4 -11
- data/lib/takumi/server_list_ping.rb +19 -0
- data/lib/takumi/server_list_ping/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19ae0f8d983d9ecc2fe163cd40f0349abcdf87b9
|
4
|
+
data.tar.gz: 48a6c148c62731f592a224a4600d323a569cb3be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5f99a0ef880a7a6fa40fe52d96a10d0eb8a9af3e55e4f6389c778facb5ee3ca850f6f80911396b8ab247669e74e83fd4a49924b8cb51994bbb962873f85b145
|
7
|
+
data.tar.gz: a0afb26ba787ddf6d3a57579571a7ca095a9e50a407601d9b0b11ff639be64fe63f07026b92233c86f7b31f15cac54a75681a4dad51cf5da49a315642e7f2887
|
data/README.md
CHANGED
@@ -22,9 +22,15 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
+
### Command
|
26
|
+
|
25
27
|
$ bundle exec takumi-server_list_ping YOUR_SERVER_IP_ADDRESS_OR_HOSTNAME
|
26
28
|
{"description":"A Minecraft Server","players":{"max":20,"online":0},"version":{"name":"1.8","protocol":47}}
|
27
29
|
|
30
|
+
### Get server list ping
|
31
|
+
|
32
|
+
Takumi::ServerListPing.ping(MINECRAFT_SERVER_ADDRESS, PORT)
|
33
|
+
|
28
34
|
## Contributing
|
29
35
|
|
30
36
|
1. Fork it ( https://github.com/blockgiven/takumi-server_list_ping/fork )
|
data/bin/takumi-server_list_ping
CHANGED
@@ -8,16 +8,9 @@ if ARGV[0]
|
|
8
8
|
server_address, port = ARGV[0].split(':')
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
server_address
|
13
|
-
|
14
|
-
|
15
|
-
status_request = Takumi::ServerListPing::StatusRequest.create
|
11
|
+
status_response = Takumi::ServerListPing.ping(
|
12
|
+
server_address || 'localhost',
|
13
|
+
(port && port.to_i) || ::Takumi::ServerListPing::PORT
|
14
|
+
)
|
16
15
|
|
17
|
-
socket = TCPSocket.open(handshake.server_address, handshake.port)
|
18
|
-
socket.write(handshake.to_s)
|
19
|
-
socket.write(status_request.to_s)
|
20
|
-
|
21
|
-
packets = socket.read
|
22
|
-
status_response = Takumi::ServerListPing::StatusResponse.decode(packets)
|
23
16
|
puts status_response.json
|
@@ -3,8 +3,27 @@ module Takumi
|
|
3
3
|
NEXT_STATUS = 1
|
4
4
|
PROTOCOL_VERSION = 4
|
5
5
|
PORT = 25565
|
6
|
+
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def ping(server_address = 'localhost', port = PORT)
|
10
|
+
handshake = Takumi::ServerListPing::Handshake.create({
|
11
|
+
server_address: server_address,
|
12
|
+
port: port
|
13
|
+
})
|
14
|
+
status_request = Takumi::ServerListPing::StatusRequest.create
|
15
|
+
|
16
|
+
socket = TCPSocket.open(handshake.server_address, handshake.port)
|
17
|
+
socket.write(handshake.to_s)
|
18
|
+
socket.write(status_request.to_s)
|
19
|
+
|
20
|
+
Takumi::ServerListPing::StatusResponse.decode(socket.read)
|
21
|
+
ensure
|
22
|
+
socket.close if socket
|
23
|
+
end
|
6
24
|
end
|
7
25
|
end
|
26
|
+
|
8
27
|
require "takumi/packet"
|
9
28
|
require "takumi/server_list_ping/version"
|
10
29
|
require "takumi/server_list_ping/base"
|