Skip to content

Instantly share code, notes, and snippets.

@mangege
Last active August 8, 2017 17:32
Show Gist options
  • Save mangege/755536f08202a16ff5bee029571b5e99 to your computer and use it in GitHub Desktop.
Save mangege/755536f08202a16ff5bee029571b5e99 to your computer and use it in GitHub Desktop.
检查有效的联通缓存服务器ip
require 'uri'
require 'net/http'
require 'timeout'
def check_server(ip)
uri = URI('http://ip.mangege.com/')
Timeout::timeout(3) do
Net::HTTP.start(ip, 80) do |http|
request = Net::HTTP::Get.new uri
response = http.request request
puts ip if response.body.include?(ip)
end
end
rescue
end
(1..254).each do |i|
check_server("120.52.72.#{i}")
end
@mangege
Copy link
Author

mangege commented Aug 11, 2016

120.52.72.19
120.52.72.20
120.52.72.21
120.52.72.22
120.52.72.23
120.52.72.24
120.52.72.47
120.52.72.48
120.52.72.52
120.52.72.53
120.52.72.54
120.52.72.55
120.52.72.56
120.52.72.58
120.52.72.59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment