Skip to content

Instantly share code, notes, and snippets.

@r4um
Last active February 6, 2018 11:52
Show Gist options
  • Save r4um/2413607 to your computer and use it in GitHub Desktop.
Save r4um/2413607 to your computer and use it in GitHub Desktop.
Discover steam servers on LAN
#!/usr/bin/ruby
require 'socket'
def print_status(data,from)
data = data[data.index("\\",4)+1...data.length].split("\\")
i=0
a = Hash.new()
while i < data.length-1
a.store(data[i] , data[i+1])
i=i+1
end
printf "%s\t%s\t%s\t%s\t%d/%d\t%d\n",a['hostname'],from,a['description'],a['map'],a['players'],a['max'],a['password']
end
begin
payload = "\xff\xff\xff\xffinfostring\x00"
sock = UDPSocket.new()
sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_BROADCAST, true)
sock.send(payload,0,"255.255.255.255",27015)
while true
reply,from = sock.recvfrom(1024,0)
print_status(reply,from[3])
end
rescue Interrupt
exit(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment