From: Kees Monshouwer Date: Sun, 17 Aug 2014 19:11:29 +0000 (+0200) Subject: remove priority in remote backend X-Git-Tag: rec-3.7.0-rc1~189^2~5^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf152979b48453b3e4abe560a238eac4af0cf5e2;p=pdns remove priority in remote backend --- diff --git a/modules/remotebackend/example.rb b/modules/remotebackend/example.rb index 777d31dc9..f93e86c6a 100644 --- a/modules/remotebackend/example.rb +++ b/modules/remotebackend/example.rb @@ -110,7 +110,7 @@ Coefficient: 5lP9IFknvFgaXKCs8MproehHSFhFTWac4557HIn03KrnlGOKDcY6DC/vgu1e42bEZ4J return [ record("SOA","example.com", "sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600"), record("NS","example.com","sns.dns.icann.org"), - record_prio("MX","example.com","test.example.com",10) + record("MX","example.com","10 test.example.com") ] elsif args["qname"] == "test.example.com" and args["qtype"].downcase == "any" return [ @@ -137,7 +137,7 @@ Coefficient: 5lP9IFknvFgaXKCs8MproehHSFhFTWac4557HIn03KrnlGOKDcY6DC/vgu1e42bEZ4J return [ record("SOA","example.com", "sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600"), record("NS","example.com","sns.dns.icann.org"), - record_prio("MX","example.com","test.example.com",10), + record("MX","example.com","10 test.example.com"), record("A","test.example.com","127.0.0.1") ] end @@ -149,16 +149,12 @@ Coefficient: 5lP9IFknvFgaXKCs8MproehHSFhFTWac4557HIn03KrnlGOKDcY6DC/vgu1e42bEZ4J ## Some helpers after this - def record_prio_ttl(qtype,qname,content,prio,ttl) - {:qtype => qtype, :qname => qname, :content => content, :priority => prio, :ttl => ttl, :auth => 1} - end - - def record_prio(qtype,qname,content,prio) - record_prio_ttl(qtype,qname,content,prio,@default_ttl) + def record_ttl(qtype,qname,content,ttl) + {:qtype => qtype, :qname => qname, :content => content, :ttl => ttl, :auth => 1} end def record(qtype,qname,content) - record_prio_ttl(qtype,qname,content,0,@default_ttl) + record_ttl(qtype,qname,content,@default_ttl,) end def log(message) diff --git a/modules/remotebackend/regression-tests/backend.rb b/modules/remotebackend/regression-tests/backend.rb index c81e2609f..d221a7edb 100755 --- a/modules/remotebackend/regression-tests/backend.rb +++ b/modules/remotebackend/regression-tests/backend.rb @@ -4,8 +4,8 @@ require 'rubygems' require 'json' require 'sqlite3' -def rr(qname, qtype, content, ttl, priority = 0, auth = 1, domain_id = -1) - {:qname => qname, :qtype => qtype, :content => content, :ttl => ttl.to_i, :priority => priority.to_i, :auth => auth.to_i, :domain_id => domain_id.to_i} +def rr(qname, qtype, content, ttl, auth = 1, domain_id = -1) + {:qname => qname, :qtype => qtype, :content => content, :ttl => ttl.to_i, :auth => auth.to_i, :domain_id => domain_id.to_i} end class Handler @@ -95,7 +95,11 @@ class Handler end end db.execute(sql, sargs) do |row| - ret << rr(row[1], row[2], row[3], row[4], row[5], row[6], row[0]) + if (row[2] == "MX" || row[2] == "SRV") + ret << rr(row[1], row[2], row[5]+" "+row[3], row[4], row[6], row[0]) + else + ret << rr(row[1], row[2], row[3], row[4], row[6], row[0]) + end end rescue Exception => e e.backtrace @@ -126,7 +130,11 @@ class Handler d_id = db.get_first_value("SELECT id FROM domains WHERE name = ?", target) return false if d_id.nil? db.execute("SELECT domain_id,name,type,content,ttl,prio,auth FROM records WHERE domain_id = ?", d_id) do |row| - ret << rr(row[1], row[2], row[3], row[4], row[5], row[6], row[0]) + if (row[2] == "MX" || row[2] == "SRV") + ret << rr(row[1], row[2], row[5]+" "+row[3], row[4], row[6], row[0]) + else + ret << rr(row[1], row[2], row[3], row[4], row[6], row[0]) + end end rescue Exception => e e.backtrace diff --git a/modules/remotebackend/regression-tests/basic-aaaa-resolution/tmp.rb b/modules/remotebackend/regression-tests/basic-aaaa-resolution/tmp.rb index 3cbe47735..bec7f929f 100644 --- a/modules/remotebackend/regression-tests/basic-aaaa-resolution/tmp.rb +++ b/modules/remotebackend/regression-tests/basic-aaaa-resolution/tmp.rb @@ -8,8 +8,8 @@ def from32(str) str.tr("ybndrfg8ejkmcpqxot1uwisza345h769", "0123456789abcdefghijklmnopqrstuv").to_i(32) end -def rr(qname, qtype, content, ttl, priority = 0, auth = 1) - {:qname => qname, :qtype => qtype, :content => content, :ttl => ttl, :priority => priority, :auth => auth} +def rr(qname, qtype, content, ttl, auth = 1) + {:qname => qname, :qtype => qtype, :content => content, :ttl => ttl, :auth => auth} end def send_result(*params) diff --git a/modules/remotebackend/regression-tests/long-txt-resolution/tmp.rb b/modules/remotebackend/regression-tests/long-txt-resolution/tmp.rb index 3cbe47735..bec7f929f 100644 --- a/modules/remotebackend/regression-tests/long-txt-resolution/tmp.rb +++ b/modules/remotebackend/regression-tests/long-txt-resolution/tmp.rb @@ -8,8 +8,8 @@ def from32(str) str.tr("ybndrfg8ejkmcpqxot1uwisza345h769", "0123456789abcdefghijklmnopqrstuv").to_i(32) end -def rr(qname, qtype, content, ttl, priority = 0, auth = 1) - {:qname => qname, :qtype => qtype, :content => content, :ttl => ttl, :priority => priority, :auth => auth} +def rr(qname, qtype, content, ttl, auth = 1) + {:qname => qname, :qtype => qtype, :content => content, :ttl => ttl, :auth => auth} end def send_result(*params) diff --git a/modules/remotebackend/remotebackend.cc b/modules/remotebackend/remotebackend.cc index 75a61d8d5..ba1ecab62 100644 --- a/modules/remotebackend/remotebackend.cc +++ b/modules/remotebackend/remotebackend.cc @@ -244,7 +244,6 @@ bool RemoteBackend::get(DNSResourceRecord &rr) { value = -1; rr.ttl = getInt(JSON_GET((*d_result)["result"][d_index], "ttl",value)); rr.domain_id = getInt(JSON_GET((*d_result)["result"][d_index],"domain_id",value)); - rr.priority = getInt(JSON_GET((*d_result)["result"][d_index],"priority",value)); value = 1; if (d_dnssec) rr.auth = getInt(JSON_GET((*d_result)["result"][d_index],"auth", value)); @@ -699,7 +698,6 @@ bool RemoteBackend::superMasterBackend(const string &ip, const string &domain, c JSON_ADD_MEMBER(rr, "qclass", QClass::IN, query.GetAllocator()); JSON_ADD_MEMBER(rr, "content", nsset[i].content.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rr, "ttl", nsset[i].ttl, query.GetAllocator()); - JSON_ADD_MEMBER(rr, "priority", nsset[i].priority, query.GetAllocator()); JSON_ADD_MEMBER(rr, "auth", nsset[i].auth, query.GetAllocator()); rrset.PushBack(rr, query.GetAllocator()); } @@ -760,7 +758,6 @@ bool RemoteBackend::replaceRRSet(uint32_t domain_id, const string& qname, const JSON_ADD_MEMBER(rr, "qclass", QClass::IN, query.GetAllocator()); JSON_ADD_MEMBER(rr, "content", rrset[i].content.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rr, "ttl", rrset[i].ttl, query.GetAllocator()); - JSON_ADD_MEMBER(rr, "priority", rrset[i].priority, query.GetAllocator()); JSON_ADD_MEMBER(rr, "auth", rrset[i].auth, query.GetAllocator()); rj_rrset.PushBack(rr, query.GetAllocator()); } @@ -785,7 +782,6 @@ bool RemoteBackend::feedRecord(const DNSResourceRecord &rr, string *ordername) { JSON_ADD_MEMBER(rj_rr, "qclass", QClass::IN, query.GetAllocator()); JSON_ADD_MEMBER(rj_rr, "content", rr.content.c_str(), query.GetAllocator()); JSON_ADD_MEMBER(rj_rr, "ttl", rr.ttl, query.GetAllocator()); - JSON_ADD_MEMBER(rj_rr, "priority", rr.priority, query.GetAllocator()); JSON_ADD_MEMBER(rj_rr, "auth", rr.auth, query.GetAllocator()); parameters.AddMember("rr", rj_rr, query.GetAllocator()); diff --git a/modules/remotebackend/unittest.rb b/modules/remotebackend/unittest.rb index a5aac4425..9bc29dd97 100644 --- a/modules/remotebackend/unittest.rb +++ b/modules/remotebackend/unittest.rb @@ -33,8 +33,8 @@ class Handler def initialize end - def rr(qname, qtype, content, ttl, priority = 0, auth = 1, domain_id = -1) - {:qname => qname, :qtype => qtype, :content => content, :ttl => ttl.to_i, :priority => priority.to_i, :auth => auth.to_i, :domain_id => domain_id.to_i} + def rr(qname, qtype, content, ttl, auth = 1, domain_id = -1) + {:qname => qname, :qtype => qtype, :content => content, :ttl => ttl.to_i, :auth => auth.to_i, :domain_id => domain_id.to_i} end def do_initialize(*args)