pdns-remotebackend 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +72 -0
- data/Rakefile +9 -0
- data/contrib/example.rb +124 -0
- data/lib/pdns/remotebackend/version.rb +5 -0
- data/lib/pdns/remotebackend.rb +184 -0
- data/pdns-remotebackend.gemspec +21 -0
- data/spec/lib/pdns_remotebackend_spec.rb +9 -0
- data/spec/spec_helper.rb +1 -0
- metadata +95 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Aki Tuomi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Pdns/Remotebackend
|
2
|
+
|
3
|
+
This is a helper for PowerDNS remotebackend. It lets you create a backend with less hassle.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'pdns-remotebackend'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install pdns-remotebackend
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Please see contrib/example.rb for example script. All methods and their arguments are described in detail at http://doc.powerdns.com/remotebackend.html. When your script
|
22
|
+
is called, the Handler class needs to have method with name do\_<name-of-method;gt;(args). Such as do\_lookup(args). Any arguments are passed as hash to your handler.
|
23
|
+
|
24
|
+
To get starting, subclass Pdns::Remotebackend::Handler. You need to override at least 'do\_lookup(args)' method. You are passed in arguments as
|
25
|
+
|
26
|
+
args = { "qname" => "www.example.com", "qtype" => "ANY|SOA", .. + other stuff }
|
27
|
+
|
28
|
+
You are expected to modify object attribute 'result' to contain an array of records. The easiest way is to do
|
29
|
+
|
30
|
+
result = [ record("www.example.com","A","127.0.01") ]
|
31
|
+
|
32
|
+
This will construct a reply array with one resource record.
|
33
|
+
|
34
|
+
Some methods expect non-array output, you can provide
|
35
|
+
|
36
|
+
result = true
|
37
|
+
result = { :foo => :bar }
|
38
|
+
|
39
|
+
If you wish to log something, use
|
40
|
+
|
41
|
+
log << "something I want logged".
|
42
|
+
|
43
|
+
Should you need some parameters passed to the remotebackend connection string, you can always have a look at @parameters, which contains them.
|
44
|
+
|
45
|
+
To start a pipe or unix server, do
|
46
|
+
|
47
|
+
Pdns::Remotebackend::Pipe.new(MyHandlerClass).run
|
48
|
+
Pdns::Remotebackend::Unix(MyHandlerClass, { :path => "/path/to/socket"} ).run
|
49
|
+
|
50
|
+
## Reference
|
51
|
+
|
52
|
+
In addition to stubs for remotebackend, the Pdns::Remotebackend::Handler has following helpers for making records
|
53
|
+
|
54
|
+
def record_prio_ttl(qtype,qname,content,prio,ttl,auth=1)
|
55
|
+
{:qtype => qtype, :qname => qname, :content => content, :priority => prio, :ttl => ttl, :auth => auth}
|
56
|
+
end
|
57
|
+
|
58
|
+
def record_prio(qtype,qname,content,prio,auth=1)
|
59
|
+
record_prio_ttl(qtype,qname,content,prio,@ttl,auth)
|
60
|
+
end
|
61
|
+
|
62
|
+
def record(qtype,qname,content,auth=1)
|
63
|
+
record_prio_ttl(qtype,qname,content,0,@ttl,auth)
|
64
|
+
end
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
1. Fork it
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/contrib/example.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'pdns/remotebackend'
|
5
|
+
|
6
|
+
## this is an example stub for remote backend
|
7
|
+
## to add more methods, just write
|
8
|
+
## def do_<methodname>(args)
|
9
|
+
## end
|
10
|
+
## look at the existing methods to find out
|
11
|
+
## how to customize this.
|
12
|
+
|
13
|
+
## WARNING: this contains some code that
|
14
|
+
## should never be used in production, but
|
15
|
+
## is provided to give a more comperehensive
|
16
|
+
## example code.
|
17
|
+
|
18
|
+
## Code provided only as example, not suitable
|
19
|
+
## for production.
|
20
|
+
|
21
|
+
## Usage:
|
22
|
+
## launch=remote
|
23
|
+
## remote-dnssec=yes
|
24
|
+
## remote-connection-string=pipe:command=/path/to/remote.rb,timeout=2000
|
25
|
+
|
26
|
+
class RequestHandler < Pdns::Remotebackend::Handler
|
27
|
+
## used to tell that we do NSEC3 NARROW
|
28
|
+
def do_getdomainmetadata(args)
|
29
|
+
if args["name"] == "example.com"
|
30
|
+
if args["kind"] == "NSEC3NARROW"
|
31
|
+
result = "1"
|
32
|
+
elsif args["kind"] == "NSEC3PARAM"
|
33
|
+
result = "1 1 1 fe"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
## returns keys, do not use in production
|
39
|
+
## you can use 'pdnssec generate-zone-key' to
|
40
|
+
## generate these
|
41
|
+
def do_getdomainkeys(args)
|
42
|
+
if args["name"] == "example.com"
|
43
|
+
result = [
|
44
|
+
{
|
45
|
+
"id" => 1,
|
46
|
+
"flags" => 257,
|
47
|
+
"active" => true,
|
48
|
+
"content" => "Private-key-format: v1.2
|
49
|
+
Algorithm: 8 (RSASHA256)
|
50
|
+
Modulus: ovvzf1fHdptdXsBrBLSqmGqdEKwR2B9st/KBgh8xQKoQzTGUG00CsPjF/J59IBU+EU/IIInMn0MxLLTyUKa2DJUkR6i7UKif5jKX1c7yvWzrFKLGOHjugUX2++r+o789biUte1qpWp3Kc2RYL18oPco4zpo6JcsPmhOK3aUCDJXmuWgHl1KudCQIiPkISArXVn4oOp+skQq+mUBl1Pysc4D+6sl77ERR2fW6xJ4ZRPOIKr445RJJmKgoMG8yRrR3it1RmV49hZlvMosQjBUoNcqhqOI0n4l8HOLyna7KIzoNKG62GtUCZh8uy8IjdUiWPYGEtkZ9zE0bnnF+R7HGvQ==
|
51
|
+
PublicExponent: AQAB
|
52
|
+
PrivateExponent: Lp/c3IUD7o4re7uX4dS9KLT3EZnn0OfMdiLNoafCszjzbX/NWrIBHxdLrCS6rr7k7pbgLU6+VqEmJB/vYdsPITJZGpbOXxieBYBbpzJ4hm/uIA0gn28Y66pUKWTkS3ud2zCPfkZFREL3c2M1Rvf1zxdWgOPl1oHsiKsmgpl9qJOSKHMWFC+m/pUMJ7iOMgyDRV+PNeb/8P1jVOAYyQMEnu+enw2ro2NiWXNikbnaWrIv3IxVZAyZG4/H8+1vfQFPDWztosOy7OhV3WyMJkfwcXrlGoyLlxyAgkh/jeCnmPllxlJZGTgCtoVYd/n8osMXCDKxpAhsfdfCPeNOcjocgQ==
|
53
|
+
Prime1: +T+s7wv+zVqONJqkAKw4OCVzxBc5FWrmDPcjPCUeKIK/K/3+XjmIqTlbvBKf+7rm+AGVnXAbqk90+jzE3mKI8HMG/rM2cx01986xNQsIqwi2VAt25huPhEyrtNzos6lmrCYaioaQnNpMvMLun3DvcaygkDUXxH7Dg+6BTHeUfnk=
|
54
|
+
Prime2: p2YbBveBK3XyGMuVrDH9CvvpgKEoko+mPwLoKNpBoHrGxeOdCQmlPbnr0GrtZpy4sBNc5+shz2c6c1J3GlgPndT7zi2+MFGfWIGV48SAknVLfOU4iUpaGllnxcbjZeytG6WHdy2RaR3ReeGvdWxmxeuv084c2zC/7/vkcmgOqWU=
|
55
|
+
Exponent1: EdVFeUEBdQ3imM7rpwSrbRD47HHA6tBgL1NLWRVKyBk6tloQ5gr1xS3Oa3FlsuwXdG0gmEgaIqBWvUS1zTd9lr6UJIsL/UZ8wwMt2J62ew4/hVngouwb45pcuq8HkzsulmiPg5PHKwHPdb34tr2s1BRG1KqHzc5IDNt2stLnc/k=
|
56
|
+
Exponent2: oT+Iv1BAu7WUa/AHj+RjJGZ+iaozo+H9uOq66Uc8OjKqMErNpLwG0Qu7rHqjjdlfSjSMpNXpLpj4Q8fm9JhpCpbzq6qCbpbhUGcbFFjfpLSZ74f5yr21R3ZhsLChsTenlF8Bu3pIfKH9e1M7KXgvE22xY+xB/Z3a9XeFmfLEVMU=
|
57
|
+
Coefficient: vG8tLZBE4s3bftN5INv2/o3knEcaoUAPfakSsjM2uLwQCGiUbBOOlp3QSdTU4MiLjDsza3fKIptdwYP9PvSkhGhtLPjBpKjRk1J1+sct3dfT66JPClJc1A8bLQPj4ZpO/BkJe6ji4HYfOp7Rjn9z8rTqwEfbP64CZV3/frUzIkQ="
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"id" => 2,
|
61
|
+
"flags" => 256,
|
62
|
+
"active" => true,
|
63
|
+
"content" => "Private-key-format: v1.2
|
64
|
+
Algorithm: 8 (RSASHA256)
|
65
|
+
Modulus: wKPNcDwkCd2DKxfdkMqTFOV2ITdgxIDaOd4vQ2QtphMBY9yYwmEkNsVdVFz7VVuQHdls20JUe+brFUhs1zEMMbokulFP/qVAItAeEWcqtkPULT+mmX5HsexpFVAZ5+UXuerObk/HMiIMt1CvkIWhmjSIkAI6dFRlf/93zTjy0+vwrNWZPXSzLccK5TfJmxdYdGPcsHkg6UmqEFPQuyZpmlmpg3IwjL5YddTDobAoABz/BrH7WsW0q/PyVubITo8JuFiBI5Fmw+3ef3PVUt1jtUCGASvtqNXW4wtWrgqvQKg/odthpceQ4QagV9XSlOdml527thnf9cMpm0Gh4Ox5HQ==
|
66
|
+
PublicExponent: AQAB
|
67
|
+
PrivateExponent: f+M+26fRdQstrUomuZ0Cj/jVt69/+nRga9JpJiA3fe1YGue0MjczR3k3QG6KHFyxDF/vuJAMbkUbBAIU37ecFNcy0s5wgOlL7tCjZYJMBLx6+58qBvSivCfqi0+mIyEf4zlS2kD0SP/52SkjpJpScoE1uAUCsX/l8lezPPb1nmH3RDwJwX1NVhsErHCAmxGDoj4nPCEhKgHkdbR0i8geXGdWR4slyq1EhuGJal4p5sNvzDQTYRy6r49rpbNHw9F7ojomIhTUCUjOXAX0X1HB5UTXRMpgpCNEjRG1a+aqxp/ZSMHSEGCv67fua5Qrd/qX1Ppns/oqZfCfTpTD3v/sMQ==
|
68
|
+
Prime1: +0zQuFi7rZDTMGMIKiF6UOG5+pKwGxHmgKPOGF6fk3tIuSomgiVD3DLz5Y6kYk0kKls6IiA6X2esYwNXAaLe0dyMzpAnU4URXhFW7fUnHP0zA7NmaFRYPHstPeU59/JS+zmVlj4Ok1oeGocSGAFYGxXa+Sot0fyCXpAjZboDWg8=
|
69
|
+
Prime2: xD4hprQmcn5gmLqYO9+nEEJTNyNccbAciiKjRJxIE7w6muuKESx0uUn5XdnzSxhbVkK16kkEqW3s+Y+VoLxwRj2fuvoPfx8nTQXY1esgcIZCG8ubvHW5T0bzee5gyX3cMvaxkoeM7euYgvh0UwR/FG910SwAlmMZjSwXay2YlhM=
|
70
|
+
Exponent1: 6vcWzNcCnDWmkT53WtU0hb2Y4+YVzSm+iRcf039d20rRY3g6y0NGoPPvQftOTi9smkH0KAZULfJEp8tupbQAfN6ntVfpvVjVNUwnKJUo/hzsfxBVt0Ttv5c4ZQAYZHHqDsX3zKO3gyUmso0KaPGQzLpxpLlAYG+mAf7paeszyRc=
|
71
|
+
Exponent2: ouvWMjk0Bi/ncETRqDuYzkXSIl+oGvaT6xawp4B70m6d1QohWPqoeT/x2Dne44R4J9hAgR5X0XXinJnZJlXrfFUi7C84eFhb33UwPQD0sJa2Aa97Pu4Zh7im4J7IGd/01Ra7+6Ovm8LRnkI5CMcd3dBfZuX6IuBpUSu+0YtMN6M=
|
72
|
+
Coefficient: 5lP9IFknvFgaXKCs8MproehHSFhFTWac4557HIn03KrnlGOKDcY6DC/vgu1e42bEZ4J0RU0EELp5u4tAEYcumIaIVhfzRsajYRGln2mHe6o6nTO+FbANKuhyVmBEvTVczPOcYLrFXKVTglKAs+8W96dYIMDhiAwxi9zijLKKQ1k="
|
73
|
+
}
|
74
|
+
]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
## Example lookup
|
79
|
+
## Returns SOA, MX, NS and A records for example.com
|
80
|
+
## also static A record for test.example.com
|
81
|
+
## and dynamic A record for anything else in example.com domain
|
82
|
+
def do_lookup(args)
|
83
|
+
if args["qname"] == "example.com" and args["qtype"].downcase == "soa"
|
84
|
+
result = [
|
85
|
+
record("SOA","example.com", "sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600"),
|
86
|
+
]
|
87
|
+
elsif args["qname"] == "example.com" and args["qtype"].downcase == "any"
|
88
|
+
result = [
|
89
|
+
record("SOA","example.com", "sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600"),
|
90
|
+
record("NS","example.com","sns.dns.icann.org"),
|
91
|
+
record_prio("MX","example.com","test.example.com",10)
|
92
|
+
]
|
93
|
+
elsif args["qname"] == "test.example.com" and args["qtype"].downcase == "any"
|
94
|
+
result = [
|
95
|
+
record("A","test.example.com","127.0.0.1")
|
96
|
+
]
|
97
|
+
elsif args["qname"] =~ /(.*)\.example\.com$/ and args["qtype"].downcase == "any"
|
98
|
+
ip = 0
|
99
|
+
$1.downcase.each_byte do |b| ip = ip + b end
|
100
|
+
ip_2 = ip/256
|
101
|
+
ip = ip%256
|
102
|
+
result = [
|
103
|
+
record("A",args["qname"], "127.0.#{ip_2}.#{ip}")
|
104
|
+
]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
## AXFR support
|
109
|
+
## Do note that having AXFR here is somewhat stupid since
|
110
|
+
## we generate records above. But it is still included
|
111
|
+
## for sake of having an example. Do not do ths in production.
|
112
|
+
def do_list(args)
|
113
|
+
if args["zonename"] == "example.com"
|
114
|
+
result = [
|
115
|
+
record("SOA","example.com", "sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600"),
|
116
|
+
record("NS","example.com","sns.dns.icann.org"),
|
117
|
+
record_prio("MX","example.com","test.example.com",10),
|
118
|
+
record("A","test.example.com","127.0.0.1")
|
119
|
+
]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
Pdns::Remotebackend::Pipe.new(RequestHandler).run
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'json'
|
3
|
+
require 'pdns/remotebackend/version'
|
4
|
+
|
5
|
+
module Pdns
|
6
|
+
module Remotebackend
|
7
|
+
class Handler
|
8
|
+
attr_accessor :log, :result, :ttl
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@log = []
|
12
|
+
@result = false
|
13
|
+
@ttl = 300
|
14
|
+
@params = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def record_prio_ttl(qtype,qname,content,prio,ttl,auth=1)
|
18
|
+
{:qtype => qtype, :qname => qname, :content => content, :priority => prio, :ttl => ttl, :auth => auth}
|
19
|
+
end
|
20
|
+
|
21
|
+
def record_prio(qtype,qname,content,prio,auth=1)
|
22
|
+
record_prio_ttl(qtype,qname,content,prio,@ttl,auth)
|
23
|
+
end
|
24
|
+
|
25
|
+
def record(qtype,qname,content,auth=1)
|
26
|
+
record_prio_ttl(qtype,qname,content,0,@ttl,auth)
|
27
|
+
end
|
28
|
+
|
29
|
+
def do_initialize(args)
|
30
|
+
@params = args
|
31
|
+
@log << "PowerDNS ruby remotebackend version #{Pdns::Remotebackend::VERSION} initialized"
|
32
|
+
@result = true
|
33
|
+
end
|
34
|
+
|
35
|
+
def do_lookup(args)
|
36
|
+
end
|
37
|
+
|
38
|
+
def do_list(args)
|
39
|
+
end
|
40
|
+
|
41
|
+
def do_getdomainmetadata(args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def do_setdomainmetadata(args)
|
45
|
+
end
|
46
|
+
|
47
|
+
def do_adddomainkey(args)
|
48
|
+
end
|
49
|
+
|
50
|
+
def do_getdomainkeys(args)
|
51
|
+
end
|
52
|
+
|
53
|
+
def do_activatedomainkey(args)
|
54
|
+
end
|
55
|
+
|
56
|
+
def do_deactivatedomainkey(args)
|
57
|
+
end
|
58
|
+
|
59
|
+
def do_removedomainkey(args)
|
60
|
+
end
|
61
|
+
|
62
|
+
def do_getbeforeandafternamesabsolute(args)
|
63
|
+
end
|
64
|
+
|
65
|
+
def do_gettsigkey(args)
|
66
|
+
end
|
67
|
+
|
68
|
+
def do_setnotified(args)
|
69
|
+
end
|
70
|
+
|
71
|
+
def do_getdomaininfo(args)
|
72
|
+
end
|
73
|
+
|
74
|
+
def do_supermasterbackend(args)
|
75
|
+
end
|
76
|
+
|
77
|
+
def do_createslavedomain(args)
|
78
|
+
end
|
79
|
+
|
80
|
+
def do_feedrecord(args)
|
81
|
+
end
|
82
|
+
|
83
|
+
def do_replacerrset(args)
|
84
|
+
end
|
85
|
+
|
86
|
+
def do_feedents(args)
|
87
|
+
end
|
88
|
+
|
89
|
+
def do_feedents3(args)
|
90
|
+
end
|
91
|
+
|
92
|
+
def do_settsigkey(args)
|
93
|
+
end
|
94
|
+
|
95
|
+
def do_deletetsigkey(args)
|
96
|
+
end
|
97
|
+
|
98
|
+
def do_gettsigkeys(*args)
|
99
|
+
end
|
100
|
+
|
101
|
+
def do_starttransaction(args)
|
102
|
+
end
|
103
|
+
|
104
|
+
def do_committransaction(args)
|
105
|
+
end
|
106
|
+
|
107
|
+
def do_aborttransaction(args)
|
108
|
+
end
|
109
|
+
|
110
|
+
def do_calculatesoaserial(args)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class Connector
|
115
|
+
def initialize(klass, options = {})
|
116
|
+
@handler = klass
|
117
|
+
@options = options
|
118
|
+
end
|
119
|
+
|
120
|
+
def open
|
121
|
+
[STDIN,STDOUT]
|
122
|
+
end
|
123
|
+
|
124
|
+
def close
|
125
|
+
end
|
126
|
+
|
127
|
+
def mainloop
|
128
|
+
h = @handler.new
|
129
|
+
reader,writer = self.open
|
130
|
+
|
131
|
+
begin
|
132
|
+
reader.each_line do |line|
|
133
|
+
# expect json
|
134
|
+
input = {}
|
135
|
+
line = line.strip
|
136
|
+
next if line.empty?
|
137
|
+
begin
|
138
|
+
input = JSON.parse(line)
|
139
|
+
method = "do_#{input["method"].downcase}"
|
140
|
+
args = input["parameters"] || []
|
141
|
+
|
142
|
+
h.result = false
|
143
|
+
h.log = []
|
144
|
+
|
145
|
+
if h.respond_to?(method.to_sym) == false
|
146
|
+
res = false
|
147
|
+
elsif args.size > 0
|
148
|
+
h.send(method,args)
|
149
|
+
else
|
150
|
+
h.send(method)
|
151
|
+
end
|
152
|
+
|
153
|
+
writer.puts ({:result => h.result, :log => h.log}).to_json
|
154
|
+
rescue JSON::ParserError
|
155
|
+
writer.puts ({:result => false, :log => "Cannot parse input #{line}"}).to_json
|
156
|
+
next
|
157
|
+
end
|
158
|
+
end
|
159
|
+
rescue SystemExit, Interrupt
|
160
|
+
end
|
161
|
+
self.close
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
class Pipe
|
167
|
+
def run
|
168
|
+
mainloop
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
class Unix
|
173
|
+
def run
|
174
|
+
@path = options[:path] || "/tmp/remotebackend.sock"
|
175
|
+
Socket.unix_server_loop(@path) do |sock, client_addrinfo|
|
176
|
+
begin
|
177
|
+
mainloop sock, sock
|
178
|
+
ensure
|
179
|
+
sock.close
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/pdns/remotebackend/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Aki Tuomi"]
|
6
|
+
gem.email = ["cmouse@desteem.org"]
|
7
|
+
gem.description = %q{This gem provides a base class and helpers for writing remotebackend servers for pipe/unix/. It is intended to make using remotebackend easier. For http support, see pdns-remotebackend-http.}
|
8
|
+
gem.summary = %q{This gem provides a base class and helpers for writing remotebackend servers for pipe/unix/http post/json modes}
|
9
|
+
gem.homepage = "http://github.com/cmouse/pdns-remotebackend"
|
10
|
+
gem.license = "MIT"
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "pdns-remotebackend"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Pdns::Remotebackend::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rake'
|
19
|
+
gem.add_development_dependency 'rspec'
|
20
|
+
gem.add_runtime_dependency 'json'
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'pdns/remotebackend'
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pdns-remotebackend
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Aki Tuomi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &6278620 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *6278620
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &6278200 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *6278200
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: json
|
38
|
+
requirement: &6277780 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *6277780
|
47
|
+
description: This gem provides a base class and helpers for writing remotebackend
|
48
|
+
servers for pipe/unix/. It is intended to make using remotebackend easier. For http
|
49
|
+
support, see pdns-remotebackend-http.
|
50
|
+
email:
|
51
|
+
- cmouse@desteem.org
|
52
|
+
executables: []
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- contrib/example.rb
|
62
|
+
- lib/pdns/remotebackend.rb
|
63
|
+
- lib/pdns/remotebackend/version.rb
|
64
|
+
- pdns-remotebackend.gemspec
|
65
|
+
- spec/lib/pdns_remotebackend_spec.rb
|
66
|
+
- spec/spec_helper.rb
|
67
|
+
homepage: http://github.com/cmouse/pdns-remotebackend
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.8.11
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: This gem provides a base class and helpers for writing remotebackend servers
|
92
|
+
for pipe/unix/http post/json modes
|
93
|
+
test_files:
|
94
|
+
- spec/lib/pdns_remotebackend_spec.rb
|
95
|
+
- spec/spec_helper.rb
|