{
d_empty=false;
d_recurse=0;
+ d_storage.reserve(strlen(p)+1);
auto labels = segmentDNSName(p);
for(const auto& e : labels)
appendRawLabel(e);
if(newpos < offset) {
if (++d_recurse > 100)
throw std::range_error("Abort label decompression after 100 redirects");
- packetParser(opos, len, newpos, true);
+ packetParser(opos, len, newpos, true);
} else
throw std::range_error("Found a forward reference during label decompression");
pos++;
if (std::distance(us,d_storage.cend()) == static_cast<unsigned int>(parent.d_storage.size())) {
auto p = parent.d_storage.cbegin();
for(; us != d_storage.cend(); ++us, ++p) {
- if(tolower(*p) != tolower(*us))
+ if(dns2_tolower(*p) != dns2_tolower(*us))
return false;
}
return true;
DNSName DNSName::makeRelative(const DNSName& zone) const
{
DNSName ret(*this);
- if (ret.isPartOf(zone)) {
- ret.d_storage.erase(ret.d_storage.size()-zone.d_storage.size());
- } else
- ret.clear();
+ ret.makeUsRelative(zone);
return ret;
}
+void DNSName::makeUsRelative(const DNSName& zone)
+{
+ if (isPartOf(zone)) {
+ d_storage.erase(d_storage.size()-zone.d_storage.size());
+ }
+ else
+ clear();
+}
DNSName DNSName::labelReverse() const
{
// #include "dns.hh"
// #include "logger.hh"
-// #include <ext/vstring.h>
+//#include <ext/vstring.h>
/* Quest in life:
accept escaped ascii presentations of DNS names and store them "natively"
std::vector<std::string> getRawLabels() const; //!< Individual raw unescaped labels
bool chopOff(); //!< Turn www.powerdns.com. into powerdns.com., returns false for .
DNSName makeRelative(const DNSName& zone) const;
+ void makeUsRelative(const DNSName& zone);
DNSName labelReverse() const;
bool isWildcard() const;
unsigned int countLabels() const;
inline bool canonCompare(const DNSName& rhs) const;
private:
- // typedef __gnu_cxx::__sso_string string_t;
+ //typedef __gnu_cxx::__sso_string string_t;
typedef std::string string_t;
bool slowCanonCompare(const DNSName& rhs) const;
string_t d_storage;