]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge branch 'more-dnsname'
authorKees Monshouwer <mind04@monshouwer.org>
Tue, 30 Jun 2015 10:58:48 +0000 (12:58 +0200)
committermind04 <mind04@monshouwer.org>
Tue, 30 Jun 2015 10:58:48 +0000 (12:58 +0200)
23 files changed:
1  2 
modules/bindbackend/bindbackend2.hh
pdns/bindparserclasses.hh
pdns/communicator.hh
pdns/dns.hh
pdns/dnsbackend.hh
pdns/dnsname.hh
pdns/dnspacket.hh
pdns/dnsparser.hh
pdns/dnsproxy.hh
pdns/dnsrecords.cc
pdns/dnsrecords.hh
pdns/dnssecinfra.hh
pdns/dnsseckeeper.hh
pdns/dnswriter.cc
pdns/dnswriter.hh
pdns/logger.hh
pdns/lua-pdns.hh
pdns/packetcache.hh
pdns/signingpipe.cc
pdns/signingpipe.hh
pdns/test-dnsname_cc.cc
pdns/ueberbackend.hh
pdns/zoneparser-tng.hh

index 4fdfb72c2f5ab77d28167189f7b2ba0f9b39fd2b,55df152a3e4119c190a4d5fd74db71fd51054c9d..b03c7d623f4462fd07378477d80e9698754f23f9
@@@ -153,19 -151,20 +151,19 @@@ public
    //! configure how often this domain should be checked for changes (on disk)
    void setCheckInterval(time_t seconds);
  
-   string d_name;   //!< actual name of the domain
 -  bool d_loaded;  //!< if a domain is loaded
 -  string d_status; //!< message describing status of a domain, for human consumption
 -  mutable bool d_checknow; //!< if this domain has been flagged for a check
 -  time_t d_ctime;  //!< last known ctime of the file on disk
+   DNSName d_name;   //!< actual name of the domain
    string d_filename; //!< full absolute filename of the zone on disk
 -  unsigned int d_id;  //!< internal id of the domain
 -  time_t d_lastcheck; //!< last time domain was checked for freshness
 +  string d_status; //!< message describing status of a domain, for human consumption
    vector<string> d_masters;     //!< IP address of the master of this domain
    set<string> d_also_notify; //!< IP list of hosts to also notify
 -
 +  LookButDontTouch<recordstorage_t> d_records;  //!< the actual records belonging to this domain
 +  time_t d_ctime;  //!< last known ctime of the file on disk
 +  time_t d_lastcheck; //!< last time domain was checked for freshness
    uint32_t d_lastnotified; //!< Last serial number we notified our slaves of
 +  unsigned int d_id;  //!< internal id of the domain
 +  mutable bool d_checknow; //!< if this domain has been flagged for a check
 +  bool d_loaded;  //!< if a domain is loaded
  
 -  LookButDontTouch<recordstorage_t> d_records;  //!< the actual records belonging to this domain
  private:
    time_t getCtime();
    time_t d_checkinterval;
@@@ -245,11 -244,12 +243,11 @@@ private
    void release(SSqlStatement**);
    static bool safeGetBBDomainInfo(int id, BB2DomainInfo* bbd);
    static void safePutBBDomainInfo(const BB2DomainInfo& bbd);
-   static bool safeGetBBDomainInfo(const std::string& name, BB2DomainInfo* bbd);
-   static bool safeRemoveBBDomainInfo(const std::string& name);
+   static bool safeGetBBDomainInfo(const DNSName& name, BB2DomainInfo* bbd);
+   static bool safeRemoveBBDomainInfo(const DNSName& name);
    bool GetBBDomainInfo(int id, BB2DomainInfo** bbd);
    shared_ptr<SSQLite3> d_dnssecdb;
-   bool getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* ns3p);
 -  bool d_hybrid;
+   bool getNSEC3PARAM(const DNSName& zname, NSEC3PARAMRecordContent* ns3p);
    class handle
    {
    public:
      recordstorage_t::const_iterator d_iter, d_end_iter;
      recordstorage_t::const_iterator d_qname_iter;
      recordstorage_t::const_iterator d_qname_end;
-     string qname;
-     string domain;
 -
 -    bool d_list;
 -    int id;
 -
+     DNSName qname;
+     DNSName domain;
 +
 +    int id;
      QType qtype;
 +    bool d_list;
      bool mustlog;
  
    private:
      handle(const handle &);
    };
  
 -  static int s_first;                                  //!< this is raised on construction to prevent multiple instances of us being generated
 -  static bool s_ignore_broken_records;
 +  SSqlStatement* d_getAllDomainMetadataQuery_stmt;
 +  SSqlStatement* d_getDomainMetadataQuery_stmt;
 +  SSqlStatement* d_deleteDomainMetadataQuery_stmt;
 +  SSqlStatement* d_insertDomainMetadataQuery_stmt;
 +  SSqlStatement* d_getDomainKeysQuery_stmt;
 +  SSqlStatement* d_deleteDomainKeyQuery_stmt;
 +  SSqlStatement* d_insertDomainKeyQuery_stmt;
 +  SSqlStatement* d_activateDomainKeyQuery_stmt;
 +  SSqlStatement* d_deactivateDomainKeyQuery_stmt;
 +  SSqlStatement* d_getTSIGKeyQuery_stmt;
 +  SSqlStatement* d_setTSIGKeyQuery_stmt;
 +  SSqlStatement* d_deleteTSIGKeyQuery_stmt;
 +  SSqlStatement* d_getTSIGKeysQuery_stmt;
  
 -  static string s_binddirectory;                              //!< this is used to store the 'directory' setting of the bind configuration
 +  string d_transaction_tmpname;
    string d_logprefix;
 -
    set<string> alsoNotify; //!< this is used to store the also-notify list of interested peers.
 -
 -  BB2DomainInfo createDomainEntry(const DNSName& domain, const string &filename); //!< does not insert in s_state
 -
 -  int d_transaction_id;
 -  string d_transaction_tmpname;
 -
    ofstream *d_of;
    handle d_handle;
-   BB2DomainInfo createDomainEntry(const string &domain, const string &filename); //!< does not insert in s_state
 +  static string s_binddirectory;                              //!< this is used to store the 'directory' setting of the bind configuration
 +  static int s_first;                                  //!< this is raised on construction to prevent multiple instances of us being generated
 +  int d_transaction_id;
 +  static bool s_ignore_broken_records;
 +  bool d_hybrid;
 +
++  BB2DomainInfo createDomainEntry(const DNSName& domain, const string &filename); //!< does not insert in s_state
  
    void queueReloadAndStore(unsigned int id);
-   bool findBeforeAndAfterUnhashed(BB2DomainInfo& bbd, const std::string& qname, std::string& unhashed, std::string& before, std::string& after);
+   bool findBeforeAndAfterUnhashed(BB2DomainInfo& bbd, const DNSName& qname, DNSName& unhashed, string& before, string& after);
    void reload();
    static string DLDomStatusHandler(const vector<string>&parts, Utility::pid_t ppid);
    static string DLListRejectsHandler(const vector<string>&parts, Utility::pid_t ppid);
index a43fee5aac0591180368b36f650857205ae14dc8,0dc424e8d98cfbcd2046e13d2898b2d5d1962d1b..2faced2ae4b27b77676734edede95b9c695df374
@@@ -90,10 -90,10 +90,10 @@@ class BindParse
    set<string> & getAlsoNotify() { return this->alsoNotify; } 
  private:
    string d_dir;
-   typedef map<string,string> zonedomain_t;
 -  bool d_verbose;
+   typedef map<DNSName,string> zonedomain_t;
    set<string> alsoNotify;
    vector<BindDomainInfo> d_zonedomains;
 +  bool d_verbose;
  };
  
  #endif /* BINDPARSER_HH */
index 8d5aef859d4f5fe50201c81181755590860308c7,e2de7b07c8be8a8c51ac6c452bb5a141a650811e..f234222a7785417b7499e8302165c25b146a5300
@@@ -128,11 -128,11 +128,11 @@@ public
  private:
    struct NotificationRequest
    {
-     string domain;
+     DNSName domain;
      string ip;
 +    time_t next;
      int attempts;
      uint16_t id;
 -    time_t next;
    };
  
    typedef std::list<NotificationRequest> d_nqueue_t;
diff --cc pdns/dns.hh
index 768c26992cc528fe1b4477875f6987825d4c332e,1fb6840b7c1a557710b9867f636891cb96435878..2c0b763e62fb8682c9d69198693d5c72f578fbc9
@@@ -37,11 -38,11 +38,11 @@@ class DNSName; // FIXM
  
  struct SOAData
  {
 -  SOAData() : ttl(0), serial(0), refresh(0), retry(0), expire(0), domain_id(-1), db(0), scopeMask(0) {};
 +  SOAData() : ttl(0), serial(0), refresh(0), retry(0), expire(0),  db(0), domain_id(-1), scopeMask(0) {};
  
-   string qname;
-   string nameserver;
-   string hostmaster;
+   DNSName qname;
+   DNSName nameserver;
+   DNSName hostmaster;
    uint32_t ttl;
    uint32_t serial;
    uint32_t refresh;
@@@ -81,25 -81,22 +82,25 @@@ public
    string getZoneRepresentation() const;
  
    // data
-   string qname; //!< the name of this record, for example: www.powerdns.com
-   string wildcardname;
 -  
 -  QType qtype; //!< qtype of this record, ie A, CNAME, MX etc
 -  uint16_t qclass; //!< class of this record
+   DNSName qname; //!< the name of this record, for example: www.powerdns.com
+   DNSName wildcardname;
    string content; //!< what this record points to. Example: 10.1.2.3
 +
 +  // Aligned on 8-byte boundries on systems where time_t is 8 bytes and int
 +  // is 4 bytes, aka modern linux on x86_64
 +  time_t last_modified; //!< For autocalculating SOA serial numbers - the backend needs to fill this in
 +
    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
 -  time_t last_modified; //!< For autocalculating SOA serial numbers - the backend needs to fill this in
 -  enum Place {QUESTION=0, ANSWER=1, AUTHORITY=2, ADDITIONAL=3}; //!< Type describing the positioning of a DNSResourceRecord within, say, a DNSPacket
 -  Place d_place; //!< This specifies where a record goes within the packet
 +  QType qtype; //!< qtype of this record, ie A, CNAME, MX etc
 +  uint16_t qclass; //!< class of this record
  
 +  Place d_place; //!< This specifies where a record goes within the packet
 +  uint8_t scopeMask;
    bool auth;
    bool disabled;
 -  uint8_t scopeMask;
  
    template<class Archive>
    void serialize(Archive & ar, const unsigned int version)
index f729622bbaa07a705c625f23e2c25c5defc01dee,4dfaa25802dc0f0ace313c9c943674612a093235..fdefa31bbc88de1759d2886f11ca95ed9101299f
@@@ -45,18 -46,15 +46,18 @@@ class DNSBackend
  struct DomainInfo
  {
    DomainInfo() : backend(0) {}
 -  uint32_t id;
 +
-   string zone;
+   DNSName zone;
 -  vector<string> masters;
 -  uint32_t notified_serial;
 -  uint32_t serial;
    time_t last_check;
    string account;
 -  enum DomainKind { Master, Slave, Native } kind;
 +  vector<string> masters;
    DNSBackend *backend;
 +
 +  uint32_t id;
 +  uint32_t notified_serial;
 +
 +  uint32_t serial;
 +  enum DomainKind : uint8_t { Master, Slave, Native } kind;
    
    bool operator<(const DomainInfo& rhs) const
    {
@@@ -166,27 -164,27 +167,27 @@@ public
    virtual void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false) { }
  
    /** Determines if we are authoritative for a zone, and at what level */
-   virtual bool getAuth(DNSPacket *p, SOAData *sd, const string &target, const int best_match_len);
+   virtual bool getAuth(DNSPacket *p, SOAData *sd, const DNSName &target, const int best_match_len);
  
    struct KeyData {
 +    std::string content;
      unsigned int id;
      unsigned int flags;
      bool active;
 -    std::string content;
    };
  
-   virtual bool getDomainKeys(const string& name, unsigned int kind, std::vector<KeyData>& keys) { return false;}
-   virtual bool removeDomainKey(const string& name, unsigned int id) { return false; }
-   virtual int addDomainKey(const string& name, const KeyData& key){ return -1; }
-   virtual bool activateDomainKey(const string& name, unsigned int id) { return false; }
-   virtual bool deactivateDomainKey(const string& name, unsigned int id) { return false; }
+   virtual bool getDomainKeys(const DNSName& name, unsigned int kind, std::vector<KeyData>& keys) { return false;}
+   virtual bool removeDomainKey(const DNSName& name, unsigned int id) { return false; }
+   virtual int addDomainKey(const DNSName& name, const KeyData& key){ return -1; }
+   virtual bool activateDomainKey(const DNSName& name, unsigned int id) { return false; }
+   virtual bool deactivateDomainKey(const DNSName& name, unsigned int id) { return false; }
  
-   virtual bool getTSIGKey(const string& name, string* algorithm, string* content) { return false; }
-   virtual bool setTSIGKey(const string& name, const string& algorithm, const string& content) { return false; }
-   virtual bool deleteTSIGKey(const string& name) { return false; }
+   virtual bool getTSIGKey(const DNSName& name, DNSName* algorithm, string* content) { return false; }
+   virtual bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) { return false; }
+   virtual bool deleteTSIGKey(const DNSName& name) { return false; }
    virtual bool getTSIGKeys(std::vector< struct TSIGKey > &keys) { return false; }
  
-   virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after)
+   virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const string& qname, DNSName& unhashed, string& before, string& after)
    {
      std::cerr<<"Default beforeAndAfterAbsolute called!"<<std::endl;
      abort();
diff --cc pdns/dnsname.hh
Simple merge
index 6820d29801407941993af1e0adf05ed1be44ad40,5ab7ce4e6a9f839c5341d489e6be8b2fc88fd0b2..b50f6ef74bdf2602b47426ec9be2e201a711da9b
@@@ -133,54 -133,52 +133,54 @@@ public
    bool hasEDNS();
    //////// DATA !
  
-   string qdomain;  //!< qname of the question 4 - unsure how this is used
-   string qdomainwild;  //!< wildcard matched by qname, used by LuaPolicyEngine
-   string qdomainzone;  //!< zone name for the answer (as reflected in SOA for negative responses), used by LuaPolicyEngine
 -  ComboAddress d_remote;
 -  uint16_t qclass;  //!< class of the question - should always be INternet 2
 -  struct dnsheader d; //!< dnsheader at the start of the databuffer 12
 -
 -  QType qtype;  //!< type of the question 8
 -
+   DNSName qdomain;  //!< qname of the question 4 - unsure how this is used
+   DNSName qdomainwild;  //!< wildcard matched by qname, used by LuaPolicyEngine
+   DNSName qdomainzone;  //!< zone name for the answer (as reflected in SOA for negative responses), used by LuaPolicyEngine
 +  string d_peer_principal;
 +  struct dnsheader d; //!< dnsheader at the start of the databuffer 12
 +
 +  uint16_t qclass;  //!< class of the question - should always be INternet 2
 +  QType qtype;  //!< type of the question 2
 +
 +  TSIGRecordContent d_trc; //72
 +
 +  ComboAddress d_remote; //28
 +  TSIGHashEnum d_tsig_algo; //4
 +
    bool d_tcp;
    bool d_dnssecOk;
    bool d_havetsig;
  
-   bool getTSIGDetails(TSIGRecordContent* tr, string* keyname, string* message) const;
-   void setTSIGDetails(const TSIGRecordContent& tr, const string& keyname, const string& secret, const string& previous, bool timersonly=false);
-   bool getTKEYRecord(TKEYRecordContent* tr, string* keyname) const;
 -  string d_peer_principal;
 -  TSIGHashEnum d_tsig_algo;
 -
+   bool getTSIGDetails(TSIGRecordContent* tr, DNSName* keyname, string* message) const;
+   void setTSIGDetails(const TSIGRecordContent& tr, const DNSName& keyname, const string& secret, const string& previous, bool timersonly=false);
+   bool getTKEYRecord(TKEYRecordContent* tr, DNSName* keyname) const;
  
    vector<DNSResourceRecord>& getRRS() { return d_rrs; }
 -  TSIGRecordContent d_trc;
    static bool s_doEDNSSubnetProcessing;
 -  static uint16_t s_udpTruncationThreshold;
 +  static uint16_t s_udpTruncationThreshold; //2
  private:
    void pasteQ(const char *question, int length); //!< set the question of this packet, useful for crafting replies
  
    bool d_wrapped; // 1
 -  bool d_compress; // 1
 -  uint16_t d_qlen; // length of the question (including class & type) in this packet 2
 -  
    int d_socket; // 4
  
 -  string d_rawpacket; // this is where everything lives 4
 -  int d_maxreplylen;
 -  string d_ednsping;
 -  bool d_wantsnsid;
 -  bool d_haveednssubnet;
 -  bool d_haveednssection;
 -  EDNSSubnetOpts d_eso;
    string d_tsigsecret;
-   string d_tsigkeyname;
+   DNSName d_tsigkeyname;
    string d_tsigprevious;
 -  bool d_tsigtimersonly;
  
 -  vector<DNSResourceRecord> d_rrs; // 4
 +  vector<DNSResourceRecord> d_rrs; // 8
 +  string d_rawpacket; // this is where everything lives 8
 +  string d_ednsping;
 +  EDNSSubnetOpts d_eso;
 +
 +  int d_maxreplylen;
 +  uint16_t d_qlen; // length of the question (including class & type) in this packet 2
 +
 +  bool d_compress; // 1
 +  bool d_tsigtimersonly;
 +  bool d_wantsnsid;
 +  bool d_haveednssubnet;
 +  bool d_haveednssection;
  };
  
  
index eff94e4e9cf23012c119b578f817f5bbfaac3ccf,814740cc6251d11b0b41e02d24b774e9b06610e5..70266c4816040e0ce3bfa1695f00f8f3121e6eea
@@@ -263,8 -262,7 +263,8 @@@ protected
  
  struct DNSRecord
  {
-   std::string d_label;
+   DNSName d_label; //FIXME rename
 +  std::shared_ptr<DNSRecordContent> d_content;
    uint16_t d_type;
    uint16_t d_class;
    uint32_t d_ttl;
@@@ -320,10 -319,10 +320,10 @@@ public
      init(packet, len);
    }
  
-   string d_qname;
 -  dnsheader d_header;
+   DNSName d_qname;
    uint16_t d_qclass, d_qtype;
    //uint8_t d_rcode;
 +  dnsheader d_header;
  
    typedef vector<pair<DNSRecord, uint16_t > > answers_t;
    
index c4bf4baf339a5d97a227f53ecad20626ee8380b3,fc103f562a6cc6ef52d540dfd7d39eb769bb7d3e..c48dec7128b238d35d388093ea1608611bc9c916
@@@ -65,17 -65,25 +65,17 @@@ public
    }
    bool recurseFor(DNSPacket* p);
  private:
 -  NetmaskGroup d_ng;
 -  int d_sock;
 -  AtomicCounter* d_resanswers;
 -  AtomicCounter* d_udpanswers;
 -  AtomicCounter* d_resquestions;
 -  pthread_mutex_t d_lock;
 -  uint16_t d_xor;
 -  int getID_locked();
    struct ConntrackEntry
    {
 -    uint16_t id;
 -    ComboAddress remote;
 -    int outsock;
      time_t created;
-     string qname;
 +    boost::optional<ComboAddress> anyLocal;
 -    uint16_t qtype;
+     DNSName qname;
      DNSPacket* complete;
-     string aname;
+     DNSName aname;
 -    boost::optional<ComboAddress> anyLocal;
 +    ComboAddress remote;
 +    uint16_t id;
 +    uint16_t qtype;
 +    int outsock;
    };
  
    typedef map<int,ConntrackEntry> map_t;
index 3df4c6a7789dbd8c4f49475c10a5d966673df621,e30583494ad8ca41ae4d369e65733086c54cd318..14a7d67fe391a590574f621774eae6f59d07b6cc
@@@ -225,8 -222,8 +222,8 @@@ boilerplate_conv(NAPTR, QType::NAPTR
                   )
  
  
- SRVRecordContent::SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const string& target) 
+ SRVRecordContent::SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const DNSName& target) 
 -: DNSRecordContent(QType::SRV), d_preference(preference), d_weight(weight), d_port(port), d_target(target)
 +: DNSRecordContent(QType::SRV), d_weight(weight), d_port(port), d_target(target), d_preference(preference)
  {}
  
  boilerplate_conv(SRV, QType::SRV, 
index 36e9b5acf1698f17d3b262932479c6d0dea5244b,4664eb030c678e533428595b37e3a9808b4eb72c..016fa8a39e7cf83d0ad6c9f0994b7d49c41b0415
@@@ -108,10 -109,11 +109,11 @@@ public
    includeboilerplate(IPSECKEY)
  
  private:
 -  uint8_t d_preference, d_gatewaytype, d_algorithm;
 +  uint32_t d_ip4;
-   string d_gateway, d_publickey;
+   DNSName d_gateway;
+   string d_publickey;
 -  uint32_t d_ip4;
    string d_ip6;
 +  uint8_t d_preference, d_gatewaytype, d_algorithm;
  };
  
  class DHCIDRecordContent : public DNSRecordContent
@@@ -131,9 -133,8 +133,9 @@@ public
  
    includeboilerplate(SRV)
  
 -  uint16_t d_preference, d_weight, d_port;
 +  uint16_t d_weight, d_port;
-   string d_target;
+   DNSName d_target;
 +  uint16_t d_preference;
  };
  
  class TSIGRecordContent : public DNSRecordContent
@@@ -142,16 -143,15 +144,16 @@@ public
    includeboilerplate(TSIG)
    TSIGRecordContent() : DNSRecordContent(QType::TSIG) {}
  
 -  DNSName d_algoName;
 -  uint64_t d_time; // 48 bits
 +  uint16_t d_origID;
    uint16_t d_fudge;
 -  //  uint16_t d_macSize;
 +
-   string d_algoName;
++  DNSName d_algoName;
    string d_mac;
 -  uint16_t d_origID;
 +  string d_otherData;
 +  uint64_t d_time;
 +  //  uint16_t d_macSize;
    uint16_t d_eRcode;
    // uint16_t d_otherLen
 -  string d_otherData;
  };
  
  
@@@ -366,12 -366,15 +368,13 @@@ public
    includeboilerplate(RRSIG)
  
    uint16_t d_type;
 -  uint8_t d_algorithm, d_labels;
 -  uint32_t d_originalttl, d_sigexpire, d_siginception;
    uint16_t d_tag;
-   string d_signer, d_signature;
+   DNSName d_signer;
+   string d_signature;
 +  uint32_t d_originalttl, d_sigexpire, d_siginception;
 +  uint8_t d_algorithm, d_labels;
  };
  
 -
 -
  //namespace {
    struct soatimes 
    {
@@@ -397,11 -400,11 +400,11 @@@ class SOARecordContent : public DNSReco
  {
  public:
    includeboilerplate(SOA)
-   SOARecordContent(const string& mname, const string& rname, const struct soatimes& st);
+   SOARecordContent(const DNSName& mname, const DNSName& rname, const struct soatimes& st);
  
-   string d_mname;
-   string d_rname;
 +  struct soatimes d_st;
 -  struct soatimes d_st;
+   DNSName d_mname;
+   DNSName d_rname;
  };
  
  class NSECRecordContent : public DNSRecordContent
@@@ -540,17 -543,15 +543,17 @@@ public
    includeboilerplate(TKEY)
  
    // storage for the bytes
 -  DNSName d_algo;
 +  uint16_t d_othersize;
 +  uint16_t d_mode;
    uint32_t d_inception;
    uint32_t d_expiration;
 -  uint16_t d_mode;
 -  uint16_t d_error;
 -  uint16_t d_keysize;
 +
-   string d_algo;
++  DNSName d_algo;
    string d_key;
 -  uint16_t d_othersize;
    string d_other;
 +
 +  uint16_t d_error;
 +  uint16_t d_keysize;
  private:
  };
  
Simple merge
index 4deb945f0cc0fa057c041d826906a76a1c40d702,87bcd7ac7cae257d69ba4059e48cd69e86002bfa..3643c60d23d8d99f081524f9b145ea149e2d2406
@@@ -117,9 -117,9 +117,9 @@@ private
        return d_ttd;
      }
    
-     string d_domain;
+     DNSName d_domain;
 -    unsigned int d_ttd;
      mutable keys_t d_keys;
 +    unsigned int d_ttd;
    };
    
    struct METACacheEntry
        return d_ttd;
      }
    
-     string d_domain;
+     DNSName d_domain;
 +    mutable std::string d_key, d_value;
      unsigned int d_ttd;
    
 -    mutable std::string d_key, d_value;
    };
    
    
index 5286439a25890c4233abe92179efc02cd7b1fb99,ddd8e357cb497dd22fba4c77c7f584cbf8a647c8..6ac0aa71dba42826bbb5cfa51552a4478a7614f3
@@@ -160,11 -160,12 +160,12 @@@ void DNSPacketWriter::xfrText(const str
    }
  }
  
- DNSPacketWriter::lmap_t::iterator find(DNSPacketWriter::lmap_t& lmap, const string& label)
+ /* FIXME400: check that this beats a map */
 -DNSPacketWriter::nmap_t::iterator find(DNSPacketWriter::nmap_t& nmap, const DNSName& name)
++DNSPacketWriter::lmap_t::iterator find(DNSPacketWriter::lmap_t& nmap, const DNSName& name)
  {
 -  DNSPacketWriter::nmap_t::iterator ret;
 +  DNSPacketWriter::lmap_t::iterator ret;
-   for(ret=lmap.begin(); ret != lmap.end(); ++ret)
-     if(pdns_iequals(ret->first ,label))
+   for(ret=nmap.begin(); ret != nmap.end(); ++ret)
+     if(pdns_iequals(ret->first ,name))
        break;
    return ret;
  }
@@@ -219,18 -222,19 +222,19 @@@ void DNSPacketWriter::xfrName(const DNS
    unsigned int startRecordSize=d_record.size();
    unsigned int startPos;
  
-   for(labelparts_t::const_iterator i=parts.begin(); i!=parts.end(); ++i) {
-     if(deDot)
-       chopped.assign(label.c_str() + i->first, labellen - i->first -1);
-     else
-       chopped.assign(label.c_str() + i->first);
+   DNSName towrite = name;
+   /* FIXME400: if we are not compressing, there is no reason to work per-label */
+   for(auto &label: parts) {
+     if(d_lowerCase) label=toLower(label);
+     //cerr<<"xfrName labelpart ["<<label<<"], left to write ["<<towrite.toString()<<"]"<<endl;
  
-     lmap_t::iterator li=d_labelmap.end();
 -    auto li=d_namemap.end();
++    auto li=d_labelmap.end();
      // see if we've written out this domain before
-     // cerr<<"Searching for compression pointer to '"<<chopped<<"', "<<d_labelmap.size()<<" cmp-records"<<endl;
-     if(compress && (li=find(d_labelmap, chopped))!=d_labelmap.end()) {
-       // cerr<<"\tFound a compression pointer to '"<<chopped<<"': "<<li->second<<endl;
-       if (d_record.size() - startRecordSize + chopped.size() > 253) // chopped does not include a length octet for the first label and the root label
 -    //cerr<<"compress="<<compress<<", searching? for compression pointer to '"<<towrite.toString()<<"', "<<d_namemap.size()<<" cmp-records"<<endl;
 -    if(compress && (li=find(d_namemap, towrite))!=d_namemap.end()) {
++    //cerr<<"compress="<<compress<<", searching? for compression pointer to '"<<towrite.toString()<<"', "<<d_labelmap.size()<<" cmp-records"<<endl;
++    if(compress && (li=find(d_labelmap, towrite))!=d_labelmap.end()) {
+       //cerr<<"doing compression, my label=["<<label<<"] found match ["<<li->first.toString()<<"]"<<endl;
+       //cerr<<"\tFound a compression pointer to '"<<towrite.toString()<<"': "<<li->second<<endl;
+       if (d_record.size() - startRecordSize + label.size() > 253) // chopped does not include a length octet for the first label and the root label
          throw MOADNSException("DNSPacketWriter::xfrName() found overly large (compressed) name");
        uint16_t offset=li->second;
        offset|=0xc000;
        goto out;                                 // skip trailing 0 in case of compression
      }
  
 -    if(li==d_namemap.end() && pos< 16384) {
 +    if(li==d_labelmap.end() && pos< 16384) {
        //      cerr<<"\tStoring a compression pointer to '"<<chopped<<"': "<<pos<<endl;
-       d_labelmap.push_back(make_pair(chopped, pos));                       //  if untrue, we need to count - also, don't store offsets > 16384, won't work
 -      d_namemap.push_back(make_pair(towrite, pos));                       //  if untrue, we need to count - also, don't store offsets > 16384, won't work
++      d_labelmap.push_back(make_pair(towrite, pos));                       //  if untrue, we need to count - also, don't store offsets > 16384, won't work
+       //cerr<<"stored ["<<towrite.toString()<<"] at pos "<<pos<<endl;
      }
  
      startPos=pos;
index 234f87b6b95ba2ff9a4caf0fcb5031faf0134c87,6f20ad5c967f9dc123bacb56d8d92fe828728785..af50502e21fe7c09cdbe04e7baeca421da344bf8
@@@ -37,15 -38,15 +38,15 @@@ class DNSPacketWriter : public boost::n
  {
  
  public:
-   typedef vector<pair<string, uint16_t> > lmap_t;
 -  typedef vector<pair<DNSName, uint16_t> > nmap_t;
 -  enum Place {ANSWER=1, AUTHORITY=2, ADDITIONAL=3};
++  typedef vector<pair<DNSName, uint16_t> > lmap_t;
 +  enum Place : uint8_t {ANSWER=1, AUTHORITY=2, ADDITIONAL=3}; 
  
    //! Start a DNS Packet in the vector passed, with question qname, qtype and qclass
-   DNSPacketWriter(vector<uint8_t>& content, const string& qname, uint16_t  qtype, uint16_t qclass=QClass::IN, uint8_t opcode=0);
-   
-   /** Start a new DNS record within this packet for namq, qtype, ttl, class and in the requested place. Note that packets can only be written in natural order - 
+   DNSPacketWriter(vector<uint8_t>& content, const DNSName& qname, uint16_t  qtype, uint16_t qclass=QClass::IN, uint8_t opcode=0);
+   /** Start a new DNS record within this packet for namq, qtype, ttl, class and in the requested place. Note that packets can only be written in natural order -
        ANSWER, AUTHORITY, ADDITIONAL */
-   void startRecord(const string& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=QClass::IN, Place place=ANSWER, bool compress=true);
+   void startRecord(const DNSName& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=QClass::IN, Place place=ANSWER, bool compress=true);
  
    /** Shorthand way to add an Opt-record, for example for EDNS0 purposes */
    typedef vector<pair<uint16_t,std::string> > optvect_t;
    bool eof() { return true; } // we don't know how long the record should be
  
  private:
 +  // We declare 1 uint_16 in the public section, these 3 align on a 8-byte boundry
 +  uint16_t d_stuff;
 +  uint16_t d_sor;
 +  uint16_t d_rollbackmarker; // start of last complete packet, for rollback
 +
    vector <uint8_t>& d_content;
    vector <uint8_t> d_record;
-   string d_qname;
-   string d_recordqname;
+   DNSName d_qname;
+   DNSName d_recordqname;
 -  uint16_t d_recordqtype, d_recordqclass;
 +  lmap_t d_labelmap;
 +
    uint32_t d_recordttl;
 -  nmap_t d_namemap;
 -  uint16_t d_stuff;
 -  uint16_t d_sor;
 -  uint16_t d_rollbackmarker; // start of last complete packet, for rollback
 +  uint16_t d_recordqtype, d_recordqclass;
 +
    uint16_t d_truncatemarker; // end of header, for truncate
    Place d_recordplace;
    bool d_canonic, d_lowerCase;
diff --cc pdns/logger.hh
Simple merge
Simple merge
Simple merge
index e3f4f634d9e48ac2b5e9009616ae13096d96be9f,9030a4093478840001cffa055388bb4138c424c3..e0e32e321e27f790f81adeb58c7e884a63dcd37a
@@@ -70,9 -70,9 +70,9 @@@ catch(...) 
    return 0;
  }
  
- ChunkedSigningPipe::ChunkedSigningPipe(const string& signerName, bool mustSign, const string& servers, unsigned int workers)
 -ChunkedSigningPipe::ChunkedSigningPipe(const DNSName& signerName, bool mustSign, const string& servers, unsigned int workers) 
 -  : d_queued(0), d_outstanding(0), d_signer(signerName), d_maxchunkrecords(100), d_numworkers(workers), d_tids(d_numworkers),
 -    d_mustSign(mustSign), d_final(false), d_submitted(0)
++ChunkedSigningPipe::ChunkedSigningPipe(const DNSName& signerName, bool mustSign, const string& servers, unsigned int workers)
 +  : d_queued(0), d_outstanding(0), d_numworkers(workers), d_submitted(0), d_signer(signerName),
 +    d_maxchunkrecords(100), d_tids(d_numworkers), d_mustSign(mustSign), d_final(false)
  {
    d_rrsetToSign = new rrset_t;
    d_chunks.push_back(vector<DNSResourceRecord>()); // load an empty chunk
index b7f906477f0aaf14884c83c3f2b58cba05abc596,4c63aea72eb2d50f6716ca9717ace47816c144f7..01b030f1837f615c548749def76782a2559c6aed
@@@ -38,13 -37,9 +38,13 @@@ private
    void worker(int n, int fd);
    
    static void* helperWorker(void* p);
 +
 +  unsigned int d_numworkers;
 +  int d_submitted;
 +
    rrset_t* d_rrsetToSign;
    std::deque< std::vector<DNSResourceRecord> > d_chunks;
-   string d_signer;
+   DNSName d_signer;
    
    chunk_t::size_type d_maxchunkrecords;
    
Simple merge
index 9002125afe9086294f7876a8dda3007707038fd5,f67d94ed93d35e3f5bf7f8471f8fa6173015cba8..4df70b7331a5a5ad3c0d01f6fafde828c6d7dc41
@@@ -88,14 -88,13 +88,14 @@@ public
      //! The current real backend, which is answering questions
      DNSBackend *d_hinterBackend;
  
 -    //! Index of the current backend within the backends vector
 -    unsigned int i;
 -
      //! DNSPacket who asked this question
      DNSPacket *pkt_p;
-     string qname;
+     DNSName qname;
 +
 +    //! Index of the current backend within the backends vector
 +    unsigned int i;
      QType qtype;
 +
    private:
  
      static AtomicCounter instances;
    void rediscover(string* status=0);
    void reload();
  private:
 -  unsigned int d_cache_ttl, d_negcache_ttl;
 -
    pthread_t tid;
    handle d_handle;
 -  bool d_negcached;
 -  bool d_cached;
 +  vector<DNSResourceRecord> d_answers;
 +  vector<DNSResourceRecord>::const_iterator d_cachehandleiter;
 +
 +  static pthread_mutex_t d_mut;
 +  static pthread_cond_t d_cond;
 +  static sem_t d_dynserialize;
 +
    struct Question
    {
-     string qname;
 -    QType qtype;
+     DNSName qname;
      int zoneId;
 +    QType qtype;
    }d_question;
 -  vector<DNSResourceRecord> d_answers;
 -  vector<DNSResourceRecord>::const_iterator d_cachehandleiter;
 +
 +  unsigned int d_cache_ttl, d_negcache_ttl;
 +  int domain_id;
 +  int d_ancount;
 +
 +  bool d_negcached;
 +  bool d_cached;
 +  static bool d_go;
 +  bool stale;
  
    int cacheHas(const Question &q, vector<DNSResourceRecord> &rrs);
    void addNegCache(const Question &q);
index ca4f71204da15a5678ec6f5aa651a442c0c33367,89888b0efdb7f752ca143bc84d09569222881e76..a743acc2ca91af9eef198b70f445d0e1f0576aea
@@@ -45,26 -45,26 +45,26 @@@ private
    void stackFile(const std::string& fname);
    unsigned makeTTLFromZone(const std::string& str);
    string getLineOfFile();
 +  struct filestate {
 +    filestate(FILE* fp, string filename) : d_fp(fp), d_filename(filename), d_lineno(0){}
 +    FILE *d_fp;
 +    string d_filename;
 +    int d_lineno;
 +  };
 +
    string d_reldir;
    string d_line;
-   string d_prevqname;
-   string d_zonename;
+   DNSName d_prevqname;
+   DNSName d_zonename;
 +  string d_templateline;
    vector<string> d_zonedata;
    vector<string>::iterator d_zonedataline;
 +  std::stack<filestate> d_filestates;
 +  parts_t d_templateparts;
    int d_defaultttl;
 +  uint32_t d_templatecounter, d_templatestop, d_templatestep;
    bool d_havedollarttl;
    bool d_fromfile;
 -  uint32_t d_templatecounter, d_templatestop, d_templatestep;
 -  string d_templateline;
 -  parts_t d_templateparts;
 -
 -  struct filestate {
 -    filestate(FILE* fp, string filename) : d_fp(fp), d_filename(filename), d_lineno(0){}
 -    FILE *d_fp;
 -    string d_filename;
 -    int d_lineno;
 -  };
 -  std::stack<filestate> d_filestates;
  };
  
  #endif