gameoverseer 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +30 -30
- data/README.md +51 -51
- data/gameoverseer.gemspec +23 -23
- data/lib/gameoverseer/channels/channel_manager.rb +49 -49
- data/lib/gameoverseer/clients/client_manager.rb +66 -66
- data/lib/gameoverseer/console/console.rb +206 -206
- data/lib/gameoverseer/encryption_handler/encryption_handler.rb +40 -40
- data/lib/gameoverseer/input_handler/input_handler.rb +36 -36
- data/lib/gameoverseer/messages/message_manager.rb +42 -42
- data/lib/gameoverseer/packet_handler/packet_handler.rb +35 -35
- data/lib/gameoverseer/server/renet_server.rb +126 -126
- data/lib/gameoverseer/services/service.rb +111 -111
- data/lib/gameoverseer/services/services.rb +38 -38
- data/lib/gameoverseer/version.rb +4 -4
- data/lib/gameoverseer.rb +59 -59
- data/license.md +9 -9
- data/test/test_helper.rb +1 -1
- data/test-clients/test-client-gamma.rb +62 -62
- metadata +17 -6
data/lib/gameoverseer.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
require "set"
|
2
|
-
require "openssl"
|
3
|
-
|
4
|
-
require "gosu"
|
5
|
-
require "concurrent"
|
6
|
-
require "renet"
|
7
|
-
require "multi_json"
|
8
|
-
|
9
|
-
require_relative "gameoverseer/version"
|
10
|
-
|
11
|
-
require_relative "gameoverseer/console/console"
|
12
|
-
|
13
|
-
require_relative "gameoverseer/channels/channel_manager"
|
14
|
-
|
15
|
-
require_relative "gameoverseer/messages/message_manager"
|
16
|
-
|
17
|
-
require_relative "gameoverseer/clients/client_manager"
|
18
|
-
|
19
|
-
require_relative "gameoverseer/services/service"
|
20
|
-
require_relative "gameoverseer/services/services"
|
21
|
-
|
22
|
-
require_relative "gameoverseer/input_handler/input_handler"
|
23
|
-
|
24
|
-
require_relative "gameoverseer/packet_handler/packet_handler"
|
25
|
-
require_relative "gameoverseer/encryption_handler/encryption_handler"
|
26
|
-
|
27
|
-
require_relative "gameoverseer/server/renet_server"
|
28
|
-
|
29
|
-
|
30
|
-
Thread.abort_on_exception = true
|
31
|
-
# General purpose game server that uses services (plugins) for logic.
|
32
|
-
module GameOverseer
|
33
|
-
|
34
|
-
# Start server
|
35
|
-
def self.activate(host, port, packet_handler = PacketHandler, encryption_handler = nil)
|
36
|
-
GameOverseer::ChannelManager.new
|
37
|
-
GameOverseer::MessageManager.new
|
38
|
-
GameOverseer::ClientManager.new
|
39
|
-
|
40
|
-
@console = GameOverseer::Console.new
|
41
|
-
@server = GameOverseer::ENetServerRunner.new
|
42
|
-
|
43
|
-
Thread.new {@server.start(host, port, packet_handler, encryption_handler)}
|
44
|
-
@console.show
|
45
|
-
sleep
|
46
|
-
|
47
|
-
at_exit do
|
48
|
-
GameOverseer::Console.instance.close
|
49
|
-
@server.supervisor.terminate if defined?(@server.supervisor.terminate)
|
50
|
-
puts "Server Shutdown"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Stop server
|
55
|
-
def self.deactivate
|
56
|
-
puts "ALERT \"CONSOLE CLOSED. LOST CONTROL OF SERVER.\""
|
57
|
-
@server.supervisor.terminate
|
58
|
-
end
|
59
|
-
end
|
1
|
+
require "set"
|
2
|
+
require "openssl"
|
3
|
+
|
4
|
+
require "gosu"
|
5
|
+
require "concurrent"
|
6
|
+
require "renet"
|
7
|
+
require "multi_json"
|
8
|
+
|
9
|
+
require_relative "gameoverseer/version"
|
10
|
+
|
11
|
+
require_relative "gameoverseer/console/console"
|
12
|
+
|
13
|
+
require_relative "gameoverseer/channels/channel_manager"
|
14
|
+
|
15
|
+
require_relative "gameoverseer/messages/message_manager"
|
16
|
+
|
17
|
+
require_relative "gameoverseer/clients/client_manager"
|
18
|
+
|
19
|
+
require_relative "gameoverseer/services/service"
|
20
|
+
require_relative "gameoverseer/services/services"
|
21
|
+
|
22
|
+
require_relative "gameoverseer/input_handler/input_handler"
|
23
|
+
|
24
|
+
require_relative "gameoverseer/packet_handler/packet_handler"
|
25
|
+
require_relative "gameoverseer/encryption_handler/encryption_handler"
|
26
|
+
|
27
|
+
require_relative "gameoverseer/server/renet_server"
|
28
|
+
|
29
|
+
|
30
|
+
Thread.abort_on_exception = true
|
31
|
+
# General purpose game server that uses services (plugins) for logic.
|
32
|
+
module GameOverseer
|
33
|
+
|
34
|
+
# Start server
|
35
|
+
def self.activate(host, port, use_inbuilt_console = false, packet_handler = PacketHandler, encryption_handler = nil)
|
36
|
+
GameOverseer::ChannelManager.new
|
37
|
+
GameOverseer::MessageManager.new
|
38
|
+
GameOverseer::ClientManager.new
|
39
|
+
|
40
|
+
@console = GameOverseer::Console.new if use_inbuilt_console
|
41
|
+
@server = GameOverseer::ENetServerRunner.new
|
42
|
+
|
43
|
+
Thread.new {@server.start(host, port, packet_handler, encryption_handler)}
|
44
|
+
@console.show if use_inbuilt_console
|
45
|
+
sleep
|
46
|
+
|
47
|
+
at_exit do
|
48
|
+
GameOverseer::Console.instance.close if use_inbuilt_console
|
49
|
+
@server.supervisor.terminate if defined?(@server.supervisor.terminate)
|
50
|
+
puts "Server Shutdown"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Stop server
|
55
|
+
def self.deactivate
|
56
|
+
puts "ALERT \"CONSOLE CLOSED. LOST CONTROL OF SERVER.\""
|
57
|
+
@server.supervisor.terminate
|
58
|
+
end
|
59
|
+
end
|
data/license.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2014 cyberarm
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
-
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
-
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2014 cyberarm
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/test/test_helper.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require "minitest"
|
1
|
+
require "minitest"
|
@@ -1,62 +1,62 @@
|
|
1
|
-
require "multi_json"
|
2
|
-
require 'uri'
|
3
|
-
require "renet"
|
4
|
-
require_relative "protocol-lib"
|
5
|
-
|
6
|
-
class TestClientGamma
|
7
|
-
HANDSHAKE = 2
|
8
|
-
# include Celluloid
|
9
|
-
|
10
|
-
def initialize(host, port)
|
11
|
-
@client = ENet::Connection.new(host, port, 4, 0, 0)
|
12
|
-
|
13
|
-
@client.on_connection(method(:on_connect))
|
14
|
-
@client.on_packet_receive(method(:on_packet))
|
15
|
-
@client.on_disconnection(method(:on_disconnect))
|
16
|
-
|
17
|
-
@client.connect(2000)
|
18
|
-
@client.send_packet("#{PROTOCOLS[:handshake_extend_hand]}", true, HANDSHAKE)
|
19
|
-
|
20
|
-
puts "Running...."
|
21
|
-
run
|
22
|
-
end
|
23
|
-
|
24
|
-
def run
|
25
|
-
loop do
|
26
|
-
@client.update(0)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def on_packet(data, channel)
|
31
|
-
p "P: #{data}-#{channel}"
|
32
|
-
handle_connection(data, channel)
|
33
|
-
end
|
34
|
-
|
35
|
-
def on_connect(data = 0, channel = 0)
|
36
|
-
p "C: #{data}-#{channel}"
|
37
|
-
end
|
38
|
-
|
39
|
-
def on_disconnect(data = 0, channel = 0)
|
40
|
-
p "D: #{data}-#{channel}"
|
41
|
-
end
|
42
|
-
|
43
|
-
def handle_connection(data, channel)
|
44
|
-
response = MultiJson.load(data)
|
45
|
-
case response['channel']
|
46
|
-
when 'handshake'
|
47
|
-
public_key_pem = response['data']['public_key'] if response['mode'] == 'public_key'
|
48
|
-
public_key = OpenSSL::PKey::RSA.new public_key_pem
|
49
|
-
encrypted_auth_key_response = MultiJson.dump({'channel'=> 'handshake', 'mode' => 'authenticate', 'data' => {'auth_key' => "#{public_key.public_encrypt('HELLO_WORLD')}".force_encoding("utf-8")}})
|
50
|
-
@client.send_packet(encrypted_auth_key_response, true, HANDSHAKE)
|
51
|
-
puts "PAST"
|
52
|
-
else
|
53
|
-
puts "hmm"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
start_time = Time.now
|
59
|
-
|
60
|
-
TestClientGamma.new("localhost", 56789)
|
61
|
-
|
62
|
-
puts "Time to complete: #{Time.now-start_time}"
|
1
|
+
require "multi_json"
|
2
|
+
require 'uri'
|
3
|
+
require "renet"
|
4
|
+
require_relative "protocol-lib"
|
5
|
+
|
6
|
+
class TestClientGamma
|
7
|
+
HANDSHAKE = 2
|
8
|
+
# include Celluloid
|
9
|
+
|
10
|
+
def initialize(host, port)
|
11
|
+
@client = ENet::Connection.new(host, port, 4, 0, 0)
|
12
|
+
|
13
|
+
@client.on_connection(method(:on_connect))
|
14
|
+
@client.on_packet_receive(method(:on_packet))
|
15
|
+
@client.on_disconnection(method(:on_disconnect))
|
16
|
+
|
17
|
+
@client.connect(2000)
|
18
|
+
@client.send_packet("#{PROTOCOLS[:handshake_extend_hand]}", true, HANDSHAKE)
|
19
|
+
|
20
|
+
puts "Running...."
|
21
|
+
run
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
loop do
|
26
|
+
@client.update(0)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def on_packet(data, channel)
|
31
|
+
p "P: #{data}-#{channel}"
|
32
|
+
handle_connection(data, channel)
|
33
|
+
end
|
34
|
+
|
35
|
+
def on_connect(data = 0, channel = 0)
|
36
|
+
p "C: #{data}-#{channel}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def on_disconnect(data = 0, channel = 0)
|
40
|
+
p "D: #{data}-#{channel}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def handle_connection(data, channel)
|
44
|
+
response = MultiJson.load(data)
|
45
|
+
case response['channel']
|
46
|
+
when 'handshake'
|
47
|
+
public_key_pem = response['data']['public_key'] if response['mode'] == 'public_key'
|
48
|
+
public_key = OpenSSL::PKey::RSA.new public_key_pem
|
49
|
+
encrypted_auth_key_response = MultiJson.dump({'channel'=> 'handshake', 'mode' => 'authenticate', 'data' => {'auth_key' => "#{public_key.public_encrypt('HELLO_WORLD')}".force_encoding("utf-8")}})
|
50
|
+
@client.send_packet(encrypted_auth_key_response, true, HANDSHAKE)
|
51
|
+
puts "PAST"
|
52
|
+
else
|
53
|
+
puts "hmm"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
start_time = Time.now
|
59
|
+
|
60
|
+
TestClientGamma.new("localhost", 56789)
|
61
|
+
|
62
|
+
puts "Time to complete: #{Time.now-start_time}"
|
metadata
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gameoverseer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyberarm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.10'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 0.10.6
|
@@ -21,6 +24,9 @@ dependencies:
|
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.10'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 0.10.6
|
@@ -42,16 +48,22 @@ dependencies:
|
|
42
48
|
name: renet
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.2'
|
45
54
|
- - ">="
|
46
55
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
56
|
+
version: 0.2.2
|
48
57
|
type: :runtime
|
49
58
|
prerelease: false
|
50
59
|
version_requirements: !ruby/object:Gem::Requirement
|
51
60
|
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0.2'
|
52
64
|
- - ">="
|
53
65
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
66
|
+
version: 0.2.2
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
68
|
name: multi_json
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,9 +129,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
129
|
version: '0'
|
118
130
|
requirements: []
|
119
131
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.5.1
|
121
133
|
signing_key:
|
122
134
|
specification_version: 4
|
123
135
|
summary: Generic game server.
|
124
136
|
test_files: []
|
125
|
-
has_rdoc:
|