-
-
Save bugparty/c8f75b3475bb3defa548790e6e583b12 to your computer and use it in GitHub Desktop.
检查有效的联通缓存服务器ip
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 '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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment