zrcon 0.0.3 → 0.0.4
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 +4 -4
- data/bin/zrcon +8 -5
- data/lib/zrcon.rb +4 -5
- data/lib/zrcon/packet.rb +10 -7
- data/lib/zrcon/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae5f25c0942ee1911228bd9c5d0f33d763c11166
|
4
|
+
data.tar.gz: '0806a6f16d2ad76695ce349ed2cb55a42d55d658'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac1986b4c5cf4b392b0734ffdaa762b1a95c1e841acb89290890220f9a9dc5258c08eb18ce66c294937a2b742893f48eb516693d93eb547499a8139af541a399
|
7
|
+
data.tar.gz: 2499bfe1b9cd39347c62eaaffdde8bbce2b9a698b62283a854b575d8e685937541435dad6fa45827ca4c22e144ce86ed087011c29e9e29c2ab337211cc4f977c
|
data/bin/zrcon
CHANGED
@@ -15,12 +15,16 @@ options = OpenStruct.new(
|
|
15
15
|
password: ENV['RCON_PASSWORD']
|
16
16
|
)
|
17
17
|
|
18
|
-
OptionParser.new
|
19
|
-
opts.banner = "Usage: zrcon..."
|
20
|
-
opts.on("-
|
18
|
+
OptionParser.new do |opts|
|
19
|
+
opts.banner = "Usage: zrcon ..."
|
20
|
+
opts.on("-HHOSTNAME", "--host=HOSTNAME", "hostname of rcon server") { |value| options.host = value }
|
21
21
|
opts.on("-pPORT", "--port=PORT", "tcp port") { |value| options.port = value.to_i }
|
22
22
|
opts.on("-PPASS", "--password=PASS", "rcon password") { |value| options.password = value }
|
23
|
-
|
23
|
+
opts.on("-h", "--help") do
|
24
|
+
puts opts.help()
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end.parse!
|
24
28
|
|
25
29
|
begin
|
26
30
|
rcon = Zrcon.new options.to_h
|
@@ -30,4 +34,3 @@ begin
|
|
30
34
|
rescue Zrcon::ConnectError => e
|
31
35
|
puts "Connect error: #{e}"
|
32
36
|
end
|
33
|
-
|
data/lib/zrcon.rb
CHANGED
@@ -32,20 +32,19 @@ class Zrcon
|
|
32
32
|
def conn
|
33
33
|
@conn ||= TCPSocket.new host, port
|
34
34
|
rescue SocketError
|
35
|
-
raise ConnectError
|
35
|
+
raise ConnectError, "bad hostname perhaps? (#{host})"
|
36
36
|
rescue Errno::ETIMEDOUT
|
37
|
-
raise ConnectError
|
37
|
+
raise ConnectError, "timed out connecting to #{host}:#{port}"
|
38
38
|
rescue Errno::ECONNREFUSED
|
39
|
-
raise ConnectError
|
39
|
+
raise ConnectError, "connection refused"
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
42
|
def next_id
|
44
43
|
@id ||= 0
|
45
44
|
@id += 1
|
46
45
|
end
|
47
46
|
|
48
|
-
def send
|
47
|
+
def send(packet)
|
49
48
|
conn.write packet.encode
|
50
49
|
end
|
51
50
|
|
data/lib/zrcon/packet.rb
CHANGED
@@ -9,23 +9,27 @@ class Zrcon
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def next_id
|
12
|
-
|
13
|
-
|
12
|
+
self.class.next_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.next_id
|
16
|
+
@id ||= -1
|
17
|
+
@id += 1
|
14
18
|
end
|
15
19
|
|
16
20
|
def encode
|
17
|
-
[10+data.length, id, type, data].pack("l<l<l<A#{data.length}xx")
|
21
|
+
[10 + data.length, id, type, data].pack("l<l<l<A#{data.length}xx")
|
18
22
|
end
|
19
23
|
|
20
|
-
def self.auth
|
24
|
+
def self.auth(password)
|
21
25
|
new type: 3, data: password
|
22
26
|
end
|
23
27
|
|
24
|
-
def self.command
|
28
|
+
def self.command(cmd)
|
25
29
|
new type: 2, data: cmd
|
26
30
|
end
|
27
31
|
|
28
|
-
def self.decode
|
32
|
+
def self.decode(raw)
|
29
33
|
raw = raw.to_s
|
30
34
|
fields = raw.unpack("l<l<Z*x")
|
31
35
|
|
@@ -33,4 +37,3 @@ class Zrcon
|
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|
36
|
-
|
data/lib/zrcon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zrcon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Libby
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.3'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +67,19 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '3.7'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: rubocop
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '0.52'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '0.52'
|
69
83
|
description: A lightweight rcon client to talk to minecraft remote console service
|
70
84
|
email: alibby@andylibby.org
|
71
85
|
executables:
|