Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
检查有效的联通缓存服务器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

This comment has been minimized.

Copy link
Owner Author

@mangege 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