steam-condenser 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/VERSION.yml +2 -2
  2. data/lib/datagram_channel.rb +30 -33
  3. data/lib/exceptions/packet_format_exception.rb +7 -3
  4. data/lib/exceptions/rcon_ban_exception.rb +7 -5
  5. data/lib/exceptions/rcon_no_auth_exception.rb +8 -6
  6. data/lib/exceptions/timeout_exception.rb +10 -4
  7. data/lib/socket_channel.rb +11 -17
  8. data/lib/steam/community/cacheable.rb +5 -7
  9. data/lib/steam/community/css/css_map.rb +31 -0
  10. data/lib/steam/community/css/css_stats.rb +116 -0
  11. data/lib/steam/community/css/css_weapon.rb +33 -0
  12. data/lib/steam/community/dods/dods_stats.rb +3 -3
  13. data/lib/steam/community/game_stats.rb +14 -13
  14. data/lib/steam/community/game_weapon.rb +3 -5
  15. data/lib/steam/community/l4d/abstract_l4d_stats.rb +4 -2
  16. data/lib/steam/community/l4d/l4d_explosive.rb +2 -2
  17. data/lib/steam/community/l4d/l4d_map.rb +3 -3
  18. data/lib/steam/community/steam_group.rb +2 -4
  19. data/lib/steam/community/steam_id.rb +2 -2
  20. data/lib/steam/community/tf2/tf2_class.rb +17 -17
  21. data/lib/steam/community/tf2/tf2_class_factory.rb +17 -17
  22. data/lib/steam/community/tf2/tf2_engineer.rb +9 -9
  23. data/lib/steam/community/tf2/tf2_medic.rb +9 -9
  24. data/lib/steam/community/tf2/tf2_sniper.rb +7 -7
  25. data/lib/steam/community/tf2/tf2_spy.rb +9 -9
  26. data/lib/steam/community/tf2/tf2_stats.rb +9 -9
  27. data/lib/steam/packets/a2a_ack_packet.rb +11 -9
  28. data/lib/steam/packets/a2a_ping_packet.rb +5 -4
  29. data/lib/steam/packets/a2m_get_servers_batch2_packet.rb +13 -12
  30. data/lib/steam/packets/a2s_info_packet.rb +8 -7
  31. data/lib/steam/packets/a2s_player_packet.rb +6 -6
  32. data/lib/steam/packets/a2s_rules_packet.rb +5 -5
  33. data/lib/steam/packets/a2s_serverquery_getchallenge_packet.rb +4 -3
  34. data/lib/steam/packets/m2a_server_batch_packet.rb +20 -22
  35. data/lib/steam/packets/rcon/rcon_auth_request.rb +5 -5
  36. data/lib/steam/packets/rcon/rcon_auth_response.rb +6 -6
  37. data/lib/steam/packets/rcon/rcon_exec_request.rb +5 -5
  38. data/lib/steam/packets/rcon/rcon_exec_response.rb +2 -2
  39. data/lib/steam/packets/rcon/rcon_goldsrc_request.rb +7 -7
  40. data/lib/steam/packets/rcon/rcon_goldsrc_response.rb +8 -8
  41. data/lib/steam/packets/rcon/rcon_packet.rb +12 -16
  42. data/lib/steam/packets/rcon/rcon_packet_factory.rb +19 -19
  43. data/lib/steam/packets/request_with_challenge.rb +5 -5
  44. data/lib/steam/packets/s2a_info2_packet.rb +28 -30
  45. data/lib/steam/packets/s2a_info_base_packet.rb +11 -16
  46. data/lib/steam/packets/s2a_info_detailed_packet.rb +30 -28
  47. data/lib/steam/packets/s2a_player_packet.rb +7 -9
  48. data/lib/steam/packets/s2a_rules_packet.rb +8 -12
  49. data/lib/steam/packets/s2c_challenge_packet.rb +7 -6
  50. data/lib/steam/packets/steam_packet.rb +7 -6
  51. data/lib/steam/packets/steam_packet_factory.rb +37 -38
  52. data/lib/steam/servers/game_server.rb +76 -86
  53. data/lib/steam/servers/goldsrc_server.rb +5 -5
  54. data/lib/steam/servers/master_server.rb +24 -24
  55. data/lib/steam/servers/source_server.rb +17 -19
  56. data/lib/steam/sockets/goldsrc_socket.rb +43 -46
  57. data/lib/steam/sockets/master_server_socket.rb +11 -13
  58. data/lib/steam/sockets/rcon_socket.rb +15 -17
  59. data/lib/steam/sockets/source_socket.rb +21 -21
  60. data/lib/steam/sockets/steam_socket.rb +25 -28
  61. data/lib/steam/steam_player.rb +3 -1
  62. data/lib/stringio_additions.rb +48 -0
  63. data/test/datagram_channel_tests.rb +8 -8
  64. data/test/query_tests.rb +15 -14
  65. data/test/rcon_tests.rb +32 -31
  66. data/test/socket_channel_tests.rb +7 -7
  67. data/test/steam/communtiy/steam_community_test_suite.rb +5 -2
  68. data/test/steam_community_tests.rb +4 -3
  69. data/test/stringio_additions_tests.rb +77 -0
  70. metadata +15 -8
  71. data/lib/byte_buffer.rb +0 -126
  72. data/lib/exceptions/buffer_underflow_exception.rb +0 -8
  73. data/test/byte_buffer_tests.rb +0 -76
@@ -1,19 +1,21 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/steam_packet"
6
+ require 'steam/packets/steam_packet'
7
7
 
8
8
  # The A2A_ACK_Packet class represents the response to a A2A_PING
9
9
  # request send to the server.
10
10
  class A2A_ACK_Packet < SteamPacket
11
-
11
+
12
12
  # Creates a A2A_ACK response object based on the data received.
13
- def initialize(data)
14
- if data != "\0" && data != "00000000000000\0"
15
- raise Exception.new("Wrong formatted A2A_ACK packet.")
16
- end
17
- super SteamPacket::A2A_ACK_HEADER, data
18
- end
13
+ def initialize(data)
14
+ if data != "\0" && data != "00000000000000\0"
15
+ raise Exception.new('Wrong formatted A2A_ACK packet.')
16
+ end
17
+
18
+ super SteamPacket::A2A_ACK_HEADER, data
19
+ end
20
+
19
21
  end
@@ -1,16 +1,17 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/steam_packet"
6
+ require 'steam/packets/steam_packet'
7
7
 
8
8
  # The A2A_PING_Packet class represents a A2A_PING request send to the
9
9
  # server.
10
10
  class A2A_PING_Packet < SteamPacket
11
-
11
+
12
12
  # Creates a new A2A_PING request object
13
13
  def initialize
14
14
  super SteamPacket::A2A_PING_HEADER
15
15
  end
16
- end
16
+
17
+ end
@@ -1,23 +1,24 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/steam_packet"
7
- require "steam/servers/master_server"
6
+ require 'steam/packets/steam_packet'
7
+ require 'steam/servers/master_server'
8
8
 
9
9
  class A2M_GET_SERVERS_BATCH2_Packet < SteamPacket
10
-
10
+
11
11
  # Creates a master server request, filtering by the given paramters.
12
- def initialize(region_code = MasterServer::REGION_ALL, start_ip = "0.0.0.0:0", filter = "")
12
+ def initialize(region_code = MasterServer::REGION_ALL, start_ip = '0.0.0.0:0', filter = '')
13
13
  super SteamPacket::A2M_GET_SERVERS_BATCH2_HEADER
14
-
15
- @filter = filter;
16
- @region_code = region_code;
17
- @start_ip = start_ip;
14
+
15
+ @filter = filter
16
+ @region_code = region_code
17
+ @start_ip = start_ip
18
18
  end
19
-
19
+
20
20
  def to_s
21
- return [@header_data, @region_code, @start_ip, @filter].pack("c2Z*Z*")
21
+ [@header_data, @region_code, @start_ip, @filter].pack('c2Z*Z*')
22
22
  end
23
- end
23
+
24
+ end
@@ -1,16 +1,17 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/steam_packet"
6
+ require 'steam/packets/steam_packet'
7
7
 
8
8
  # The A2S_INFO_Packet class represents a A2S_INFO request send to the
9
9
  # server.
10
10
  class A2S_INFO_Packet < SteamPacket
11
-
11
+
12
12
  # Creates a new A2S_INFO request object
13
- def initialize
14
- super SteamPacket::A2S_INFO_HEADER, "Source Engine Query\0"
15
- end
16
- end
13
+ def initialize
14
+ super SteamPacket::A2S_INFO_HEADER, "Source Engine Query\0"
15
+ end
16
+
17
+ end
@@ -1,20 +1,20 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/request_with_challenge"
7
- require "steam/packets/steam_packet"
6
+ require 'steam/packets/request_with_challenge'
7
+ require 'steam/packets/steam_packet'
8
8
 
9
9
  # The A2S_PLAYER_Packet class represents a A2S_PLAYER request send to the
10
10
  # server.
11
11
  class A2S_PLAYER_Packet < SteamPacket
12
-
12
+
13
13
  include RequestWithChallenge
14
-
14
+
15
15
  # Creates a new A2S_PLAYER request object including the challenge_number
16
16
  def initialize(challenge_number = -1)
17
17
  super SteamPacket::A2S_PLAYER_HEADER, challenge_number
18
18
  end
19
-
19
+
20
20
  end
@@ -1,16 +1,16 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/request_with_challenge"
7
- require "steam/packets/steam_packet"
6
+ require 'steam/packets/request_with_challenge'
7
+ require 'steam/packets/steam_packet'
8
8
 
9
9
  # Creates a new A2A_RULES request object including the challenge_number
10
10
  class A2S_RULES_Packet < SteamPacket
11
-
11
+
12
12
  include RequestWithChallenge
13
-
13
+
14
14
  # Creates a new A2S_RULES request object including the challenge_number
15
15
  def initialize(challenge_number = -1)
16
16
  super SteamPacket::A2S_RULES_HEADER, challenge_number
@@ -1,16 +1,17 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/steam_packet"
6
+ require 'steam/packets/steam_packet'
7
7
 
8
8
  # The A2S_SERVERQUERY_GETCHALLENGE_Packet class represents a
9
9
  # A2S_SERVERQUERY_GETCHALLENGE request send to the server.
10
10
  class A2S_SERVERQUERY_GETCHALLENGE_Packet < SteamPacket
11
-
11
+
12
12
  # Creates a new A2S_SERVERQUERY_GETCHALLENGE request object
13
13
  def initialize
14
14
  super SteamPacket::A2S_SERVERQUERY_GETCHALLENGE_HEADER
15
15
  end
16
+
16
17
  end
@@ -1,35 +1,33 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/steam_packet"
6
+ require 'steam/packets/steam_packet'
7
7
 
8
8
  class M2A_SERVER_BATCH_Packet < SteamPacket
9
-
9
+
10
+ attr_reader :servers
11
+
10
12
  def initialize(data)
11
13
  super SteamPacket::M2A_SERVER_BATCH_HEADER, data
12
-
13
- if(@content_data.get_byte != 0x0A)
14
- raise PacketFormatException.new("Master query response is missing additional 0x0A byte.")
14
+
15
+ unless @content_data.byte == 0x0A
16
+ raise PacketFormatException.new('Master query response is missing additional 0x0A byte.')
15
17
  end
16
-
17
- @server_array = Array.new
18
-
18
+
19
+ @servers = []
20
+
19
21
  begin
20
- first_octet = @content_data.get_byte
21
- second_octet = @content_data.get_byte
22
- third_octet = @content_data.get_byte
23
- fourth_octet = @content_data.get_byte
24
- port_number = @content_data.get_short
22
+ first_octet = @content_data.byte
23
+ second_octet = @content_data.byte
24
+ third_octet = @content_data.byte
25
+ fourth_octet = @content_data.byte
26
+ port_number = @content_data.short
25
27
  port_number = ((port_number & 0xFF) << 8) + (port_number >> 8)
26
-
27
- @server_array << "#{first_octet}.#{second_octet}.#{third_octet}.#{fourth_octet}:#{port_number}"
28
+
29
+ @servers << "#{first_octet}.#{second_octet}.#{third_octet}.#{fourth_octet}:#{port_number}"
28
30
  end while @content_data.remaining > 0
29
31
  end
30
-
31
- def get_servers
32
- return @server_array
33
- end
34
-
35
- end
32
+
33
+ end
@@ -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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/rcon/rcon_packet"
6
+ require 'steam/packets/rcon/rcon_packet'
7
7
 
8
8
  class RCONAuthRequest < RCONPacket
9
-
9
+
10
10
  def initialize(request_id, rcon_password)
11
11
  super request_id, RCONPacket::SERVERDATA_AUTH, rcon_password
12
12
  end
13
-
14
- end
13
+
14
+ end
@@ -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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/rcon/rcon_packet"
6
+ require 'steam/packets/rcon/rcon_packet'
7
7
 
8
8
  class RCONAuthResponse < RCONPacket
9
-
9
+
10
10
  def initialize(request_id)
11
- super request_id, RCONPacket::SERVERDATA_AUTH_RESPONSE, ""
11
+ super request_id, RCONPacket::SERVERDATA_AUTH_RESPONSE, ''
12
12
  end
13
-
14
- end
13
+
14
+ end
@@ -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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/rcon/rcon_packet"
6
+ require 'steam/packets/rcon/rcon_packet'
7
7
 
8
8
  class RCONExecRequest < RCONPacket
9
-
9
+
10
10
  def initialize(request_id, rcon_command)
11
11
  super request_id, RCONPacket::SERVERDATA_EXECCOMMAND, rcon_command
12
12
  end
13
-
14
- end
13
+
14
+ end
@@ -11,8 +11,8 @@ class RCONExecResponse < RCONPacket
11
11
  super request_id, RCONPacket::SERVERDATA_RESPONSE_VALUE, command_response
12
12
  end
13
13
 
14
- def get_response
15
- @content_data.array[0..-3]
14
+ def response
15
+ @content_data.data[0..-3]
16
16
  end
17
17
 
18
18
  end
@@ -1,18 +1,18 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/steam_packet"
6
+ require 'steam/packets/steam_packet'
7
7
 
8
8
  class RCONGoldSrcRequest < SteamPacket
9
-
9
+
10
10
  def initialize(request)
11
11
  super 0x00, request
12
12
  end
13
-
13
+
14
14
  def to_s
15
- return [0xFFFFFFFF, @content_data.array].pack("Va*")
15
+ [0xFFFFFFFF, @content_data.data].pack('Va*')
16
16
  end
17
-
18
- end
17
+
18
+ end
@@ -1,18 +1,18 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/packets/steam_packet"
6
+ require 'steam/packets/steam_packet'
7
7
 
8
8
  class RCONGoldSrcResponse < SteamPacket
9
-
9
+
10
10
  def initialize(command_response)
11
11
  super SteamPacket::RCON_GOLDSRC_RESPONSE_HEADER, command_response
12
12
  end
13
-
14
- def get_response
15
- return @content_data.array[0..-3]
13
+
14
+ def response
15
+ @content_data.data[0..-3]
16
16
  end
17
-
18
- end
17
+
18
+ end
@@ -1,34 +1,30 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "abstract_class"
7
- require "steam/packets/steam_packet"
6
+ require 'abstract_class'
7
+ require 'steam/packets/steam_packet'
8
8
 
9
9
  class RCONPacket < SteamPacket
10
10
 
11
11
  include AbstractClass
12
-
12
+
13
13
  SERVERDATA_AUTH = 3
14
14
  SERVERDATA_AUTH_RESPONSE = 2
15
15
  SERVERDATA_EXECCOMMAND = 2
16
16
  SERVERDATA_RESPONSE_VALUE = 0
17
-
17
+
18
18
  attr_reader :request_id
19
-
19
+
20
20
  def initialize(request_id, rcon_header, rcon_data)
21
21
  super rcon_header, "#{rcon_data}\0\0"
22
-
22
+
23
23
  @request_id = request_id
24
24
  end
25
-
26
- def get_bytes
27
- return [@content_data.length + 8, @request_id, @header_data, @content_data.array].pack("V3a*")
28
- end
29
-
30
- def get_request_id
31
- return @request_id
25
+
26
+ def bytes
27
+ [@content_data.length + 8, @request_id, @header_data, @content_data.data].pack('V3a*')
32
28
  end
33
-
34
- end
29
+
30
+ end
@@ -1,27 +1,27 @@
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-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "abstract_class"
7
- require "byte_buffer"
8
- require "exceptions/packet_format_exception"
9
- require "steam/packets/steam_packet_factory"
10
- require "steam/packets/rcon/rcon_auth_response"
11
- require "steam/packets/rcon/rcon_exec_response"
6
+ require 'abstract_class'
7
+ require 'stringio_additions'
8
+ require 'exceptions/packet_format_exception'
9
+ require 'steam/packets/steam_packet_factory'
10
+ require 'steam/packets/rcon/rcon_auth_response'
11
+ require 'steam/packets/rcon/rcon_exec_response'
12
12
 
13
13
  class RCONPacketFactory < SteamPacketFactory
14
-
14
+
15
15
  include AbstractClass
16
-
17
- def self.get_packet_from_data(raw_data)
18
- byte_buffer = ByteBuffer.new raw_data
19
-
20
- packet_size = byte_buffer.get_long
21
- request_id = byte_buffer.get_long
22
- header = byte_buffer.get_long
23
- data = byte_buffer.get_string
24
-
16
+
17
+ def self.packet_from_data(raw_data)
18
+ byte_buffer = StringIO.new raw_data
19
+
20
+ byte_buffer.long
21
+ request_id = byte_buffer.long
22
+ header = byte_buffer.long
23
+ data = byte_buffer.string
24
+
25
25
  case header
26
26
  when RCONPacket::SERVERDATA_AUTH_RESPONSE then
27
27
  return RCONAuthResponse.new(request_id)
@@ -31,5 +31,5 @@ class RCONPacketFactory < SteamPacketFactory
31
31
  raise PacketFormatException.new("Unknown packet with header #{header.to_s(16)} received.")
32
32
  end
33
33
  end
34
-
35
- end
34
+
35
+ end