30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/srv/murakumo_server.rb', line 30
def run
RubyDNS.run_server(:listen => [[:udp, @@options[:dns_address], @@options[:dns_port]]]) do
@logger = @@options[:logger] if @@options[:logger]
on(:start) do
if @@options[:socket]
DRb.start_service("drbunix:#{@@options[:socket]}", @@cloud)
at_exit { FileUtils.rm_f(@@options[:socket]) }
end
if @@options[:logger]
trap(:HUP) do
if logger = @@options[:logger]
logdev = logger.instance_variable_get(:@logdev)
if (dev = logdev.dev).kind_of?(File)
path = dev.path
mutex = logdev.instance_variable_get(:@mutex)
mutex.synchronize do
dev.reopen(path, 'a')
dev.sync = true
end
end
end
end
end
@@cloud.start
end
match(@@cloud.method(:address_exist?), :A) do |transaction|
records = @@cloud.lookup_addresses(transaction.name)
records.each do |r|
address, ttl = r
transaction.respond!(address, :ttl => ttl)
end
end
match(@@cloud.method(:name_exist?), :PTR) do |transaction|
name, ttl = @@cloud.lookup_name(transaction.name)
transaction.respond!(Resolv::DNS::Name.create("#{name}."), :ttl => ttl)
end
if @@options[:resolver]
otherwise do |transaction|
transaction.passthrough!(@@options[:resolver])
end
end
end end
|