steam-condenser 0.10.1 → 0.11.0
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.
- data/VERSION.yml +2 -2
- data/lib/datagram_channel.rb +30 -33
- data/lib/exceptions/packet_format_exception.rb +7 -3
- data/lib/exceptions/rcon_ban_exception.rb +7 -5
- data/lib/exceptions/rcon_no_auth_exception.rb +8 -6
- data/lib/exceptions/timeout_exception.rb +10 -4
- data/lib/socket_channel.rb +11 -17
- data/lib/steam/community/cacheable.rb +5 -7
- data/lib/steam/community/css/css_map.rb +31 -0
- data/lib/steam/community/css/css_stats.rb +116 -0
- data/lib/steam/community/css/css_weapon.rb +33 -0
- data/lib/steam/community/dods/dods_stats.rb +3 -3
- data/lib/steam/community/game_stats.rb +14 -13
- data/lib/steam/community/game_weapon.rb +3 -5
- data/lib/steam/community/l4d/abstract_l4d_stats.rb +4 -2
- data/lib/steam/community/l4d/l4d_explosive.rb +2 -2
- data/lib/steam/community/l4d/l4d_map.rb +3 -3
- data/lib/steam/community/steam_group.rb +2 -4
- data/lib/steam/community/steam_id.rb +2 -2
- data/lib/steam/community/tf2/tf2_class.rb +17 -17
- data/lib/steam/community/tf2/tf2_class_factory.rb +17 -17
- data/lib/steam/community/tf2/tf2_engineer.rb +9 -9
- data/lib/steam/community/tf2/tf2_medic.rb +9 -9
- data/lib/steam/community/tf2/tf2_sniper.rb +7 -7
- data/lib/steam/community/tf2/tf2_spy.rb +9 -9
- data/lib/steam/community/tf2/tf2_stats.rb +9 -9
- data/lib/steam/packets/a2a_ack_packet.rb +11 -9
- data/lib/steam/packets/a2a_ping_packet.rb +5 -4
- data/lib/steam/packets/a2m_get_servers_batch2_packet.rb +13 -12
- data/lib/steam/packets/a2s_info_packet.rb +8 -7
- data/lib/steam/packets/a2s_player_packet.rb +6 -6
- data/lib/steam/packets/a2s_rules_packet.rb +5 -5
- data/lib/steam/packets/a2s_serverquery_getchallenge_packet.rb +4 -3
- data/lib/steam/packets/m2a_server_batch_packet.rb +20 -22
- data/lib/steam/packets/rcon/rcon_auth_request.rb +5 -5
- data/lib/steam/packets/rcon/rcon_auth_response.rb +6 -6
- data/lib/steam/packets/rcon/rcon_exec_request.rb +5 -5
- data/lib/steam/packets/rcon/rcon_exec_response.rb +2 -2
- data/lib/steam/packets/rcon/rcon_goldsrc_request.rb +7 -7
- data/lib/steam/packets/rcon/rcon_goldsrc_response.rb +8 -8
- data/lib/steam/packets/rcon/rcon_packet.rb +12 -16
- data/lib/steam/packets/rcon/rcon_packet_factory.rb +19 -19
- data/lib/steam/packets/request_with_challenge.rb +5 -5
- data/lib/steam/packets/s2a_info2_packet.rb +28 -30
- data/lib/steam/packets/s2a_info_base_packet.rb +11 -16
- data/lib/steam/packets/s2a_info_detailed_packet.rb +30 -28
- data/lib/steam/packets/s2a_player_packet.rb +7 -9
- data/lib/steam/packets/s2a_rules_packet.rb +8 -12
- data/lib/steam/packets/s2c_challenge_packet.rb +7 -6
- data/lib/steam/packets/steam_packet.rb +7 -6
- data/lib/steam/packets/steam_packet_factory.rb +37 -38
- data/lib/steam/servers/game_server.rb +76 -86
- data/lib/steam/servers/goldsrc_server.rb +5 -5
- data/lib/steam/servers/master_server.rb +24 -24
- data/lib/steam/servers/source_server.rb +17 -19
- data/lib/steam/sockets/goldsrc_socket.rb +43 -46
- data/lib/steam/sockets/master_server_socket.rb +11 -13
- data/lib/steam/sockets/rcon_socket.rb +15 -17
- data/lib/steam/sockets/source_socket.rb +21 -21
- data/lib/steam/sockets/steam_socket.rb +25 -28
- data/lib/steam/steam_player.rb +3 -1
- data/lib/stringio_additions.rb +48 -0
- data/test/datagram_channel_tests.rb +8 -8
- data/test/query_tests.rb +15 -14
- data/test/rcon_tests.rb +32 -31
- data/test/socket_channel_tests.rb +7 -7
- data/test/steam/communtiy/steam_community_test_suite.rb +5 -2
- data/test/steam_community_tests.rb +4 -3
- data/test/stringio_additions_tests.rb +77 -0
- metadata +15 -8
- data/lib/byte_buffer.rb +0 -126
- data/lib/exceptions/buffer_underflow_exception.rb +0 -8
- data/test/byte_buffer_tests.rb +0 -76
@@ -1,14 +1,14 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2010, Sebastian Staudt
|
5
5
|
|
6
6
|
# This module implements a to_s method for request packets which send a challenge number
|
7
7
|
module RequestWithChallenge
|
8
|
-
|
8
|
+
|
9
9
|
# Returns a packed version of the request
|
10
10
|
def to_s
|
11
|
-
|
11
|
+
[0xFF, 0xFF, 0xFF, 0xFF, @header_data, @content_data.data.to_i].pack('c5l')
|
12
12
|
end
|
13
|
-
|
14
|
-
end
|
13
|
+
|
14
|
+
end
|
@@ -1,50 +1,48 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2010, Sebastian Staudt
|
5
5
|
|
6
|
-
require
|
6
|
+
require 'steam/packets/s2a_info_base_packet'
|
7
7
|
|
8
8
|
# The S2A_INFO2_Packet class represents the response to a A2A_INFO
|
9
9
|
# request send to a Source server.
|
10
10
|
class S2A_INFO2_Packet < S2A_INFO_BasePacket
|
11
|
-
|
11
|
+
|
12
12
|
# Creates a S2A_INFO2 response object based on the data received.
|
13
13
|
def initialize(data)
|
14
14
|
super SteamPacket::S2A_INFO2_HEADER, data
|
15
|
-
|
16
|
-
@protocol_version = @content_data.
|
17
|
-
@server_name = @content_data.
|
18
|
-
@map_name = @content_data.
|
19
|
-
@game_directory = @content_data.
|
20
|
-
@game_description = @content_data.
|
21
|
-
@app_id = @content_data.
|
22
|
-
@number_of_players = @content_data.
|
23
|
-
@max_players = @content_data.
|
24
|
-
@number_of_bots = @content_data.
|
25
|
-
@dedicated = @content_data.
|
26
|
-
@operating_system = @content_data.
|
27
|
-
@password_needed = @content_data.
|
28
|
-
@secure = @content_data.
|
29
|
-
@game_version = @content_data.
|
30
|
-
extra_data_flag = @content_data.
|
31
|
-
|
32
|
-
unless extra_data_flag & 0x80 == 0
|
33
|
-
@server_port = @content_data.get_short
|
34
|
-
end
|
15
|
+
|
16
|
+
@protocol_version = @content_data.byte
|
17
|
+
@server_name = @content_data.string
|
18
|
+
@map_name = @content_data.string
|
19
|
+
@game_directory = @content_data.string
|
20
|
+
@game_description = @content_data.string
|
21
|
+
@app_id = @content_data.short
|
22
|
+
@number_of_players = @content_data.byte
|
23
|
+
@max_players = @content_data.byte
|
24
|
+
@number_of_bots = @content_data.byte
|
25
|
+
@dedicated = @content_data.byte.chr
|
26
|
+
@operating_system = @content_data.byte.chr
|
27
|
+
@password_needed = @content_data.byte == 1
|
28
|
+
@secure = @content_data.byte == 1
|
29
|
+
@game_version = @content_data.string
|
30
|
+
extra_data_flag = @content_data.byte
|
31
|
+
|
32
|
+
@server_port = @content_data.short unless extra_data_flag & 0x80 == 0
|
35
33
|
|
36
34
|
unless extra_data_flag & 0x10 == 0
|
37
|
-
@server_id = @content_data.
|
35
|
+
@server_id = @content_data.long | (@content_data.long << 32)
|
38
36
|
end
|
39
37
|
|
40
38
|
unless extra_data_flag & 0x40 == 0
|
41
|
-
@tv_port = @content_data.
|
42
|
-
@tv_name = @content_data.
|
39
|
+
@tv_port = @content_data.short
|
40
|
+
@tv_name = @content_data.string
|
43
41
|
end
|
44
42
|
|
45
|
-
unless extra_data_flag & 0x20 == 0
|
46
|
-
|
47
|
-
|
43
|
+
@server_tags = @content_data.string unless extra_data_flag & 0x20 == 0
|
44
|
+
|
45
|
+
generate_info_hash
|
48
46
|
end
|
49
|
-
|
47
|
+
|
50
48
|
end
|
@@ -1,31 +1,26 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2010, Sebastian Staudt
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require 'abstract_class'
|
7
|
+
require 'steam/packets/steam_packet'
|
8
8
|
|
9
9
|
# The S2A_INFO_BasePacket class represents the response to a A2S_INFO
|
10
10
|
# request send to the server.
|
11
11
|
class S2A_INFO_BasePacket < SteamPacket
|
12
|
-
|
12
|
+
|
13
13
|
include AbstractClass
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
super header, data
|
18
|
-
end
|
19
|
-
|
14
|
+
|
15
|
+
attr_reader :info_hash
|
16
|
+
|
20
17
|
# Returns the hash containing information on the server
|
21
|
-
|
22
|
-
|
23
|
-
return Hash[
|
18
|
+
def generate_info_hash
|
19
|
+
@info_hash = Hash[
|
24
20
|
*instance_variables.map { |var|
|
25
|
-
if var !=
|
26
|
-
[var[1..-1], instance_variable_get(var)]
|
27
|
-
end
|
21
|
+
[var[1..-1], instance_variable_get(var)] if var != '@content_data' && var != '@header_data'
|
28
22
|
}.compact.flatten
|
29
23
|
]
|
30
24
|
end
|
25
|
+
|
31
26
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2010, Sebastian Staudt
|
5
5
|
|
6
6
|
require "steam/packets/s2a_info_base_packet"
|
7
7
|
|
@@ -10,41 +10,43 @@ require "steam/packets/s2a_info_base_packet"
|
|
10
10
|
# This is deprecated by 10/24/2008 for GoldSrc servers. They use the same
|
11
11
|
# format as Source servers (S2A_INFO2) now.
|
12
12
|
class S2A_INFO_DETAILED_Packet < S2A_INFO_BasePacket
|
13
|
-
|
13
|
+
|
14
14
|
# Creates a S2A_INFO_DETAILED response object based on the data received.
|
15
15
|
def initialize(data)
|
16
16
|
super SteamPacket::S2A_INFO_DETAILED_HEADER, data
|
17
17
|
|
18
|
-
@game_ip = @content_data.
|
19
|
-
@server_name = @content_data.
|
20
|
-
@map_name = @content_data.
|
21
|
-
@game_directory = @content_data.
|
22
|
-
@game_description = @content_data.
|
23
|
-
@number_of_players = @content_data.
|
24
|
-
@max_players = @content_data.
|
25
|
-
@network_version = @content_data.
|
26
|
-
@dedicated = @content_data.
|
27
|
-
@operating_system = @content_data.
|
28
|
-
@password_needed = @content_data.
|
29
|
-
@is_mod = @content_data.
|
30
|
-
|
18
|
+
@game_ip = @content_data.string
|
19
|
+
@server_name = @content_data.string
|
20
|
+
@map_name = @content_data.string
|
21
|
+
@game_directory = @content_data.string
|
22
|
+
@game_description = @content_data.string
|
23
|
+
@number_of_players = @content_data.byte
|
24
|
+
@max_players = @content_data.byte
|
25
|
+
@network_version = @content_data.byte
|
26
|
+
@dedicated = @content_data.byte.chr
|
27
|
+
@operating_system = @content_data.byte.chr
|
28
|
+
@password_needed = @content_data.byte == 1
|
29
|
+
@is_mod = @content_data.byte == 1
|
30
|
+
|
31
31
|
if @is_mod
|
32
|
-
@mod_info =
|
33
|
-
@mod_info[
|
34
|
-
@mod_info[
|
35
|
-
@content_data.
|
32
|
+
@mod_info = {}
|
33
|
+
@mod_info['url_info'] = @content_data.string
|
34
|
+
@mod_info['url_dl'] = @content_data.string
|
35
|
+
@content_data.byte
|
36
36
|
if @content_data.remaining == 12
|
37
|
-
@mod_info[
|
38
|
-
@mod_info[
|
39
|
-
@mod_info[
|
40
|
-
@mod_info[
|
41
|
-
@secure = @content_data.
|
42
|
-
@number_of_bots = @content_data.
|
37
|
+
@mod_info['mod_version'] = @content_data.long
|
38
|
+
@mod_info['mod_size'] = @content_data.long
|
39
|
+
@mod_info['sv_only'] = @content_data.byte == 1
|
40
|
+
@mod_info['cl_dll'] = @content_data.byte == 1
|
41
|
+
@secure = @content_data.byte == 1
|
42
|
+
@number_of_bots = @content_data.byte
|
43
43
|
end
|
44
44
|
else
|
45
|
-
@secure = @content_data.
|
46
|
-
@number_of_bots = @content_data.
|
45
|
+
@secure = @content_data.byte == 1
|
46
|
+
@number_of_bots = @content_data.byte
|
47
47
|
end
|
48
|
+
|
49
|
+
generate_info_hash
|
48
50
|
end
|
49
|
-
|
51
|
+
|
50
52
|
end
|
@@ -1,30 +1,28 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2010, Sebastian Staudt
|
5
5
|
|
6
|
-
require
|
6
|
+
require 'steam/packets/steam_packet'
|
7
7
|
|
8
8
|
# The S2A_PLAYER_Packet class represents the response to a A2S_PLAYER
|
9
9
|
# request send to the server.
|
10
10
|
class S2A_PLAYER_Packet < SteamPacket
|
11
11
|
|
12
12
|
attr_reader :player_hash
|
13
|
-
|
13
|
+
|
14
14
|
# Creates a S2A_PLAYER response object based on the data received.
|
15
15
|
def initialize(content_data)
|
16
|
-
if content_data
|
17
|
-
|
18
|
-
end
|
19
|
-
|
16
|
+
raise Exception.new('Wrong formatted S2A_PLAYER packet.') if content_data.nil?
|
17
|
+
|
20
18
|
super SteamPacket::S2A_PLAYER_HEADER, content_data
|
21
19
|
|
22
20
|
# Ignore player count
|
23
|
-
@content_data.
|
21
|
+
@content_data.byte
|
24
22
|
@player_hash = {}
|
25
23
|
|
26
24
|
while @content_data.remaining > 0
|
27
|
-
player_data = @content_data.
|
25
|
+
player_data = @content_data.byte, @content_data.string, @content_data.signed_long, @content_data.float
|
28
26
|
@player_hash[player_data[1]] = SteamPlayer.new(*player_data[0..3])
|
29
27
|
end
|
30
28
|
end
|
@@ -1,29 +1,29 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2010, Sebastian Staudt
|
5
5
|
|
6
|
-
require
|
6
|
+
require 'steam/packets/steam_packet'
|
7
7
|
|
8
8
|
# The S2A_RULES_Packet class represents the response to a A2S_RULES
|
9
9
|
# request send to the server.
|
10
10
|
class S2A_RULES_Packet < SteamPacket
|
11
11
|
|
12
|
+
attr_reader :rules_hash
|
13
|
+
|
12
14
|
# Creates a S2A_RULES response object based on the data received.
|
13
15
|
def initialize(content_data)
|
14
|
-
if content_data
|
15
|
-
raise Exception.new("Wrong formatted A2A_RULES response packet.")
|
16
|
-
end
|
16
|
+
raise Exception.new('Wrong formatted A2A_RULES response packet.') if content_data.nil?
|
17
17
|
|
18
18
|
super SteamPacket::S2A_RULES_HEADER, content_data
|
19
19
|
|
20
|
-
rules_count = @content_data.
|
20
|
+
rules_count = @content_data.short
|
21
21
|
|
22
22
|
@rules_hash = {}
|
23
23
|
|
24
24
|
rules_count.times do
|
25
|
-
rule = @content_data.
|
26
|
-
value = @content_data.
|
25
|
+
rule = @content_data.string
|
26
|
+
value = @content_data.string
|
27
27
|
|
28
28
|
# This is a workaround for servers sending corrupt replies
|
29
29
|
break if rule.empty? or value.empty?
|
@@ -32,8 +32,4 @@ class S2A_RULES_Packet < SteamPacket
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
# Returns the hash containing the server rules
|
36
|
-
def get_rules_hash
|
37
|
-
return @rules_hash
|
38
|
-
end
|
39
35
|
end
|
@@ -1,21 +1,22 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2010, Sebastian Staudt
|
5
5
|
|
6
|
-
require
|
6
|
+
require 'steam/packets/steam_packet'
|
7
7
|
|
8
8
|
# The S2C_CHALLENGE_Packet class represents the response
|
9
9
|
# to a A2S_SERVERQUERY_GETCHALLENGE request send to the server.
|
10
10
|
class S2C_CHALLENGE_Packet < SteamPacket
|
11
|
-
|
11
|
+
|
12
12
|
# Creates a AS2C_CHALLENGE response object based on the data received.
|
13
13
|
def initialize(challenge_number)
|
14
14
|
super S2C_CHALLENGE_HEADER, challenge_number
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
# Returns the challenge number received from the server
|
18
|
-
def
|
19
|
-
|
18
|
+
def challenge_number
|
19
|
+
@content_data.rewind
|
20
|
+
@content_data.long
|
20
21
|
end
|
21
22
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# Copyright (c) 2008-2010, Sebastian Staudt
|
5
5
|
|
6
|
+
require 'stringio_additions'
|
7
|
+
|
6
8
|
# This class represents a packet used by the Source query protocol
|
7
9
|
class SteamPacket
|
8
10
|
|
@@ -25,15 +27,14 @@ class SteamPacket
|
|
25
27
|
S2C_CHALLENGE_HEADER = 0x41
|
26
28
|
|
27
29
|
# Creates a new SteamPacket object with given header and content data
|
28
|
-
def initialize(header_data, content_data =
|
29
|
-
@content_data =
|
30
|
-
@header_data
|
30
|
+
def initialize(header_data, content_data = '')
|
31
|
+
@content_data = StringIO.new content_data.to_s
|
32
|
+
@header_data = header_data
|
31
33
|
end
|
32
34
|
|
33
35
|
# Returns a packed string representing the packet's data
|
34
36
|
def to_s
|
35
|
-
|
36
|
-
|
37
|
-
return packet_data << [@header_data, @content_data.array].pack("ca*")
|
37
|
+
[0xFF, 0xFF, 0xFF, 0xFF, @header_data, @content_data.data].pack('c5a*')
|
38
38
|
end
|
39
|
+
|
39
40
|
end
|
@@ -1,40 +1,41 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2010, Sebastian Staudt
|
5
5
|
|
6
6
|
require 'zlib'
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
8
|
+
require 'abstract_class'
|
9
|
+
require 'exceptions/steam_condenser_exception'
|
10
|
+
require 'steam/packets/s2a_info_detailed_packet'
|
11
|
+
require 'steam/packets/a2s_info_packet'
|
12
|
+
require 'steam/packets/s2a_info2_packet'
|
13
|
+
require 'steam/packets/a2a_ping_packet'
|
14
|
+
require 'steam/packets/a2a_ack_packet'
|
15
|
+
require 'steam/packets/a2s_player_packet'
|
16
|
+
require 'steam/packets/s2a_player_packet'
|
17
|
+
require 'steam/packets/a2s_rules_packet'
|
18
|
+
require 'steam/packets/s2a_rules_packet'
|
19
|
+
require 'steam/packets/a2s_serverquery_getchallenge_packet'
|
20
|
+
require 'steam/packets/s2c_challenge_packet'
|
21
|
+
require 'steam/packets/a2m_get_servers_batch2_packet'
|
22
|
+
require 'steam/packets/m2a_server_batch_packet'
|
23
|
+
require 'steam/packets/rcon/rcon_goldsrc_response'
|
23
24
|
|
24
25
|
class SteamPacketFactory
|
25
|
-
|
26
|
+
|
26
27
|
include AbstractClass
|
27
|
-
|
28
|
+
|
28
29
|
# Creates a new packet object based on the header byte of the given raw data
|
29
|
-
def self.
|
30
|
-
header = raw_data[0].to_i
|
31
|
-
data = raw_data[1..-1]
|
32
|
-
|
30
|
+
def self.packet_from_data(raw_data)
|
31
|
+
header = raw_data[0].to_i
|
32
|
+
data = raw_data[1..-1]
|
33
|
+
|
33
34
|
case header
|
34
35
|
when SteamPacket::S2A_INFO_DETAILED_HEADER
|
35
36
|
return S2A_INFO_DETAILED_Packet.new(data)
|
36
37
|
when SteamPacket::A2S_INFO_HEADER
|
37
|
-
return A2S_INFO_Packet.new
|
38
|
+
return A2S_INFO_Packet.new
|
38
39
|
when SteamPacket::S2A_INFO2_HEADER
|
39
40
|
return S2A_INFO2_Packet.new(data)
|
40
41
|
when SteamPacket::A2A_PING_HEADER
|
@@ -54,7 +55,7 @@ class SteamPacketFactory
|
|
54
55
|
when SteamPacket::S2C_CHALLENGE_HEADER
|
55
56
|
return S2C_CHALLENGE_Packet.new(data)
|
56
57
|
when SteamPacket::A2M_GET_SERVERS_BATCH2_HEADER
|
57
|
-
return
|
58
|
+
return A2M_GET_SERVERS_BATCH2_Packet.new(data)
|
58
59
|
when SteamPacket::M2A_SERVER_BATCH_HEADER
|
59
60
|
return M2A_SERVER_BATCH_Packet.new(data)
|
60
61
|
when SteamPacket::RCON_GOLDSRC_CHALLENGE_HEADER,
|
@@ -62,29 +63,27 @@ class SteamPacketFactory
|
|
62
63
|
SteamPacket::RCON_GOLDSRC_RESPONSE_HEADER
|
63
64
|
return RCONGoldSrcResponse.new(data)
|
64
65
|
else
|
65
|
-
raise
|
66
|
+
raise SteamCondenserException.new("Unknown packet with header 0x#{header.to_s(16)} received.")
|
66
67
|
end
|
67
68
|
end
|
68
|
-
|
69
|
+
|
69
70
|
def self.reassemble_packet(split_packets, is_compressed = false, packet_checksum = 0)
|
70
|
-
packet_data = split_packets.join
|
71
|
-
|
71
|
+
packet_data = split_packets.join ''
|
72
|
+
|
72
73
|
if is_compressed
|
73
74
|
begin
|
74
75
|
require 'bz2'
|
75
76
|
packet_data = BZ2.uncompress(packet_data)
|
76
77
|
rescue LoadError
|
77
|
-
raise SteamCondenserException.new(
|
78
|
+
raise SteamCondenserException.new('You need to install the libbzip2 interface for Ruby.')
|
78
79
|
end
|
79
|
-
|
80
|
-
|
81
|
-
raise PacketFormatException.new(
|
80
|
+
|
81
|
+
unless Zlib.crc32(packet_data) == packet_checksum
|
82
|
+
raise PacketFormatException.new('CRC32 checksum mismatch of uncompressed packet data.')
|
82
83
|
end
|
83
84
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
return self.get_packet_from_data(packet_data)
|
85
|
+
|
86
|
+
packet_from_data packet_data[4..-1]
|
88
87
|
end
|
89
|
-
|
90
|
-
end
|
88
|
+
|
89
|
+
end
|