Skip to content
This repository
Newer
Older
100644 112 lines (96 sloc) 4.259 kb
afb4065b »
2009-07-01 Super simple and super buggy initial version. It works, but sometimes…
1 namespace :server do
ee6b7787 »
2010-08-23 Remove .txt temporary definition files. Change rake tasks to generate…
2
07cd39b3 »
2009-07-07 Refactoring class to use an object oriented server definition. The li…
3 desc "server:convert_file_tlds"
4 task :convert_file_tlds do
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
5 list = parse_list_tld
7096e8c3 »
2010-08-23 Move Debian/Linux Whois files to the C folder
6 File.open("data/c/tlds.txt", "w+") do |f|
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
7 f.write(list)
8 end
9 puts "Created file with #{list.size} servers."
10 end
11
12 desc "server:convert_file_ipv4"
13 task :convert_file_ipv4 do
14 list = parse_list_ipv4
7096e8c3 »
2010-08-23 Move Debian/Linux Whois files to the C folder
15 File.open("data/c/ipv4.txt", "w+") do |f|
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
16 f.write(list)
17 end
18 puts "Created file with #{list.size} servers."
19 end
20
21 desc "server:convert_file_ipv6"
22 task :convert_file_ipv6 do
23 list = parse_list_ipv6
7096e8c3 »
2010-08-23 Move Debian/Linux Whois files to the C folder
24 File.open("data/c/ipv6.txt", "w+") do |f|
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
25 f.write(list)
26 end
27 puts "Created file with #{list.size} servers."
28 end
29
30
31 def parse_list_tld
7096e8c3 »
2010-08-23 Move Debian/Linux Whois files to the C folder
32 File.readlines("data/c/tld_serv_list").map do |line|
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
33 line.chomp!
34 line.gsub!(/^\s*(.*)\s*$/, '\1')
35 line.gsub!(/\s*#.*$/, '')
36 next if line =~ /^$/;
37 abort("format error #{line}") unless line =~ /^([\w\d\.-]+)\s+([\w\d\.:-]+|[A-Z]+\s+.*)$/
38
39 extension, instructions = $1, $2
40 server, options = case instructions
471e9fa7 »
2009-08-20 Sync definitions with Debian whois 4.7.36
41 when "NONE" then [nil, { :adapter => Whois::Server::Adapters::None }]
42 when "ARPA" then [nil, { :adapter => Whois::Server::Adapters::Arpa }]
43 when /^WEB (.*)$/ then [nil, { :adapter => Whois::Server::Adapters::Web, :web => $1 }]
44 when "CRSNIC" then ["whois.crsnic.net", { :adapter => Whois::Server::Adapters::Verisign }]
45 when /^VERISIGN (.*)$/ then [$1, { :adapter => Whois::Server::Adapters::Verisign }]
46 when "PIR" then ["whois.publicinterestregistry.net", { :adapter => Whois::Server::Adapters::Pir }]
47 when "AFILIAS" then ["whois.afilias-grs.info", { :adapter => Whois::Server::Adapters::Afilias }]
48 when "NICCC" then ["whois.nic.cc", { :adapter => Whois::Server::Adapters::Verisign }]
49 else [instructions]
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
50 end
51
d0a97b9d »
2010-08-24 Improved Rake task to create server definitions.
52 %Q{Whois::Server.define :tld, #{value_to_string(extension)}, #{value_to_string(server)}#{options.nil? ? "" : ", " + options_to_string(options)}\n}
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
53 end
54 end
55
56 def parse_list_ipv4
7096e8c3 »
2010-08-23 Move Debian/Linux Whois files to the C folder
57 File.readlines("data/c/ip_del_list").map do |line|
afb4065b »
2009-07-01 Super simple and super buggy initial version. It works, but sometimes…
58 line.chomp!
59 line.gsub!(/^\s*(.*)\s*$/, '\1')
60 line.gsub!(/\s*#.*$/, '')
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
61 next if line =~ /^$/;
62 abort("format error #{line}") unless line =~ /^([\d\.]+)\/(\d+)\s+([\w\.]+)$/
63
64 range, server = line.split(/[ \t]/)
65 server, options = case server
66 when /\./ then [server]
67 when "UNALLOCATED" then [nil, { :adapter => Whois::Server::Adapters::None }]
3a3aa2c2 »
2010-08-23 Sync definitions with Debian whois 5.0.7:
68 when "UNKNOWN" then [nil, { :adapter => Whois::Server::Adapters::None }]
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
69 else ["whois.#{server}.net"]
70 end
71
d0a97b9d »
2010-08-24 Improved Rake task to create server definitions.
72 %Q{Whois::Server.define :ipv4, #{value_to_string(range)}, #{value_to_string(server)}#{options.nil? ? "" : ", " + options_to_string(options)}\n}
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
73 end
74 end
75
76 def parse_list_ipv6
7096e8c3 »
2010-08-23 Move Debian/Linux Whois files to the C folder
77 File.readlines("data/c/ip6_del_list").map do |line|
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
78 line.chomp!
79 line.gsub!(/^\s*(.*)\s*$/, '\1')
80 line.gsub!(/\s*#.*$/, '')
81 next if line =~ /^$/;
82 abort("format error #{line}") unless line =~ %r{^([\da-fA-F]{4}):([\da-fA-F]{1,4})::/(\d+)\s+([\w\.]+)$}
83
84 range = "#{$1}:#{$2}::/#{$3}"
85 server = $4
86 server, options = case server
87 when /\./ then [server]
88 when "UNALLOCATED" then [nil, { :adapter => Whois::Server::Adapters::None }]
89 when "6to4" then ["6to4", { :adapter => Whois::Server::Adapters::NotImplemented }]
90 when "teredo" then ["teredo", { :adapter => Whois::Server::Adapters::NotImplemented }]
91 else ["whois.#{server}.net"]
afb4065b »
2009-07-01 Super simple and super buggy initial version. It works, but sometimes…
92 end
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
93
d0a97b9d »
2010-08-24 Improved Rake task to create server definitions.
94 %Q{Whois::Server.define :ipv6, #{value_to_string(range)}, #{value_to_string(server)}#{options.nil? ? "" : ", " + options_to_string(options)}\n}
95 end
96 end
97
98 def options_to_string(options)
99 options.is_a?(Hash) ? options.map do |k, v|
100 ":#{k} => " + (v.is_a?(Hash) ? ('{ ' + options_to_string(v) + ' }') : "#{value_to_string(v)}")
101 end.join(", ") : options.to_s
102 end
103
104 def value_to_string(value)
105 case value
106 when NilClass then "nil"
107 when String then '"' + value.to_s + '"'
108 else value.to_s
07cd39b3 »
2009-07-07 Refactoring class to use an object oriented server definition. The li…
109 end
afb4065b »
2009-07-01 Super simple and super buggy initial version. It works, but sometimes…
110 end
404f8378 »
2009-08-06 Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
111
afb4065b »
2009-07-01 Super simple and super buggy initial version. It works, but sometimes…
112 end
Something went wrong with that request. Please try again.