Skip to content

Instantly share code, notes, and snippets.

@Eleeleth
Last active December 18, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eleeleth/5793630 to your computer and use it in GitHub Desktop.
Save Eleeleth/5793630 to your computer and use it in GitHub Desktop.
Resolve a server to its IP for Toribash.
require 'socket'
host = 'game.toribash.com'
port = 22000
server = 'judo1'
#Create our socket.
lobbySock = TCPSocket.new host, port
#loop over lobby output
while line = lobbySock.gets
if line =~ /^SERVER/
line = line.split('; ')[1]
line = line.split ' '
if server == line[1]
ip = line[0]
puts "Resolved #{server} to #{ip}"
break
end
end
end
if !ip
puts "Could not resolve #{server} to an IP"
end
lobbySock.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment