Class: Comuna::Server
- Inherits:
-
Object
- Object
- Comuna::Server
- Defined in:
- lib/comuna/server.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(config) ⇒ Server
constructor
A new instance of Server.
- #upstream ⇒ Object
Constructor Details
#initialize(config) ⇒ Server
Returns a new instance of Server.
9 10 11 12 13 |
# File 'lib/comuna/server.rb', line 9 def initialize(config) @interfaces = config.interfaces @upstream_ifaces = config.upstream @matches = config.matches end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/comuna/server.rb', line 15 def call matches = @matches upstr = upstream RubyDNS::run_server(:listen => @interfaces) do @logger.level = Logger::INFO matches.each do |(name, address)| match(/#{name}/, IN::A) do |transaction| transaction.respond!(address) end end otherwise do |transaction| transaction.passthrough!(upstr) end end end |
#upstream ⇒ Object
34 35 36 |
# File 'lib/comuna/server.rb', line 34 def upstream RubyDNS::Resolver.new(@upstream_ifaces) end |