Class: PowerDNS::Pipe

Inherits:
Object
  • Object
show all
Defined in:
lib/powerdns_pipe.rb

Overview

DnsPipe is an abstraction of the Powerdns pipe backend protocol. doc.powerdns.com/backends-detail.html

It’s dead simple to use, see the README for examples

Written by John Leach <[email protected]>

Defined Under Namespace

Classes: Answer, Question

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Pipe

Returns a new instance of Pipe.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/powerdns_pipe.rb', line 45

def initialize(options = {})
  options = { 
    :input => STDIN,
    :output => STDOUT,
    :err => STDERR,
    :version_range => 1..2,
    :banner => "Ruby PowerDNS::Pipe"
  }.merge options

  @input = options[:input]
  @output = options[:output]
  @err = options[:err]
  @version_range = options[:version_range]
  @banner = options[:banner]
end

Instance Attribute Details

Returns the value of attribute banner.



11
12
13
# File 'lib/powerdns_pipe.rb', line 11

def banner
  @banner
end

#errObject (readonly)

Returns the value of attribute err.



11
12
13
# File 'lib/powerdns_pipe.rb', line 11

def err
  @err
end

#inputObject (readonly)

Returns the value of attribute input.



11
12
13
# File 'lib/powerdns_pipe.rb', line 11

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



11
12
13
# File 'lib/powerdns_pipe.rb', line 11

def output
  @output
end

#version_rangeObject (readonly)

Returns the value of attribute version_range.



11
12
13
# File 'lib/powerdns_pipe.rb', line 11

def version_range
  @version_range
end

Instance Method Details

#answer(options = {}) ⇒ Object



69
70
71
72
73
74
75
76
77
# File 'lib/powerdns_pipe.rb', line 69

def answer(options = {})
  options = {
    :ttl => 3600,
    :id => -1,
    :class => 'IN'
  }.merge options

  respond "DATA", options[:name], options[:class], options[:type], options[:ttl], options[:id], options[:content]
end

#run!(&query_processor) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/powerdns_pipe.rb', line 61

def run!(&query_processor)
  while (line = input.readline) do
    process_line line, query_processor
  end
rescue EOFError
  err.write "EOF, terminating loop\n"
end