Last active
December 18, 2015 13:58
-
-
Save Eleeleth/5793630 to your computer and use it in GitHub Desktop.
Resolve a server to its IP for Toribash.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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