steam-condenser 1.3.5 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +228 -0
- data/CONTRIBUTING.md +59 -0
- data/Gemfile.lock +12 -13
- data/README.md +9 -4
- data/lib/steam-condenser/version.rb +1 -1
- data/lib/steam/community/alien_swarm/alien_swarm_mission.rb +10 -9
- data/lib/steam/community/alien_swarm/alien_swarm_stats.rb +74 -72
- data/lib/steam/community/css/css_map.rb +2 -2
- data/lib/steam/community/css/css_stats.rb +54 -56
- data/lib/steam/community/css/css_weapon.rb +4 -4
- data/lib/steam/community/game_item.rb +2 -3
- data/lib/steam/community/game_leaderboard.rb +22 -15
- data/lib/steam/community/l4d/abstract_l4d_stats.rb +64 -61
- data/lib/steam/community/l4d/l4d2_stats.rb +26 -21
- data/lib/steam/community/steam_id.rb +8 -11
- data/lib/steam/community/web_api.rb +19 -14
- data/lib/steam/packets/s2a_info2_packet.rb +16 -14
- data/lib/steam/packets/s2a_info_detailed_packet.rb +24 -19
- data/lib/steam/packets/steam_packet_factory.rb +7 -2
- data/lib/steam/servers/game_server.rb +3 -2
- data/lib/steam/servers/master_server.rb +1 -1
- data/lib/steam/sockets/source_socket.rb +4 -9
- data/pkg/steam-condenser-1.3.5.gem +0 -0
- data/pkg/steam-condenser-1.3.5/Gemfile +7 -0
- data/pkg/steam-condenser-1.3.5/Gemfile.lock +45 -0
- data/pkg/steam-condenser-1.3.5/LICENSE +25 -0
- data/pkg/steam-condenser-1.3.5/README.md +70 -0
- data/pkg/steam-condenser-1.3.5/Rakefile +46 -0
- data/pkg/steam-condenser-1.3.5/lib/core_ext/stringio.rb +91 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/packet_format_error.rb +13 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/rcon_ban_error.rb +22 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/rcon_no_auth_error.rb +21 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/steam_condenser_error.rb +26 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/timeout_error.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/web_api_error.rb +57 -0
- data/pkg/steam-condenser-1.3.5/lib/steam-condenser.rb +18 -0
- data/pkg/steam-condenser-1.3.5/lib/steam-condenser/community.rb +24 -0
- data/pkg/steam-condenser-1.3.5/lib/steam-condenser/servers.rb +24 -0
- data/pkg/steam-condenser-1.3.5/lib/steam-condenser/version.rb +11 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/alien_swarm/alien_swarm_mission.rb +119 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/alien_swarm/alien_swarm_stats.rb +186 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/alien_swarm/alien_swarm_weapon.rb +49 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/app_news.rb +133 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/cacheable.rb +199 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/css/css_map.rb +61 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/css/css_stats.rb +142 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/css/css_weapon.rb +69 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/defense_grid/defense_grid_stats.rb +238 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dods/dods_class.rb +90 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dods/dods_stats.rb +62 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dods/dods_weapon.rb +67 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dota2/dota2_beta_inventory.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dota2/dota2_inventory.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dota2/dota2_item.rb +33 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_achievement.rb +109 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_class.rb +22 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_inventory.rb +171 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_item.rb +156 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_item_schema.rb +131 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_leaderboard.rb +205 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_leaderboard_entry.rb +43 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_stats.rb +175 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_weapon.rb +41 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/abstract_l4d_stats.rb +185 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/abstract_l4d_weapon.rb +56 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d2_map.rb +90 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d2_stats.rb +174 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d2_weapon.rb +38 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d_explosive.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d_map.rb +65 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d_stats.rb +73 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d_weapon.rb +26 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/portal2/portal2_inventory.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/portal2/portal2_item.rb +55 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/portal2/portal2_stats.rb +33 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/steam_game.rb +193 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/steam_group.rb +129 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/steam_id.rb +498 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_beta_inventory.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_class.rb +92 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_class_factory.rb +40 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_engineer.rb +43 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_golden_wrench.rb +70 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_inventory.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_item.rb +55 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_medic.rb +35 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_sniper.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_spy.rb +41 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_stats.rb +77 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/web_api.rb +130 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/xml_data.rb +27 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2m_get_servers_batch2_packet.rb +59 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2s_info_packet.rb +24 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2s_player_packet.rb +31 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2s_rules_packet.rb +32 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2s_serverquery_getchallenge_packet.rb +25 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/c2m_checkmd5_packet.rb +31 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/m2a_server_batch_packet.rb +52 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/m2c_isvalidmd5_packet.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/m2s_requestrestart_packet.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_auth_request.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_auth_response.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_exec_request.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_exec_response.rb +37 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_goldsrc_request.rb +35 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_goldsrc_response.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_packet.rb +57 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_packet_factory.rb +43 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_terminator.rb +29 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/request_with_challenge.rb +19 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_info2_packet.rb +74 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_info_base_packet.rb +25 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_info_detailed_packet.rb +59 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_logstring_packet.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_player_packet.rb +44 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_rules_packet.rb +48 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2c_challenge_packet.rb +35 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2m_heartbeat2_packet.rb +72 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/steam_packet.rb +52 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/steam_packet_factory.rb +108 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/game_server.rb +392 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/goldsrc_server.rb +74 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/master_server.rb +188 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/server.rb +115 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/source_server.rb +117 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/goldsrc_socket.rb +142 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/master_server_socket.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/rcon_socket.rb +103 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/source_socket.rb +78 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/steam_socket.rb +91 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/steam_player.rb +143 -0
- data/pkg/steam-condenser-1.3.5/steam-condenser.gemspec +26 -0
- data/pkg/steam-condenser-1.3.5/test/core_ext/test_stringio.rb +59 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/invalid.xml +2 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/sonofthor.xml +882 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/status_goldsrc +3 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/status_source +3 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/valve-members.xml +231 -0
- data/pkg/steam-condenser-1.3.5/test/helper.rb +48 -0
- data/pkg/steam-condenser-1.3.5/test/steam/community/test_cacheable.rb +100 -0
- data/pkg/steam-condenser-1.3.5/test/steam/community/test_steam_group.rb +83 -0
- data/pkg/steam-condenser-1.3.5/test/steam/community/test_steam_id.rb +144 -0
- data/pkg/steam-condenser-1.3.5/test/steam/community/test_web_api.rb +98 -0
- data/pkg/steam-condenser-1.3.5/test/steam/packets/test_steam_packet.rb +37 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_game_server.rb +296 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_goldsrc_server.rb +59 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_master_server.rb +131 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_server.rb +72 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_source_server.rb +134 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_goldsrc_socket.rb +127 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_master_server_socket.rb +42 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_rcon_socket.rb +118 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_source_socket.rb +77 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_steam_socket.rb +97 -0
- data/steam-condenser.gemspec +2 -3
- data/test/steam/community/test_cacheable.rb +3 -0
- data/test/steam/community/test_web_api.rb +15 -2
- data/test/steam/packets/test_steam_packet.rb +1 -1
- data/test/steam/sockets/test_source_socket.rb +1 -1
- metadata +151 -27
@@ -0,0 +1,19 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
# This module implements a method to generate raw packet data used by request
|
7
|
+
# packets which send a challenge number
|
8
|
+
#
|
9
|
+
# @author Sebastian Staudt
|
10
|
+
module RequestWithChallenge
|
11
|
+
|
12
|
+
# Returns the raw data representing this packet
|
13
|
+
#
|
14
|
+
# @return [String] A string containing the raw data of this request packet
|
15
|
+
def to_s
|
16
|
+
[0xFF, 0xFF, 0xFF, 0xFF, @header_data, @content_data.string.to_i].pack('c5l')
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2008-2013, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/packets/s2a_info_base_packet'
|
7
|
+
|
8
|
+
# This class represents a S2A_INFO_DETAILED response packet sent by a Source or
|
9
|
+
# GoldSrc server
|
10
|
+
#
|
11
|
+
# Out-of-date (before 10/24/2008) GoldSrc servers use an older format (see
|
12
|
+
# {S2A_INFO_DETAILED_Packet}).
|
13
|
+
#
|
14
|
+
# @author Sebastian Staudt
|
15
|
+
# @see GameServer#update_server_info
|
16
|
+
class S2A_INFO2_Packet
|
17
|
+
|
18
|
+
include S2A_INFO_BasePacket
|
19
|
+
|
20
|
+
EDF_GAME_ID = 0x01
|
21
|
+
EDF_GAME_PORT = 0x80
|
22
|
+
EDF_SERVER_ID = 0x10
|
23
|
+
EDF_SERVER_TAGS = 0x20
|
24
|
+
EDF_SOURCE_TV = 0x40
|
25
|
+
|
26
|
+
# Creates a new S2A_INFO2 response object based on the given data
|
27
|
+
#
|
28
|
+
# @param [String] data The raw packet data replied from the server
|
29
|
+
# @see S2A_INFO_BasePacket#generate_info_hash
|
30
|
+
def initialize(data)
|
31
|
+
super S2A_INFO2_HEADER, data
|
32
|
+
|
33
|
+
info[:protocol_version] = @content_data.byte
|
34
|
+
info[:server_name] = @content_data.cstring
|
35
|
+
info[:map_name] = @content_data.cstring
|
36
|
+
info[:game_directory] = @content_data.cstring
|
37
|
+
info[:game_description] = @content_data.cstring
|
38
|
+
info[:app_id] = @content_data.short
|
39
|
+
info[:number_of_players] = @content_data.byte
|
40
|
+
info[:max_players] = @content_data.byte
|
41
|
+
info[:number_of_bots] = @content_data.byte
|
42
|
+
info[:dedicated] = @content_data.byte.chr
|
43
|
+
info[:operating_system] = @content_data.byte.chr
|
44
|
+
info[:password_needed] = @content_data.byte == 1
|
45
|
+
info[:secure] = @content_data.byte == 1
|
46
|
+
info[:game_version] = @content_data.cstring
|
47
|
+
|
48
|
+
if @content_data.remaining > 0
|
49
|
+
extra_data_flag = @content_data.byte
|
50
|
+
|
51
|
+
if extra_data_flag & EDF_GAME_PORT != 0
|
52
|
+
info[:server_port] = @content_data.short
|
53
|
+
end
|
54
|
+
|
55
|
+
if extra_data_flag & EDF_SERVER_ID != 0
|
56
|
+
info[:server_id] = @content_data.long | (@content_data.long << 32)
|
57
|
+
end
|
58
|
+
|
59
|
+
if extra_data_flag & EDF_SOURCE_TV != 0
|
60
|
+
info[:tv_port] = @content_data.short
|
61
|
+
info[:tv_name] = @content_data.cstring
|
62
|
+
end
|
63
|
+
|
64
|
+
if extra_data_flag & EDF_SERVER_TAGS != 0
|
65
|
+
info[:server_tags] = @content_data.cstring
|
66
|
+
end
|
67
|
+
|
68
|
+
if extra_data_flag & EDF_GAME_ID != 0
|
69
|
+
info[:game_id] = @content_data.long | (@content_data.long << 32)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2008-2013, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/packets/steam_packet'
|
7
|
+
|
8
|
+
# This module implements methods to generate and access server information from
|
9
|
+
# S2A_INFO_DETAILED and S2A_INFO2 response packets
|
10
|
+
#
|
11
|
+
# @author Sebastian Staudt
|
12
|
+
# @see S2A_INFO_DETAILED_Packet
|
13
|
+
# @see S2A_INFO2_Packet
|
14
|
+
module S2A_INFO_BasePacket
|
15
|
+
|
16
|
+
include SteamPacket
|
17
|
+
|
18
|
+
# Returns the information provided by the server
|
19
|
+
#
|
20
|
+
# @return [Hash<String, Object>] The information provided by the server
|
21
|
+
def info
|
22
|
+
@info ||= {}
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2008-2013, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/packets/s2a_info_base_packet'
|
7
|
+
|
8
|
+
# This class represents a S2A_INFO_DETAILED response packet sent by a GoldSrc
|
9
|
+
# server
|
10
|
+
#
|
11
|
+
# @author Sebastian Staudt
|
12
|
+
# @deprecated Only outdated GoldSrc servers (before 10/24/2008) use this
|
13
|
+
# format. Newer ones use the same format as Source servers now (see
|
14
|
+
# {S2A_INFO2_Packet}).
|
15
|
+
# @see GameServer#update_server_info
|
16
|
+
class S2A_INFO_DETAILED_Packet
|
17
|
+
|
18
|
+
include S2A_INFO_BasePacket
|
19
|
+
|
20
|
+
# Creates a new S2A_INFO_DETAILED response object based on the given data
|
21
|
+
#
|
22
|
+
# @param [String] data The raw packet data replied from the server
|
23
|
+
# @see S2A_INFO_BasePacket#generate_info_hash
|
24
|
+
def initialize(data)
|
25
|
+
super S2A_INFO_DETAILED_HEADER, data
|
26
|
+
|
27
|
+
info[:game_ip] = @content_data.cstring
|
28
|
+
info[:server_name] = @content_data.cstring
|
29
|
+
info[:map_name] = @content_data.cstring
|
30
|
+
info[:game_directory] = @content_data.cstring
|
31
|
+
info[:game_description] = @content_data.cstring
|
32
|
+
info[:number_of_players] = @content_data.byte
|
33
|
+
info[:max_players] = @content_data.byte
|
34
|
+
info[:network_version] = @content_data.byte
|
35
|
+
info[:dedicated] = @content_data.byte.chr
|
36
|
+
info[:operating_system] = @content_data.byte.chr
|
37
|
+
info[:password_needed] = @content_data.byte == 1
|
38
|
+
info[:is_mod] = @content_data.byte == 1
|
39
|
+
|
40
|
+
if info[:is_mod]
|
41
|
+
info[:mod_info] = {}
|
42
|
+
info[:mod_info][:url_info] = @content_data.cstring
|
43
|
+
info[:mod_info][:url_dl] = @content_data.cstring
|
44
|
+
@content_data.byte
|
45
|
+
if @content_data.remaining == 12
|
46
|
+
info[:mod_info][:mod_version] = @content_data.long
|
47
|
+
info[:mod_info][:mod_size] = @content_data.long
|
48
|
+
info[:mod_info][:sv_only] = @content_data.byte == 1
|
49
|
+
info[:mod_info][:cl_dll] = @content_data.byte == 1
|
50
|
+
info[:secure] = @content_data.byte == 1
|
51
|
+
info[:number_of_bots] = @content_data.byte
|
52
|
+
end
|
53
|
+
else
|
54
|
+
info[:secure] = @content_data.byte == 1
|
55
|
+
info[:number_of_bots] = @content_data.byte
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/packets/steam_packet'
|
7
|
+
|
8
|
+
# This class represents a S2A_LOGSTRING packet used to transfer log messages
|
9
|
+
#
|
10
|
+
# @author Sebastian Staudt
|
11
|
+
class S2A_LOGSTRING_Packet
|
12
|
+
|
13
|
+
include SteamPacket
|
14
|
+
|
15
|
+
# Returns the log message contained in this packet
|
16
|
+
#
|
17
|
+
# @return [String] The log message
|
18
|
+
attr_reader :message
|
19
|
+
|
20
|
+
# Creates a new S2A_LOGSTRING object based on the given data
|
21
|
+
#
|
22
|
+
# @param [String] data The raw packet data sent by the server
|
23
|
+
def initialize(data)
|
24
|
+
super S2A_LOGSTRING_HEADER, data
|
25
|
+
|
26
|
+
@content_data.byte
|
27
|
+
@message = @content_data.string
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'errors/packet_format_error'
|
7
|
+
require 'steam/packets/steam_packet'
|
8
|
+
|
9
|
+
# This class represents a S2A_PLAYER response sent by a game server
|
10
|
+
#
|
11
|
+
# It is used to transfer a list of players currently playing on the server.
|
12
|
+
#
|
13
|
+
# @author Sebastian Staudt
|
14
|
+
# @see GameServer#update_player_info
|
15
|
+
class S2A_PLAYER_Packet
|
16
|
+
|
17
|
+
include SteamPacket
|
18
|
+
|
19
|
+
# Returns the list of active players provided by the server
|
20
|
+
#
|
21
|
+
# @return [Hash<String, SteamPlayer>] All active players on the server
|
22
|
+
attr_reader :player_hash
|
23
|
+
|
24
|
+
# Creates a new S2A_PLAYER response object based on the given data
|
25
|
+
#
|
26
|
+
# @param [String] content_data The raw packet data sent by the server
|
27
|
+
# @raise [PacketFormatError] if the packet data is not well formatted
|
28
|
+
def initialize(content_data)
|
29
|
+
if content_data.nil?
|
30
|
+
raise PacketFormatError, 'Wrong formatted S2A_PLAYER packet.'
|
31
|
+
end
|
32
|
+
|
33
|
+
super S2A_PLAYER_HEADER, content_data
|
34
|
+
|
35
|
+
@content_data.byte
|
36
|
+
@player_hash = {}
|
37
|
+
|
38
|
+
while @content_data.remaining > 0
|
39
|
+
player_data = @content_data.byte, @content_data.cstring, @content_data.signed_long, @content_data.float
|
40
|
+
@player_hash[player_data[1]] = SteamPlayer.new(*player_data[0..3])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/packets/steam_packet'
|
7
|
+
|
8
|
+
# This class represents a S2A_RULES response sent by a game server
|
9
|
+
#
|
10
|
+
# It is used to transfer a list of server rules (a.k.a. CVARs) with their
|
11
|
+
# active values.
|
12
|
+
#
|
13
|
+
# @author Sebastian Staudt
|
14
|
+
# @see GameServer#update_rules_info
|
15
|
+
class S2A_RULES_Packet
|
16
|
+
|
17
|
+
include SteamPacket
|
18
|
+
|
19
|
+
# Returns the list of server rules (a.k.a. CVars) with the current values
|
20
|
+
#
|
21
|
+
# @return [Hash<String, String>] A list of server rules
|
22
|
+
attr_reader :rules_hash
|
23
|
+
|
24
|
+
# Creates a new S2A_RULES response object based on the given data
|
25
|
+
#
|
26
|
+
# @param [String] content_data The raw packet data sent by the server
|
27
|
+
def initialize(content_data)
|
28
|
+
if content_data.nil?
|
29
|
+
raise PacketFormatError, 'Wrong formatted S2A_RULES response packet.'
|
30
|
+
end
|
31
|
+
|
32
|
+
super SteamPacket::S2A_RULES_HEADER, content_data
|
33
|
+
|
34
|
+
rules_count = @content_data.short
|
35
|
+
|
36
|
+
@rules_hash = {}
|
37
|
+
|
38
|
+
rules_count.times do
|
39
|
+
rule = @content_data.cstring
|
40
|
+
value = @content_data.cstring
|
41
|
+
|
42
|
+
break if rule.empty?
|
43
|
+
|
44
|
+
@rules_hash[rule] = value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/packets/steam_packet'
|
7
|
+
|
8
|
+
# This packet class represents a S2C_CHALLENGE response replied by a game
|
9
|
+
# server
|
10
|
+
#
|
11
|
+
# It is used to provide a challenge number to a client requesting information
|
12
|
+
# from the game server.
|
13
|
+
#
|
14
|
+
# @author Sebastian Staudt
|
15
|
+
# @see GameServer#update_challenge_number
|
16
|
+
class S2C_CHALLENGE_Packet
|
17
|
+
|
18
|
+
include SteamPacket
|
19
|
+
|
20
|
+
# Creates a new S2C_CHALLENGE response object based on the given data
|
21
|
+
#
|
22
|
+
# @param [String] challenge_number The raw packet data replied from the
|
23
|
+
# server
|
24
|
+
def initialize(challenge_number)
|
25
|
+
super S2C_CHALLENGE_HEADER, challenge_number
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the challenge number received from the game server
|
29
|
+
#
|
30
|
+
# @return [Fixnum] The challenge number provided by the game server
|
31
|
+
def challenge_number
|
32
|
+
@content_data.rewind
|
33
|
+
@content_data.long
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2010-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/packets/steam_packet'
|
7
|
+
|
8
|
+
# This class represents a S2M_HEARTBEAT2 packet sent by game servers to master
|
9
|
+
# servers
|
10
|
+
#
|
11
|
+
# It is used to signal the game server's availability and status to the master
|
12
|
+
# servers.
|
13
|
+
#
|
14
|
+
# @author Sebastian Staudt
|
15
|
+
# @deprecated
|
16
|
+
# @see MasterServer#send_heartbeat
|
17
|
+
class S2M_HEARTBEAT2_Packet
|
18
|
+
|
19
|
+
include SteamPacket
|
20
|
+
|
21
|
+
# Default data to send with a S2M_HEARTBEAT2 packet
|
22
|
+
DEFAULT_DATA = {
|
23
|
+
:appid => 320,
|
24
|
+
:bots => 0,
|
25
|
+
:challenge => nil,
|
26
|
+
:dedicated => 0,
|
27
|
+
:gamedir => 'hl2mp',
|
28
|
+
:gameport => 27015,
|
29
|
+
:gametype => 'ctf',
|
30
|
+
:lan => 1,
|
31
|
+
:map => 'null',
|
32
|
+
:max => 24,
|
33
|
+
:os => 'l',
|
34
|
+
:password => 0,
|
35
|
+
:players => 0,
|
36
|
+
:product => 'hl2dm',
|
37
|
+
:protocol => 7,
|
38
|
+
:region => 255,
|
39
|
+
:secure => 0,
|
40
|
+
:specport => 0,
|
41
|
+
:type => 'd',
|
42
|
+
:version => '1.0.0.0'
|
43
|
+
}
|
44
|
+
|
45
|
+
# Creates a new S2M_HEARTBEAT2 packet object based on the given data
|
46
|
+
#
|
47
|
+
# @param [Hash<Symbol, Object>] data The data to send with the heartbeat. The
|
48
|
+
# data contents are merge with the values from {DEFAULT_DATA}.
|
49
|
+
# @raise [SteamCondenserError] when the required challenge number is
|
50
|
+
# missing
|
51
|
+
def initialize(data = {})
|
52
|
+
data = DEFAULT_DATA.merge data
|
53
|
+
|
54
|
+
if data[:challenge].nil?
|
55
|
+
raise SteamCondenserError, 'You have to provide a challenge number when sending a heartbeat to a master server.'
|
56
|
+
end
|
57
|
+
|
58
|
+
bytes = 0x0A.chr
|
59
|
+
data.each { |k, v| bytes += "\\#{k}\\#{v}" }
|
60
|
+
bytes += 0x0A.chr
|
61
|
+
|
62
|
+
super S2M_HEARTBEAT2_HEADER, bytes
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns the raw data representing this packet
|
66
|
+
#
|
67
|
+
# @return [String] A string containing the raw data of this request packet
|
68
|
+
def to_s
|
69
|
+
[@header_data, @content_data.string].pack('ca*')
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'core_ext/stringio'
|
7
|
+
|
8
|
+
# This module implements the basic functionality used by most of the packets
|
9
|
+
# used in communication with master, Source or GoldSrc servers.
|
10
|
+
#
|
11
|
+
# @author Sebastian Staudt
|
12
|
+
# @see SteamPacketFactory
|
13
|
+
module SteamPacket
|
14
|
+
|
15
|
+
A2M_GET_SERVERS_BATCH2_HEADER = 0x31
|
16
|
+
A2S_INFO_HEADER = 0x54
|
17
|
+
A2S_PLAYER_HEADER = 0x55
|
18
|
+
A2S_RULES_HEADER = 0x56
|
19
|
+
A2S_SERVERQUERY_GETCHALLENGE_HEADER = 0x57
|
20
|
+
C2M_CHECKMD5_HEADER = 0x4D
|
21
|
+
M2A_SERVER_BATCH_HEADER = 0x66
|
22
|
+
M2C_ISVALIDMD5_HEADER = 0x4E
|
23
|
+
M2S_REQUESTRESTART_HEADER = 0x4F
|
24
|
+
RCON_GOLDSRC_CHALLENGE_HEADER = 0x63
|
25
|
+
RCON_GOLDSRC_NO_CHALLENGE_HEADER = 0x39
|
26
|
+
RCON_GOLDSRC_RESPONSE_HEADER = 0x6c
|
27
|
+
S2A_INFO_DETAILED_HEADER = 0x6D
|
28
|
+
S2A_INFO2_HEADER = 0x49
|
29
|
+
S2A_LOGSTRING_HEADER = 0x52
|
30
|
+
S2A_PLAYER_HEADER = 0x44
|
31
|
+
S2A_RULES_HEADER = 0x45
|
32
|
+
S2C_CONNREJECT_HEADER = 0x39
|
33
|
+
S2C_CHALLENGE_HEADER = 0x41
|
34
|
+
S2M_HEARTBEAT2_HEADER = 0x30
|
35
|
+
|
36
|
+
# Creates a new packet object based on the given data
|
37
|
+
#
|
38
|
+
# @param [Fixnum] header_data The packet header
|
39
|
+
# @param [String] content_data The raw data of the packet
|
40
|
+
def initialize(header_data, content_data = '')
|
41
|
+
@content_data = StringIO.new content_data.to_s
|
42
|
+
@header_data = header_data
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns the raw data representing this packet
|
46
|
+
#
|
47
|
+
# @return [String] A string containing the raw data of this request packet
|
48
|
+
def to_s
|
49
|
+
[0xFF, 0xFF, 0xFF, 0xFF, @header_data, @content_data.string].pack('c5a*')
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|