koraktor / steam-condenser

A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
https://koraktor.de/steam-condenser
Other
359 stars 65 forks source link

HLTV RCON challenges expire #2

Closed koraktor closed 15 years ago

koraktor commented 15 years ago

This issue has been reported by tuorpez, Mar 17, 2009 on Google Code

Hi,

Using steam-condenser to remote control an HLTV server may be funny, here a ruby example (with ed979ed921e27ff0294f4701b29d303d1a5fd8ac):

hltvServer = GoldSrcServer.new IPAddr.new('127.0.0.1'), 27020, true
hltvServer.rcon_auth 'greatRCON'

while true
  puts "\nGet status..."
  hltvReply = hltvServer.rcon_exec "status"
  puts "#### REPLY ####"
  puts hltvReply
  puts "#### /REPLY ####"
  puts "Now sleeping 20 sec..."
  sleep 20
end

You will easily understand that this program execute a "status" command on the HLTV server, print the result and wait 20sec before re-execute "status". I have also added this line warn "Current challenge : #{@rcon_challenge}" to the rcon_exec function in goldsrc_socket.rb to print out current challenge.

Here's the result :

Get status...
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
Current challenge : 3708975953
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
#### REPLY ####
--- HLTV Status ---
Online 18:43, FPS 97.9, Version 4379 (Linux)
Local IP 0.0.0.0:27020, Network In 0.0, Out 0.0, Loss 0.00
Local Slots 5, Spectators 0 (max 0), Proxies 0
Not connected.
#### /REPLY ####
Now sleeping 20 sec...

Get status...
Current challenge : 3708975953
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
#### REPLY ####
--- HLTV Status ---
Online 19:04, FPS 97.9, Version 4379 (Linux)
Local IP 0.0.0.0:27020, Network In 0.0, Out 0.0, Loss 0.00
Local Slots 5, Spectators 0 (max 0), Proxies 0
Not connected.
#### /REPLY ####
Now sleeping 20 sec...

Get status...
Current challenge : 3708975953
Sending data packet of type "RCONGoldSrcRequest".
#### REPLY ####

#### /REPLY ####
Now sleeping 20 sec...

Get status...
Current challenge : 3708975953
Sending data packet of type "RCONGoldSrcRequest".
#### REPLY ####

#### /REPLY ####
Now sleeping 20 sec...

As you can see after 40?sec the challenge expire and we can't get any results anymore. We need something to check the validity of the challenge before each commands (a simply timeout can't work properly). So I modifiy a line in goldsrc_socket.rb :

if @rcon_challenge.nil? || @is_hltv
  self.rcon_get_challenge
end

What a better command to check challenge validity than rcon challenge ? ;)

Here the new result :
Get status...
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
Current challenge : 617761570
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
#### REPLY ####
--- HLTV Status ---
Online 23:05, FPS 97.9, Version 4379 (Linux)
Local IP 0.0.0.0:27020, Network In 0.0, Out 0.0, Loss 0.00
Local Slots 5, Spectators 0 (max 0), Proxies 0
Not connected.
#### /REPLY ####
Now sleeping 20 sec...

Get status...
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
Current challenge : 617761570
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
#### REPLY ####
--- HLTV Status ---
Online 23:26, FPS 98.0, Version 4379 (Linux)
Local IP 0.0.0.0:27020, Network In 0.0, Out 0.0, Loss 0.00
Local Slots 5, Spectators 0 (max 0), Proxies 0
Not connected.
#### /REPLY ####
Now sleeping 20 sec...

Get status...
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
Current challenge : 2628870978
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
#### REPLY ####
--- HLTV Status ---
Online 23:47, FPS 98.0, Version 4379 (Linux)
Local IP 0.0.0.0:27020, Network In 0.0, Out 0.0, Loss 0.00
Local Slots 5, Spectators 0 (max 0), Proxies 0
Not connected.
#### /REPLY ####
Now sleeping 20 sec...

Get status...
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
Current challenge : 2628870978
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
#### REPLY ####
--- HLTV Status ---
Online 24:08, FPS 97.9, Version 4379 (Linux)
Local IP 0.0.0.0:27020, Network In 0.0, Out 0.0, Loss 0.00
Local Slots 5, Spectators 0 (max 0), Proxies 0
Not connected.
#### /REPLY ####
Now sleeping 20 sec...

Get status...
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
Current challenge : 245645570
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
#### REPLY ####
--- HLTV Status ---
Online 24:29, FPS 98.1, Version 4379 (Linux)
Local IP 0.0.0.0:27020, Network In 0.0, Out 0.0, Loss 0.00
Local Slots 5, Spectators 0 (max 0), Proxies 0
Not connected.
#### /REPLY ####
Now sleeping 20 sec...

Get status...
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
Current challenge : 245645570
Sending data packet of type "RCONGoldSrcRequest".
Got reply of type "RCONGoldSrcResponse".
#### REPLY ####
--- HLTV Status ---
Online 24:50, FPS 98.1, Version 4379 (Linux)
Local IP 0.0.0.0:27020, Network In 0.0, Out 0.0, Loss 0.00
Local Slots 5, Spectators 0 (max 0), Proxies 0
Not connected.
#### /REPLY ####
Now sleeping 20 sec...

As you can see the challenge is automatically updated after expiration and I always get my results ! At the cost of 2 rcon challenge command for each rcon command...

If you can do better I'm interested !

koraktor commented 15 years ago

This comment has been posted by koraktor, Mar 19, 2009 on Google Code

I will definitely check into this problem. As this may hint at a general expiration of challenges (which is undocumented in Valve's developer wiki) this may also affect other queries and all servers. So I will try to find out more about this and fix it.

koraktor commented 15 years ago

This comment has been posted by koraktor, Mar 21, 2009 on Google Code

Ok. I just tried this for normal game servers - their challenges do not expire. Neither server queries nor RCON stopped working. So this is specific to HTLV. Expiration time is about 30 to 40 seconds.

Now about a fix for this. Your suggestion works, but it adds mostly unnecessary overhead to HLTV RCON communication. Another way is adding a timestamp to the server object (this would additionally increase the need for a seperate HLTVServer class) which will be used to check the expiration time of the challenge.

koraktor commented 15 years ago

Always rechallenge when using RCON HLTV servers

Closed by fdd286b3ab1de2be469ecb45bbd2345288455d9f

PS: You may see that I choose the easy way, taking the overhead of redundant challenges. I think this should be ok for this specific use case.