]> granicus.if.org Git - pdns/commitdiff
add priority to content for MX and SRV records
authorKees Monshouwer <mind04@monshouwer.org>
Sun, 17 Aug 2014 13:03:06 +0000 (15:03 +0200)
committermind04 <mind04@monshouwer.org>
Mon, 13 Oct 2014 22:08:56 +0000 (00:08 +0200)
24 files changed:
modules/bindbackend/bindbackend2.cc
modules/bindbackend/bindbackend2.hh
modules/ldapbackend/ldapbackend.cc
modules/lmdbbackend/lmdbbackend.cc
modules/mydnsbackend/mydnsbackend.cc
modules/opendbxbackend/odbxbackend.cc
modules/oraclebackend/oraclebackend.cc
modules/pipebackend/pipebackend.cc
modules/tinydnsbackend/tinydnsbackend.cc
pdns/backends/gsql/gsqlbackend.cc
pdns/dns.hh
pdns/dnspacket.cc
pdns/dnsproxy.cc
pdns/dnsrecords.cc
pdns/dnssecsigner.cc
pdns/lua-auth.cc
pdns/packethandler.cc
pdns/pdnssec.cc
pdns/resolver.cc
pdns/signingpipe.cc
pdns/ws-auth.cc
pdns/zone2json.cc
pdns/zone2ldap.cc
pdns/zone2sql.cc

index f5ef1dbeba6a097042d7a732565089fbe9ac7e61..392503d6dabbdad2b1fbe5fc016a5253c0da957c 100644 (file)
@@ -266,15 +266,7 @@ bool Bind2Backend::feedRecord(const DNSResourceRecord &r, string *ordername)
   // SOA needs stripping too! XXX FIXME - also, this should not be here I think
   switch(r.qtype.getCode()) {
   case QType::MX:
-    if(!stripDomainSuffix(&content, domain))
-      content+=".";
-    *d_of<<qname<<"\t"<<r.ttl<<"\t"<<r.qtype.getName()<<"\t"<<r.priority<<"\t"<<content<<endl;
-    break;
   case QType::SRV:
-    if(!stripDomainSuffix(&content, domain))
-      content+=".";
-    *d_of<<qname<<"\t"<<r.ttl<<"\t"<<r.qtype.getName()<<"\t"<<r.priority<<"\t"<<content<<endl;
-    break;
   case QType::CNAME:
   case QType::NS:
     if(!stripDomainSuffix(&content, domain))
@@ -460,7 +452,7 @@ void Bind2Backend::parseZoneFile(BB2DomainInfo *bbd)
       else
         hashed="";
     }
-    insertRecord(*bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed);
+    insertRecord(*bbd, rr.qname, rr.qtype, rr.content, rr.ttl, hashed);
   }
   fixupAuth(bbd->d_records.getWRITABLE());
   doEmptyNonTerminals(*bbd, nsec3zone, ns3pr);
@@ -472,7 +464,7 @@ void Bind2Backend::parseZoneFile(BB2DomainInfo *bbd)
 
 /** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedance matching
     Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */
-void Bind2Backend::insertRecord(BB2DomainInfo& bb2, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed, bool *auth)
+void Bind2Backend::insertRecord(BB2DomainInfo& bb2, const string &qnameu, const QType &qtype, const string &content, int ttl, const std::string& hashed, bool *auth)
 {
   Bind2DNSRecord bdr;
   shared_ptr<recordstorage_t> records = bb2.d_records.getWRITABLE();
@@ -507,20 +499,10 @@ void Bind2Backend::insertRecord(BB2DomainInfo& bb2, const string &qnameu, const
   else
     bdr.auth=true;
 
-  if(bdr.qtype == QType::MX || bdr.qtype == QType::SRV) { 
-    prio=atoi(bdr.content.c_str());
-    
-    string::size_type pos = bdr.content.find_first_not_of("0123456789");
-    if(pos != string::npos)
-      boost::erase_head(bdr.content, pos);
-    trim_left(bdr.content);
-  }
-  
   if(bdr.qtype==QType::CNAME || bdr.qtype==QType::MX || bdr.qtype==QType::NS || bdr.qtype==QType::AFSDB)
     bdr.content=toLowerCanonic(bdr.content); // I think this is wrong, the zoneparser should not come up with . terminated stuff XXX FIXME
 
   bdr.ttl=ttl;
-  bdr.priority=prio;  
   records->insert(bdr);
 }
 
@@ -728,14 +710,13 @@ void Bind2Backend::doEmptyNonTerminals(BB2DomainInfo& bbd, bool nsec3zone, NSEC3
   rr.qtype="#0";
   rr.content="";
   rr.ttl=0;
-  rr.priority=0;
   pair<string, bool> nt;
   BOOST_FOREACH(nt, nonterm)
   {
     rr.qname=nt.first+"."+bbd.d_name+".";
     if(nsec3zone)
       hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname));
-    insertRecord(bbd, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed, &nt.second);
+    insertRecord(bbd, rr.qname, rr.qtype, rr.content, rr.ttl, hashed, &nt.second);
   }
 }
 
@@ -1133,7 +1114,7 @@ bool Bind2Backend::get(DNSResourceRecord &r)
     return false;
   }
   if(d_handle.mustlog)
-    L<<Logger::Warning<<"Returning: '"<<r.qtype.getName()<<"' of '"<<r.qname<<"', content: '"<<r.content<<"', prio: "<<r.priority<<endl;
+    L<<Logger::Warning<<"Returning: '"<<r.qtype.getName()<<"' of '"<<r.qname<<"', content: '"<<r.content<<"'"<<endl;
   return true;
 }
 
@@ -1177,7 +1158,6 @@ bool Bind2Backend::handle::get_normal(DNSResourceRecord &r)
   //  r.domain_id=(d_iter)->domain_id;
   r.qtype=(d_iter)->qtype;
   r.ttl=(d_iter)->ttl;
-  r.priority=(d_iter)->priority;
 
   //if(!d_iter->auth && r.qtype.getCode() != QType::A && r.qtype.getCode()!=QType::AAAA && r.qtype.getCode() != QType::NS)
   //  cerr<<"Warning! Unauth response for qtype "<< r.qtype.getName() << " for '"<<r.qname<<"'"<<endl;
@@ -1215,7 +1195,6 @@ bool Bind2Backend::handle::get_list(DNSResourceRecord &r)
     r.content=(d_qname_iter)->content;
     r.qtype=(d_qname_iter)->qtype;
     r.ttl=(d_qname_iter)->ttl;
-    r.priority=(d_qname_iter)->priority;
     r.auth = d_qname_iter->auth;
     d_qname_iter++;
     return true;
index 8666a702a46ced0fed76aa19f9224c67fe787df5..9ced301b998430477af2b3a7d0b29834dda5866b 100644 (file)
@@ -53,8 +53,7 @@ struct Bind2DNSRecord
   string nsec3hash;
   uint32_t ttl;
   uint16_t qtype;
-  uint16_t priority;
-  mutable bool auth; 
+  mutable bool auth;
   bool operator<(const Bind2DNSRecord& rhs) const
   {
     if(qname < rhs.qname)
@@ -226,7 +225,7 @@ public:
   static pthread_rwlock_t s_state_lock;
 
   void parseZoneFile(BB2DomainInfo *bbd);
-  void insertRecord(BB2DomainInfo& bbd, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string(), bool *auth=0);
+  void insertRecord(BB2DomainInfo& bbd, const string &qname, const QType &qtype, const string &content, int ttl, const std::string& hashed=string(), bool *auth=0);
   void rediscover(string *status=0);
 
   bool isMaster(const string &name, const string &ip);
index 57d9899dae6ba9dcdd2bec5e638f2e23faae31cf..137804f6b7741e9213b17ce82e0c97a298175e01 100644 (file)
@@ -400,7 +400,7 @@ bool LdapBackend::get( DNSResourceRecord &rr )
 {
         QType qt;
         vector<string> parts;
-        string attrname, content, qstr;
+        string attrname, qstr;
 
 
         try
@@ -417,41 +417,15 @@ bool LdapBackend::get( DNSResourceRecord &rr )
 
                                        while( m_value != m_attribute->second.end() )
                                        {
-                                               content = *m_value;
 
                                                rr.qtype = qt;
                                                rr.qname = *m_adomain;
-                                               rr.priority = 0;
                                                rr.ttl = m_ttl;
                                                rr.last_modified = m_last_modified;
-
-                                               if( qt.getCode() == QType::MX || qt.getCode() == QType::SRV )   // Priority, e.g. 10 smtp.example.com
-                                               {
-                                                       char* endptr;
-                                                       string::size_type first = content.find_first_of( " " );
-
-                                                       if( first == string::npos )
-                                                       {
-                                                               L << Logger::Warning << m_myname << " Invalid " << attrname << " without priority for " << m_qname << ": " << content << endl;
-                                                               m_value++;
-                                                               continue;
-                                                       }
-
-                                                       rr.priority = (uint16_t) strtoul( (content.substr( 0, first )).c_str(), &endptr, 10 );
-                                                       if( *endptr != '\0' )
-                                                       {
-                                                               L << Logger::Warning << m_myname << " Invalid " << attrname << " without priority for " << m_qname << ": " << content << endl;
-                                                               m_value++;
-                                                               continue;
-                                                       }
-
-                                                       content = content.substr( first + 1, content.length() - first - 1 );
-                                               }
-
-                                               rr.content = content;
+                                               rr.content = *m_value;
                                                m_value++;
 
-                                               DLOG( L << Logger::Debug << m_myname << " Record = qname: " << rr.qname << ", qtype: " << (rr.qtype).getName() << ", priority: " << rr.priority << ", ttl: " << rr.ttl << ", content: " << rr.content << endl );
+                                               DLOG( L << Logger::Debug << m_myname << " Record = qname: " << rr.qname << ", qtype: " << (rr.qtype).getName() << ", ttl: " << rr.ttl << ", content: " << rr.content << endl );
                                                return true;
                                        }
 
index e8a623310acc1704356f3bf3deac7dad96fd566b..b6411d29a3fa97e9d29113c805ea7f8ae39977ca 100644 (file)
@@ -519,16 +519,7 @@ next_record:
 
     rr.domain_id = domain_id;
     rr.ttl = atoi( valparts[1].c_str() );
-
-    if( rr.qtype.getCode() != QType::MX && rr.qtype.getCode() != QType::SRV )
-        rr.content = valparts[2];
-    else {
-        // split out priority field
-        string::size_type pos = valparts[2].find_first_of(" ", 0);
-
-        rr.priority = atoi( valparts[2].substr(0, pos).c_str() );
-        rr.content = valparts[2].substr(pos+1, valparts[2].length());
-    }
+    rr.content = valparts[2];
 
     return true;
 }
index 0237d1f9fb4515e736dd93ee339d283c373bfe14..bd9acaa72c48324edd8bf7f69b2c67dd3416dd04 100644 (file)
@@ -324,7 +324,8 @@ bool MyDNSBackend::get(DNSResourceRecord &rr) {
                }
         }
 
-        rr.priority = atol(rrow[2].c_str());
+        if (rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV)
+          rr.content=rrow[2]+" "+rr.content;
         rr.ttl = atol(rrow[3].c_str());
         if (d_useminimalttl && rr.ttl < d_minimum)
                rr.ttl = d_minimum;
index 3b5a5f4681188be7969d800772e7c1353d5c1c72..80df4debfe80e1aae222f2043a36517ec9bec284 100644 (file)
@@ -340,7 +340,7 @@ void OdbxBackend::lookup( const QType& qtype, const string& qname, DNSPacket* dn
 bool OdbxBackend::get( DNSResourceRecord& rr )
 {
         const char* tmp;
-
+        string priority;
 
         try
         {
@@ -348,8 +348,8 @@ bool OdbxBackend::get( DNSResourceRecord& rr )
 
                if( getRecord( READ ) )
                {
+
                        rr.content = "";
-                       rr.priority = 0;
                        rr.domain_id = 0;
                        rr.last_modified = 0;
                        rr.ttl = m_default_ttl;
@@ -377,7 +377,7 @@ bool OdbxBackend::get( DNSResourceRecord& rr )
 
                        if( ( tmp = odbx_field_value( m_result, 4 ) ) != NULL )
                        {
-                               rr.priority = (uint16_t) strtoul( tmp, NULL, 10 );
+                               priority = string( tmp, odbx_field_length( m_result, 4 ) );
                        }
 
                        if( ( tmp = odbx_field_value( m_result, 5 ) ) != NULL )
@@ -385,6 +385,9 @@ bool OdbxBackend::get( DNSResourceRecord& rr )
                                rr.content = string( tmp, odbx_field_length( m_result, 5 ) );
                        }
 
+                       if (rr.qtype==QType::MX || rr.qtype==QType::SRV)
+                               rr.content = priority + " " + rr.content;
+
                        return true;
                }
         }
@@ -659,9 +662,22 @@ bool OdbxBackend::feedRecord( const DNSResourceRecord& rr, string *ordername )
                }
 
                string tmp = rr.qname;
+
+               int priority=0;
+               string content(rr.content);
+
+               if(rr.qtype == QType::MX || rr.qtype == QType::SRV) {
+                       priority=atoi(content.c_str());
+
+                       string::size_type pos = content.find_first_not_of("0123456789");
+                       if(pos != string::npos)
+                               boost::erase_head(content, pos);
+                       trim_left(content);
+               }
+
                int len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-insert-record" ).c_str(), rr.domain_id,
-                       escape( toLowerByRef( tmp ), WRITE ).c_str(), rr.qtype.getName().c_str(), rr.ttl, rr.priority,
-                       escape( rr.content, WRITE ).c_str() );
+                       escape( toLowerByRef( tmp ), WRITE ).c_str(), rr.qtype.getName().c_str(), rr.ttl, priority,
+                       escape( content, WRITE ).c_str() );
 
                if( len < 0 )
                {
index 5020cf9dc6cf9a8cda480c53cf211372eed58935..2c4305565af1862a4493a0e55a4f63aad5a5de2c 100644 (file)
@@ -1071,7 +1071,6 @@ OracleBackend::feedRecord (const DNSResourceRecord &rr, string *ordername)
   OCIStmt *stmt;
 
   uint32_t ttl;
-  char content[4001];
 
   stmt = prepare_query(masterSvcCtx, insertRecordQuerySQL, insertRecordQueryKey);
   bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName));
@@ -1079,17 +1078,13 @@ OracleBackend::feedRecord (const DNSResourceRecord &rr, string *ordername)
   bind_str(stmt, ":name", mQueryName, sizeof(mQueryName));
   bind_str(stmt, ":type", mQueryType, sizeof(mQueryType));
   bind_uint32(stmt, ":ttl", &ttl);
-  bind_str(stmt, ":content", content, sizeof(content));
+  bind_str(stmt, ":content", mQueryContent, sizeof(mQueryContent));
 
   mQueryZoneId = rr.domain_id;
   string_to_cbuf(mQueryName, rr.qname, sizeof(mQueryName));
   ttl = rr.ttl;
   string_to_cbuf(mQueryType, rr.qtype.getName(), sizeof(mQueryType));
-  if (rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV) {
-    snprintf(content, sizeof(content), "%d %s", rr.priority, rr.content.c_str());
-  } else {
-    string_to_cbuf(content, rr.content, sizeof(content));
-  }
+  string_to_cbuf(mQueryContent, rr.content, sizeof(mQueryContent));
 
   rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT);
 
index 62ccd2e5d87acfd9ab80e68735e6246e4d511a28..3fb7dc9b1b5e2b6493db095666fca2766559a739 100644 (file)
@@ -251,8 +251,7 @@ bool PipeBackend::get(DNSResourceRecord &r)
             throw PDNSException("Format error communicating with coprocess in data section of MX/SRV record");
            }
            
-           r.priority=atoi(parts[6+extraFields].c_str());
-           r.content=parts[7+extraFields];
+           r.content=parts[6+extraFields]+" "+parts[7+extraFields];
          }
          break;
       }
index 43e3d10c5590c075d61c8fbc011ee7c8e5150ca0..74dae2da03d46b61109453459c5e0a023eca29bc 100644 (file)
@@ -277,19 +277,11 @@ bool TinyDNSBackend::get(DNSResourceRecord &rr)
                                dr.d_class = 1;
                                dr.d_type = rr.qtype.getCode();
                                dr.d_clen = val.size()-pr.d_pos;
-                               DNSRecordContent *drc = DNSRecordContent::mastermake(dr, pr);
 
-                               string content = drc->getZoneRepresentation();
-                               // cerr<<"CONTENT: "<<content<<endl;
+                               DNSRecordContent *drc = DNSRecordContent::mastermake(dr, pr);
+                               rr.content = drc->getZoneRepresentation();
+                               // cerr<<"CONTENT: "<<rr.content<<endl;
                                delete drc;
-                               if(rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV) {
-                                       vector<string>parts;
-                                       stringtok(parts,content," ");
-                                       rr.priority=atoi(parts[0].c_str());
-                                       rr.content=content.substr(parts[0].size()+1);
-                               } else {
-                                       rr.content = content;
-                               }
                        }
                        catch (...) {
                                if (d_ignorebogus) {
index 5f948c0f0e53ceb16c431f3ad0286758904657ad..4befdf896d4ab4ee7ed790d45195bf29f30e8847 100644 (file)
@@ -1021,19 +1021,23 @@ bool GSQLBackend::get(DNSResourceRecord &r)
   // L << "GSQLBackend get() was called for "<<qtype.getName() << " record: ";
   SSql::row_t row;
   if(d_db->getRow(row)) {
-    r.content=row[0];
     if (row[1].empty())
         r.ttl = ::arg().asNum( "default-ttl" );
-    else 
+    else
         r.ttl=atol(row[1].c_str());
-    r.priority=atol(row[2].c_str());
     if(!d_qname.empty())
       r.qname=d_qname;
     else
       r.qname=row[6];
     r.qtype=row[3];
+
+    if (r.qtype==QType::MX || r.qtype==QType::SRV)
+      r.content=row[2]+" "+row[0];
+    else
+      r.content=row[0];
+
     r.last_modified=0;
-    
+
     if(d_dnssecQueries)
       r.auth = !row[7].empty() && row[7][0]=='1';
     else
@@ -1093,13 +1097,25 @@ bool GSQLBackend::replaceRRSet(uint32_t domain_id, const string& qname, const QT
 
 bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername)
 {
+  int prio=0;
+  string content(r.content);
+
+  if(r.qtype == QType::MX || r.qtype == QType::SRV) {
+    prio=atoi(content.c_str());
+
+    string::size_type pos = content.find_first_not_of("0123456789");
+    if(pos != string::npos)
+      boost::erase_head(content, pos);
+    trim_left(content);
+ }
+
   string query;
 
   if(d_dnssecQueries && ordername)
     query = (GSQLformat(d_InsertRecordOrderQuery)
-             % sqlEscape(r.content)
+             % sqlEscape(content)
              % r.ttl
-             % r.priority
+             % prio
              % sqlEscape(r.qtype.getName())
              % r.domain_id
              % (int)r.disabled
@@ -1109,9 +1125,9 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername)
       ).str();
   else
     query = (GSQLformat(d_InsertRecordQuery)
-             % sqlEscape(r.content)
+             % sqlEscape(content)
              % r.ttl
-             % r.priority
+             % prio
              % sqlEscape(r.qtype.getName())
              % r.domain_id
              % (int)r.disabled
index 611c3daf1e187d6b9d812eb40daeea3d2574aa07..48f694bfe26953bc9d019dcc6915efb61426689d 100644 (file)
@@ -75,7 +75,7 @@ public:
 class DNSResourceRecord
 {
 public:
-  DNSResourceRecord() : qclass(1), priority(0), signttl(0), last_modified(0), d_place(ANSWER), auth(1), disabled(0), scopeMask(0) {};
+  DNSResourceRecord() : qclass(1), signttl(0), last_modified(0), d_place(ANSWER), auth(1), disabled(0), scopeMask(0) {};
   DNSResourceRecord(const struct DNSRecord&);
   ~DNSResourceRecord(){};
 
@@ -89,7 +89,6 @@ public:
   string qname; //!< the name of this record, for example: www.powerdns.com
   string wildcardname;
   string content; //!< what this record points to. Example: 10.1.2.3
-  uint16_t priority; //!< For qtypes that support a priority or preference (MX, SRV)
   uint32_t ttl; //!< Time To Live of this record
   uint32_t signttl; //!< If non-zero, use this TTL as original TTL in the RRSIG
   int domain_id; //!< If a backend implements this, the domain_id of the zone this record is in
@@ -109,7 +108,6 @@ public:
     ar & qname;
     ar & wildcardname;
     ar & content;
-    ar & priority;
     ar & ttl;
     ar & domain_id;
     ar & last_modified;
index f6f5d51b103e9235d4668ab83d4170edd5996829..11675553755ba2d84e1e7d2a8bf7a92ae7bb3c71 100644 (file)
@@ -164,9 +164,6 @@ void DNSPacket::addRecord(const DNSResourceRecord &rr)
   if(d_compress)
     for(vector<DNSResourceRecord>::const_iterator i=d_rrs.begin();i!=d_rrs.end();++i) 
       if(rr.qname==i->qname && rr.qtype==i->qtype && rr.content==i->content) {
-        if(rr.qtype.getCode()!=QType::MX && rr.qtype.getCode()!=QType::SRV)
-          return;
-        if(rr.priority==i->priority)
           return;
       }
 
@@ -300,10 +297,6 @@ void DNSPacket::wrapup()
       uint8_t maxScopeMask=0;
       for(pos=d_rrs.begin(); pos < d_rrs.end(); ++pos) {
         maxScopeMask = max(maxScopeMask, pos->scopeMask);
-        // this needs to deal with the 'prio' mismatch:
-        if(pos->qtype.getCode()==QType::MX || pos->qtype.getCode() == QType::SRV) {  
-          pos->content = lexical_cast<string>(pos->priority) + " " + pos->content;
-        }
 
         if(!pos->content.empty() && pos->qtype.getCode()==QType::TXT && pos->content[0]!='"') {
           pos->content="\""+pos->content+"\"";
index 504691286ec025705ae424da70758ff17ce03d5c..dc324ce0b75722ea44ac9ab8014a2b1893903062 100644 (file)
@@ -253,19 +253,7 @@ void DNSProxy::mainloop(void)
                rr.qtype = j->first.d_type;
                rr.ttl=j->first.d_ttl;
                rr.d_place= (DNSResourceRecord::Place)j->first.d_place;
-               shared_ptr<MXRecordContent> mx=boost::dynamic_pointer_cast<MXRecordContent>(j->first.d_content);
-               shared_ptr<SRVRecordContent> srv=boost::dynamic_pointer_cast<SRVRecordContent>(j->first.d_content);
-               if(mx) {
-                 rr.content=mx->d_mxname;
-                 rr.priority=mx->d_preference;
-               }
-               else if(srv) {
-                 rr.content = lexical_cast<string>(srv->d_weight)+" "+lexical_cast<string>(srv->d_port)+" "+srv->d_target;
-                 rr.priority=srv->d_preference;
-               }
-               else {
-                 rr.content=j->first.d_content->getZoneRepresentation();
-               }
+               rr.content=j->first.d_content->getZoneRepresentation();
                i->second.complete->addRecord(rr);
              }
            }
index 4c9a05407e6c70275d8206ef6e2a58b3e8116246..6642fa28f39fa66119b47e3921e8e26a8beea390 100644 (file)
 
 void DNSResourceRecord::setContent(const string &cont) {
   content = cont;
-  if(!content.empty() && (qtype==QType::MX || qtype==QType::NS || qtype==QType::CNAME))
-    boost::erase_tail(content, 1);
-
-  if(qtype.getCode() == QType::MX) {
-    vector<string> parts;
-    stringtok(parts, content);
-    priority = atoi(parts[0].c_str());
-    if(parts.size() > 1)
-      content=parts[1];
-    else
-      content=".";
-  } else if(qtype.getCode() == QType::SRV) {
-    priority = atoi(content.c_str());
-    vector<pair<string::size_type, string::size_type> > fields;
-    vstringtok(fields, content, " ");
-    if(fields.size()==4) {
-      content=string(content.c_str() + fields[1].first, fields[3].second - fields[1].first);
-      content=stripDot(content);
-    }
+  switch(qtype.getCode()) {
+    case QType::SRV:
+    case QType::MX:
+      if (content.size() >= 2 && *(content.rbegin()+1) == ' ')
+        return;
+    case QType::CNAME:
+    case QType::NS:
+      if(!content.empty())
+        boost::erase_tail(content, 1);
   }
 }
 
@@ -53,15 +43,11 @@ string DNSResourceRecord::getZoneRepresentation() const {
   switch(qtype.getCode()) {
     case QType::SRV:
     case QType::MX:
-      ret<<priority;
-      ret<<" "<<content;
-      if (*(content.rbegin()) != '.') ret<<".";
-    break;
     case QType::CNAME:
     case QType::NS:
-      ret<<content;
-      if (*(content.rbegin()) != '.') ret<<".";
-    break;
+      if (*(content.rbegin()) != '.')
+        ret<<content<<".";
+      break;
     default:
       ret<<content;
     break;
@@ -78,8 +64,8 @@ bool DNSResourceRecord::operator==(const DNSResourceRecord& rhs)
   string rlabel=toLower(rhs.qname);
 
   return
-    tie(llabel, qtype, lcontent, ttl, priority) ==
-    tie(rlabel, rhs.qtype, rcontent, rhs.ttl, rhs.priority);
+    tie(llabel, qtype, lcontent, ttl) ==
+    tie(rlabel, rhs.qtype, rcontent, rhs.ttl);
 }
 
 
@@ -93,7 +79,6 @@ DNSResourceRecord::DNSResourceRecord(const DNSRecord &p) {
 
   qtype = p.d_type;
   ttl = p.d_ttl;
-  priority=0;
   setContent(p.d_content->getZoneRepresentation());
 }
 
index 19a459fa0544e9ecc3f16b90b1af3e31aaac6042..0e89781d0305b24fd5324559b7319739df620d46 100644 (file)
@@ -212,9 +212,6 @@ void addRRSigs(DNSSECKeeper& dk, DNSBackend& db, const set<string, CIStringCompa
     signPlace = (DNSPacketWriter::Place) pos->d_place;
     if(pos->auth || pos->qtype.getCode() == QType::DS) {
       string content = pos->content;
-      if(pos->qtype.getCode()==QType::MX || pos->qtype.getCode() == QType::SRV) {  
-        content = lexical_cast<string>(pos->priority) + " " + pos->content;
-      }
       if(!pos->content.empty() && pos->qtype.getCode()==QType::TXT && pos->content[0]!='"') {
         content="\""+pos->content+"\"";
       }
index 05d8c820955d386a6863dc017fbc9150603b6534..9736d3da587f1fd1d0eca3ebc72daea0319de933 100644 (file)
@@ -58,7 +58,6 @@ bool AuthLua::axfrfilter(const ComboAddress& remote, const string& zone, const D
   lua_pushstring(d_lua,  in.qname.c_str() );
   lua_pushnumber(d_lua,  in.qtype.getCode() );
   lua_pushnumber(d_lua,  in.ttl );
-  lua_pushnumber(d_lua,  in.priority );
   lua_pushstring(d_lua,  in.content.c_str() );
 
   if(lua_pcall(d_lua,  7, 2, 0)) { // error 
index 84f24871519b0487d3aae7af6b91adc48eec06df..7d2c9d28d1378f5924d48bcc3c31dd45a2e8cc86 100644 (file)
@@ -341,6 +341,12 @@ int PacketHandler::doAdditionalProcessingAndDropAA(DNSPacket *p, DNSPacket *r, c
       }
 
       string content = stripDot(i->content);
+      if(i->qtype == QType::MX || i->qtype == QType::SRV) {
+        string::size_type pos = content.find_first_not_of("0123456789");
+        if(pos != string::npos)
+          boost::erase_head(content, pos);
+        trim_left(content);
+      }
 
       QType qtypes[2];
       qtypes[0]="A"; qtypes[1]="AAAA";
index 17b3f934f6800fa21d90cb4a2bfee97768c29a51..73aa921d6ab9619dbeb4fa0de0b26d382bedc03a 100644 (file)
@@ -391,9 +391,6 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const std::string& zone)
       rr.content=o.str();
     }
 
-    if(rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV)
-      rr.content = lexical_cast<string>(rr.priority)+" "+rr.content;
-
     if(rr.qtype.getCode() == QType::TXT && !rr.content.empty() && rr.content[0]!='"')
       rr.content = "\""+rr.content+"\"";
 
@@ -690,7 +687,6 @@ void testSpeed(DNSSECKeeper& dk, const string& zone, const string& remote, int c
   rr.auth=1;
   rr.qclass = QClass::IN;
   rr.d_place=DNSResourceRecord::ANSWER;
-  rr.priority=0;
   
   UeberBackend db("key-only");
   
index d0357167bbe2b121ec88bd28cb4db63b748eb976..cd207248c2eca169881d114aaee4922b21ede296 100644 (file)
@@ -199,30 +199,15 @@ static int parseResult(MOADNSParser& mdp, const std::string& origQname, uint16_t
     rr.qtype = i->first.d_type;
     rr.ttl = i->first.d_ttl;
     rr.content = i->first.d_content->getZoneRepresentation();
-    rr.priority = 0;
-
-    uint16_t qtype=rr.qtype.getCode();
-
-    if(!rr.content.empty() && (qtype==QType::MX || qtype==QType::NS || qtype==QType::CNAME))
-      boost::erase_tail(rr.content, 1);
-
-    if(rr.qtype.getCode() == QType::MX) {
-      vector<string> parts;
-      stringtok(parts, rr.content);
-      rr.priority = atoi(parts[0].c_str());
-      if(parts.size() > 1)
-        rr.content=parts[1];
-      else
-        rr.content=".";
-    } else if(rr.qtype.getCode() == QType::SRV) {
-      rr.priority = atoi(rr.content.c_str());
-      vector<pair<string::size_type, string::size_type> > fields;
-      vstringtok(fields, rr.content, " ");
-      if(fields.size()==4) {
-        if(fields[3].second - fields[3].first > 1) // strip dot, unless root
-          fields[3].second--;
-        rr.content=string(rr.content.c_str() + fields[1].first, fields[3].second - fields[1].first);
-      }
+    switch(rr.qtype.getCode()) {
+      case QType::SRV:
+      case QType::MX:
+        if (rr.content.size() >= 2 && *(rr.content.rbegin()+1) == ' ')
+          break;
+      case QType::CNAME:
+      case QType::NS:
+        if(!rr.content.empty())
+          boost::erase_tail(rr.content, 1);
     }
     result->push_back(rr);
   }
index 0756149f3848ad46de9f4d608d7915ad20e8593e..c2bd2d381cf34b181f77374ff990991bb1a4ae69 100644 (file)
@@ -107,22 +107,15 @@ ChunkedSigningPipe::~ChunkedSigningPipe()
 }
 
 namespace {
-bool dedupLessThan(const DNSResourceRecord& a, const DNSResourceRecord &b)
+bool
+dedupLessThan(const DNSResourceRecord& a, const DNSResourceRecord &b)
 {
-  if(tie(a.content, a.ttl) < tie(b.content, b.ttl))
-    return true;
-  if(a.qtype.getCode() == QType::MX || a.qtype.getCode() == QType::SRV)
-    return a.priority < b.priority;
-  return false;
+  return (tie(a.content, a.ttl) < tie(b.content, b.ttl));
 }
 
 bool dedupEqual(const DNSResourceRecord& a, const DNSResourceRecord &b)
 {
-  if(tie(a.content, a.ttl) != tie(b.content, b.ttl))
-    return false;
-  if(a.qtype.getCode() == QType::MX || a.qtype.getCode() == QType::SRV)
-    return a.priority == b.priority;
-  return true;
+  return(tie(a.content, a.ttl) == tie(b.content, b.ttl));
 }
 }
 
index 69d27a6c7a8baf567119c3eb5f6e99d4b4b69adf..839dc2d024389fed089240bf0188e4ff2dc9cb58 100644 (file)
@@ -339,7 +339,6 @@ static void fillZone(const string& zonename, HttpResponse* resp) {
     Value jtype(rr.qtype.getName().c_str(), doc.GetAllocator()); // copy
     object.AddMember("type", jtype, doc.GetAllocator());
     object.AddMember("ttl", rr.ttl, doc.GetAllocator());
-    object.AddMember("priority", rr.priority, doc.GetAllocator());
     object.AddMember("disabled", rr.disabled, doc.GetAllocator());
     Value jcontent(rr.content.c_str(), doc.GetAllocator()); // copy
     object.AddMember("content", jcontent, doc.GetAllocator());
@@ -394,15 +393,10 @@ static void gatherRecords(const Value& container, vector<DNSResourceRecord>& new
       rr.content = stringFromJson(record, "content");
       rr.auth = 1;
       rr.ttl = intFromJson(record, "ttl");
-      rr.priority = intFromJson(record, "priority");
       rr.disabled = boolFromJson(record, "disabled");
 
-      string temp_content = rr.content;
-      if (rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV)
-        temp_content = lexical_cast<string>(rr.priority)+" "+rr.content;
-
       try {
-        shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, temp_content));
+        shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content));
         string tmp = drc->serialize(rr.qname);
       }
       catch(std::exception& e)
@@ -570,20 +564,6 @@ static void gatherRecordsFromZone(const Value &container, vector<DNSResourceReco
       if(rr.qtype.getCode() == QType::SOA)
         seenSOA=true;
 
-      rr.priority = 0;
-
-      if (rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV) {
-        int prio;
-        prio=atoi(rr.content.c_str());
-
-        string::size_type pos = rr.content.find_first_not_of("0123456789");
-        if(pos != string::npos)
-          boost::erase_head(rr.content, pos);
-        trim_left(rr.content);
-        rr.priority = prio;
-      }
-
-
       rr.qname = stripDot(rr.qname);
       new_records.push_back(rr);
     }
@@ -661,7 +641,6 @@ static void apiServerZones(HttpRequest* req, HttpResponse* resp) {
     rr.qname = zonename;
     rr.auth = 1;
     rr.ttl = ::arg().asNum("default-ttl");
-    rr.priority = 0;
 
     if (!have_soa && zonekind != DomainInfo::Slave) {
       // synthesize a SOA record so the zone "really" exists
@@ -847,8 +826,6 @@ static void apiServerZoneExport(HttpRequest* req, HttpResponse* resp) {
       break;
     case QType::MX:
     case QType::SRV:
-      content = lexical_cast<string>(rr.priority) + "\t" + makeDotted(content);
-      break;
     case QType::CNAME:
     case QType::NS:
     case QType::AFSDB:
@@ -912,7 +889,6 @@ static void makePtr(const DNSResourceRecord& rr, DNSResourceRecord* ptr) {
   ptr->qtype = "PTR";
   ptr->ttl = rr.ttl;
   ptr->disabled = rr.disabled;
-  ptr->priority = 0;
   ptr->content = rr.qname;
 }
 
@@ -1016,7 +992,6 @@ static void patchZone(HttpRequest* req, HttpResponse* resp) {
       rr.domain_id = di.id;
       rr.auth = 1;
       rr.ttl = sd.ttl;
-      rr.priority = 0;
       editSOARecord(rr, soa_edit_api_kind);
 
       if (!di.backend->replaceRRSet(di.id, rr.qname, rr.qtype, vector<DNSResourceRecord>(1, rr))) {
index 86c5ffff1cb02089062519e21600f35521ce25bf..6141215b808567643243a1e60cc342db265f3492 100644 (file)
@@ -68,8 +68,9 @@ static void quoteValue(string &value)
 }
 
 
-static string emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl, int prio)
+static string emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl)
 {
+  int prio=0;
   string retval;
   g_numRecords++;
   string content(ocontent);
@@ -204,7 +205,7 @@ try
             ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory());
             DNSResourceRecord rr;
             while(zpt.get(rr)) 
-              lines.push_back(emitRecord(i->name, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority));
+              lines.push_back(emitRecord(i->name, rr.qname, rr.qtype.getName(), rr.content, rr.ttl));
             cout << "{\"name\":\"" << i->name << "\",\"records\": ";
             emitJson(lines);
             cout << "},";
@@ -234,7 +235,7 @@ try
       string zname; 
       cout << "{\"name\":\"" << ::arg()["zone-name"] << "\",\"records\":";
       while(zpt.get(rr)) 
-        lines.push_back(emitRecord(::arg()["zone-name"], rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority));
+        lines.push_back(emitRecord(::arg()["zone-name"], rr.qname, rr.qtype.getName(), rr.content, rr.ttl));
       emitJson(lines);
       cout << "}\n";
       num_domainsdone=1;
index f004a60954d06bb59e43fa10127e95a3a5351082..4dd7e9f24e9e19c4e775acfefe345e25cd15b27c 100644 (file)
@@ -43,7 +43,7 @@ string g_basedn;
 string g_zonename;
 map<string,bool> g_objects;
 
-static void callback_simple( unsigned int domain_id, const string &domain, const string &qtype, const string &content, int ttl, int prio )
+static void callback_simple( unsigned int domain_id, const string &domain, const string &qtype, const string &content, int ttl )
 {
         string host;
         string::size_type pos;
@@ -82,14 +82,12 @@ static void callback_simple( unsigned int domain_id, const string &domain, const
                 cout << "add: " << qtype << "Record" << endl;
         }
 
-        cout << qtype << "Record: ";
-        if( prio != 0 ) { cout << prio << " "; }
-        cout << stripDot( content ) << endl << endl;
+        cout << qtype << "Record: " << stripDot( content ) << endl << endl;
 }
 
 
 
-static void callback_tree( unsigned int domain_id, const string &domain, const string &qtype, const string &content, int ttl, int prio )
+static void callback_tree( unsigned int domain_id, const string &domain, const string &qtype, const string &content, int ttl )
 {
         unsigned int i;
         string dn, net;
@@ -138,9 +136,7 @@ static void callback_tree( unsigned int domain_id, const string &domain, const s
                 cout << "add: " << qtype << "Record" << endl;
         }
 
-        cout << qtype << "Record: ";
-        if( prio != 0 ) { cout << prio << " "; }
-        cout << stripDot( content ) << endl << endl;
+        cout << qtype << "Record: " << stripDot( content ) << endl << endl;
 }
 
 
@@ -185,7 +181,7 @@ int main( int argc, char* argv[] )
 
                 g_basedn = args["basedn"];
                 g_dnsttl = args.mustDo( "dnsttl" );
-                typedef boost::function<void(unsigned int, const string &, const string &, const string &, int, int)> callback_t;
+                typedef boost::function<void(unsigned int, const string &, const string &, const string &, int)> callback_t;
                 callback_t callback = callback_simple;
                 if( args["layout"] == "tree" )
                 {
@@ -214,7 +210,7 @@ int main( int argc, char* argv[] )
                                                 ZoneParserTNG zpt(i->filename, i->name, BP.getDirectory());
                                                 DNSResourceRecord rr;
                                                 while(zpt.get(rr))
-                                                        callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority);
+                                                        callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl);
                                         }
                                 }
                                 catch( PDNSException &ae )
@@ -239,7 +235,7 @@ int main( int argc, char* argv[] )
                         ZoneParserTNG zpt(args["zone-file"], args["zone-name"]);
                         DNSResourceRecord rr;
                         while(zpt.get(rr))
-                                callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority);
+                                callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl);
                 }
         }
         catch( PDNSException &ae )
index 003047622d9c47ae247c46c9a211db270a69ff00..317fd8bfbbda62bebd6b6eb4f40bb0cd9eca424b 100644 (file)
@@ -143,8 +143,9 @@ static void emitDomain(const string& domain, const vector<string> *masters = 0)
 }
 
 bool g_doJSONComments;
-static void emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl, int prio, const string& comment="")
+static void emitRecord(const string& zoneName, const string &qname, const string &qtype, const string &ocontent, int ttl, const string& comment="")
 {
+  int prio=0;
   int disabled=0;
   string recordcomment;
 
@@ -401,7 +402,7 @@ try
                continue;
              if(rr.qtype.getCode() == QType::SOA)
                seenSOA=true;
-              emitRecord(i->name, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority, comment);
+              emitRecord(i->name, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, comment);
            }
             num_domainsdone++;
           }
@@ -438,7 +439,7 @@ try
        if(rr.qtype.getCode() == QType::SOA)
          seenSOA=true;
 
-        emitRecord(zonename, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority, comment);
+        emitRecord(zonename, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, comment);
       }
       num_domainsdone=1;
     }