[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Debian JP master SVN www commits (rev.188)
=======================================================
Repository: /org/svn.debian.or.jp/repos
Revision: 188
Commiter: yasu
Date: 2007-02-27 20:07:42 +0900 (火, 27 2月 2007)
=======================================================
Log:
this is running version
=======================================================
Changed:
A cdn/check-surrogates.rb
Added: cdn/check-surrogates.rb
===================================================================
--- cdn/check-surrogates.rb 2007-02-27 11:00:52 UTC (rev 187)
+++ cdn/check-surrogates.rb 2007-02-27 11:07:42 UTC (rev 188)
@@ -0,0 +1,65 @@
+#!/usr/bin/env ruby
+
+require 'socket'
+require 'syslog'
+require 'timeout'
+require 'net/http'
+require 'uri'
+require 'resolv'
+
+surrogates = {
+ '203.178.137.175' => '1',
+# '133.41.81.212' => '9900', # hiroshima-u
+ '219.103.212.212' => '1000', # hanzubon
+ '210.157.158.38' => '9900', # plat
+ '210.157.158.59' => '9900' ## fail
+}
+
+def checkhttp(host, codename='sid', port=80, tl=5)
+ begin
+ timeout(tl) do
+ h = Net::HTTP.new(host, port)
+ case response = h.get("/debian/dists/#{codename}/Release", nil)
+ when Net::HTTPSuccess
+ return true
+ else
+ return nil
+ end
+ end
+ rescue
+ return nil
+ end
+end
+
+s_active = Hash.new
+
+surrogates.each do |t_ip, t_value|
+ if checkhttp(t_ip)
+ s_active[t_ip.gsub('.',',')] = t_value
+ else
+ end
+end
+
+foo = File.open("addr", 'w')
+
+foo.puts "##" + Time.now.to_s + "\n\n"
+foo.puts '$addr_db = {
+ "default" => {
+ "ns.cdn.araki.net" => [
+ [[210,157,158,38], 0],
+ ],
+ "localhost" => [
+ [[127,0,0,1], 0],
+ ],
+ "deb.cdn.araki.net" => [
+'
+s_active.each do |k,v|
+ foo.puts "\t" + '[[' + k + '], ' + v + '],' + "\n"
+end
+
+foo.puts '
+ ],
+ },
+}'
+
+foo.close