From: Kees Monshouwer Date: Sun, 17 Nov 2013 19:36:23 +0000 (+0100) Subject: remove unreferenced files from source tree X-Git-Tag: rec-3.6.0-rc1~341^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c091afe362542a881bef32731501f64fc417b42d;p=pdns remove unreferenced files from source tree for FILE in $(git ls-files pdns/*); do git grep $(basename "$FILE") > /dev/null || echo "would remove $FILE" done --- diff --git a/pdns/argtng.hh b/pdns/argtng.hh deleted file mode 100644 index 45489aefb..000000000 --- a/pdns/argtng.hh +++ /dev/null @@ -1,283 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include "namespaces.hh" -#include "namespaces.hh" - -#define decl(x,y) typeof((y)) (x) = (y) - -struct cond -{ - virtual bool operator()(const string& s) const=0; - virtual shared_ptr copy() const=0; - virtual ~cond() - { - } -}; - -struct Ok : public cond -{ - bool operator()(const string& s) const - { - return true; - } - shared_ptr copy() const - { - return shared_ptr(new Ok); - } -}; - -struct Empty : public cond -{ - bool operator()(const string& s) const - { - return s.empty(); - } - shared_ptr copy() const - { - return shared_ptr(new Empty); - } -}; - -struct IpAddress : public cond -{ - bool operator()(const string& s) const - { - static const regex r("^((25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)\\.){3}(25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)$"); - return regex_match(s,r); - } - shared_ptr copy() const - { - return shared_ptr(new IpAddress); - } -}; - -struct HostName : public cond -{ - bool operator()(const string& s) const - { - static const regex r("^([a-zA-Z0-9_-]\\.)?([a-zA-Z0-9_-]\\.?)*$"); - return regex_match(s,r); - } - shared_ptr copy() const - { - return shared_ptr(new HostName); - } -}; - - -struct Numeric : public cond -{ - bool operator()(const string& s) const - { - if(s.empty()) - return false; - - for(decl(i,s.begin());i!=s.end();++i) - if(!isdigit(*i)) - return false; - return true; - } - shared_ptr copy() const - { - return shared_ptr(new Numeric); - } -}; - -struct Switch : public cond -{ - bool operator()(const string& s) const - { - return (s=="on" || s=="off"); - } - shared_ptr copy() const - { - return shared_ptr(new Switch); - } -}; - - - - -struct And : public cond -{ - And(const cond& A, const cond& B) - : d_A(A.copy()), d_B(B.copy()) - { - } - - bool operator()(const string& s) const - { - return (*d_A)(s) && (*d_B)(s); - } - - shared_ptr copy() const - { - return shared_ptr(new And(*d_A, *d_B)); - } - shared_ptr d_A, d_B; - -}; - - -struct Or : public cond -{ - Or(const cond& A, const cond& B) - : d_A(A.copy()), d_B(B.copy()) - { - } - - - bool operator()(const string& s) const - { - return (*d_A)(s) || (*d_B)(s); - } - - shared_ptr copy() const - { - return shared_ptr(new Or(*d_A, *d_B)); - } - shared_ptr d_A, d_B; -}; - -struct Not : public cond -{ - Not(const cond& A) - : d_A(A.copy()) - { - } - - - bool operator()(const string& s) const - { - return !(*d_A)(s); - } - - shared_ptr copy() const - { - return shared_ptr(new Not(*d_A)); - } - shared_ptr d_A; -}; - - -const Not operator!(const cond &A) -{ - return Not(A); -} - -const And operator&&(const cond &A, const cond& B) -{ - return And(A,B); -} - -const Or operator||(const cond &A, const cond& B) -{ - return Or(A,B); -} - - - - -struct Argument -{ - Argument() - {} - - Argument(const cond& c, const string& val="") - : d_c(c.copy()), d_value(val) - {} - - shared_ptr d_c; - string d_value; -}; - -typedef runtime_error argument_exception; - -class ArgTng -{ -public: - void add(const string &name, const cond& c=Ok(), const string& def="") - { - d_content[name]=Argument(c,def); - } - - void constraints() - { - for(decl(i,d_content.begin());i!=d_content.end();++i) - if(!correct(i->first)) - throw runtime_error("variable '"+i->first+"' violates constraints with value '"+i->second.d_value+"'"); - - } - - void parse(int argc, char **argv) - { - for(int n=1;n d_content; - bool correct(const string& s) - { - return (*d_content[s].d_c)(d_content[s].d_value); - } - void parseString(const string& s) - { - static const regex r("^--([a-z0-9-]*)=(.*)$"); - match_results res; - if(!regex_match(s,res,r)) - throw argument_exception("argument item does not match, should be --var=val"); - - string var(res[1].first, res[1].second); - string val(res[2].first, res[2].second); - - if(!d_content.count(var)) - throw argument_exception("trying to set unknown variable '"+var+"'"); - if(!(*d_content[var].d_c)(val)) - throw argument_exception("trying to set variable '"+var+"' to illegal value '"+val+"'"); - - d_content[var].d_value=val; - } -}; - -#if 0 - -int main(int argc, char**argv) -try { - ArgTng at; - at.add("host", !Empty() && (IpAddress() || HostName()),"localhost"); - at.add("number", Numeric()); - at.parse(argc, argv); - at.constraints(); - - cout<<"Hostname="< d_capacity) { - delete[] d_storage; - d_storage = new char[newlen]; - } - d_fulllen = newlen; - d_offset=0; - memcpy(d_storage, rhs.d_storage, d_fulllen); - - return *this; -} - -DNSLabel::~DNSLabel() -{ - delete[] d_storage; -} - -DNSLabel::DNSLabel(const char* human) -{ - // FIXME: do the escaping thing - init(); - const char* labelStart=human; - const char* p; - for(p=human; *p; ++p) { - if(*p=='.') { - char labelLen = p - labelStart; - appendChar(labelLen); - appendRange(labelStart, labelLen); - labelStart=p+1; - } - } - if(labelStart != p) { // human input did not end on a trailing dot - char labelLen = p - labelStart; - appendChar(labelLen); - appendRange(labelStart, labelLen); - } - d_storage[d_fulllen++]=0; -} - -bool DNSLabel::validateStrict(const char* raw, unsigned int len) -{ - int result = validateConsume(raw, len); - if(result < 0 || (unsigned int)result != len) - return false; - return true; -} - -int DNSLabel::validateConsume(const char* raw, unsigned int maxLen) -{ - if(!maxLen) - return -1; // shortest ok label is: '\x00' - - const unsigned char* p = (const unsigned char*) raw; - - for(;;) { - if(p > (const unsigned char*)raw + maxLen) // beyond the end - return -1; - - // cerr<<(int)*p<= 0xc0 && p + 1 < (const unsigned char*)raw + maxLen) { - // unsigned int offset=(*p & ~0xc0) * 0xff + *(p+1); - ++p; - // cerr<<"Wants to refer to offset "< 64) // label length too long, or a compression pointer - return -1; - - if(!*p) { // final label, return bytes consumed - return 1 + (p - (const unsigned char*)raw); - } - - p += *p + 1; - } - return -1; // we should not get here, but if we do, it's bad -} - - -string DNSLabel::human() const -{ - // FIXME: do the escaping thing - const char* p = getStart(); - char labelLen; - - if(!*p) - return "."; - - string ret; - for(;;) { - labelLen = *p; - // cerr<<"human, labelLen: "<<(int) labelLen<> 1; // handle 2 bit numbers - x |= x >> 2; // handle 4 bit numbers - x |= x >> 4; // handle 8 bit numbers - x |= x >> 8; // handle 16 bit numbers - x |= x >> 16; // handle 32 bit numbers - x++; - - return x; -} -void DNSLabel::expandCapacity(unsigned int len) -{ - if(!len) - d_capacity *= 2; - else { - d_capacity = roundUpToNextPowerOfTwo(d_capacity + len); - } - char *newStorage = new char[d_capacity]; - memcpy(newStorage, d_storage, d_fulllen); - delete[] d_storage; - d_storage=newStorage; -} - -DNSLabel DNSLabel::createFromBuffer(const char* raw, unsigned int* len) -{ - int result = DNSLabel::validateConsume(raw, *len); - if(result < 0) - throw std::runtime_error("raw input to DNSLabel factory was invalid"); - *len = (unsigned int) result; - return DNSLabel(raw, result); -} - -void DNSLabel::chaseLabel(const char* raw, const char* beginPacket, unsigned int packetLength, unsigned int* len, bool updateLen) -{ - const unsigned char* p = (const unsigned char*) raw; - - for(;;) { - if(p > (const unsigned char*)beginPacket + packetLength) // beyond the end - throw std::range_error("label begins beyond end of packet"); - - if(*p >= 0xc0 && p + 1 < (const unsigned char*)beginPacket + packetLength) { - unsigned int offset=(*p & ~0xc0) * 256 + *(p+1); - if(offset < 12) - throw std::range_error("compression pointer to before beginning of content"); - offset -= 12; - // cerr<<"new offset: "<= p) { - throw std::runtime_error("looping or forward compression pointer"); - } - - p+=2; - if(updateLen) { - *len = (p - (const unsigned char*)raw); - } - - chaseLabel(beginPacket + offset, beginPacket, packetLength, len, false); - return; - } - if(*p > 64) // label length too long, or a compression pointer - throw std::range_error("label too long"); - - if(!*p) { // final label, setbytes consumed - appendChar(0); - if(updateLen) - *len = 1 + (p - (const unsigned char*)raw); - return; - } - appendChar(*p); - appendRange((const char*)p+1, *p); - p += *p + 1; - } - // we should not get here, but if we do, it's bad -} - -DNSLabel::DNSLabel(const char* raw, const char* beginPacket, unsigned int packetLength, unsigned int* len) -{ - init(); - if(!*len) { - throw std::range_error("void label"); // shortest ok label is: '\x00' - } - - chaseLabel(raw, beginPacket, packetLength, len, true); -} - -#if 0 -void endsOn(const DNSLabel& first, const DNSLabel& second) -{ - cerr<<"Does '"< -#include -#include -#include -#include -using std::string; -using std::cerr; -using std::endl; - - -/* the idea of dnslabel is that we guard our input, and from that point - * onwards, trust the contents of d_storage. - * - * On input we deal with escapes etc, on output we re-escape. - * This can be slow since we hope with all our might not to be - * using the 'human' interfaces too much, and keep everything as a - * native DNS label all the time. - * - * The goal for DNSLabel is to be 'holier than thou' and adhere - * to all relevant RFCs. This means implementing the really odd DNS case - * sensitivity rules, doing all the escaping properly and deal - * with embedded nuls. - * - * Design - * As a special speedup, we implement 'chopping' by having an offset - * counter. This means that the oft-repeated 'www.powerdns.com.' - * 'powerdns.com.', 'com.', '.' sequence does not involve any mallocs. - */ -class DNSLabel -{ - public: - explicit DNSLabel(const char* human); - explicit DNSLabel(const std::string& human); - DNSLabel(const char* raw, unsigned int length); - DNSLabel(const DNSLabel& rhs); - DNSLabel(const char* raw, const char* beginPacket, unsigned int packetLength, unsigned int* len); - DNSLabel(); - ~DNSLabel(); - string human() const; - string binary() const; - bool endsOn(const DNSLabel& rhs) const; - bool chopOff(); - bool operator<(const DNSLabel& rhs) const; - bool operator==(const DNSLabel& rhs) const; - DNSLabel& operator=(const DNSLabel& rhs); - int project(char* target, unsigned int length); - static int validateConsume(const char* raw, unsigned int len); - static bool validateStrict(const char* raw, unsigned int len); - - static DNSLabel createFromBuffer(const char* raw, unsigned int* len); - private: - char* d_storage; - unsigned int d_fulllen; - unsigned int d_offset; - unsigned int d_capacity; - void init(unsigned int len=64); - unsigned int getLength() const - { - return d_fulllen - d_offset; - } - - const char* getStart() const - { - return d_storage + d_offset; - } - - void appendChar(char c) - { - if(d_fulllen == d_capacity) - expandCapacity(); - d_storage[d_fulllen++]= c; - } - void appendRange(const char* ptr, unsigned int len) - { - if(d_fulllen + len > d_capacity) - expandCapacity(len); - memcpy(d_storage + d_fulllen, ptr, len); - d_fulllen += len; - } - - void expandCapacity(unsigned int len=0); - void chaseLabel(const char* raw, const char* beginPacket, unsigned int packetLength, unsigned int* len, bool updateLen); -}; diff --git a/pdns/dnsrecord.proto b/pdns/dnsrecord.proto deleted file mode 100644 index 653b951e7..000000000 --- a/pdns/dnsrecord.proto +++ /dev/null @@ -1,20 +0,0 @@ -package DNSProtoBuf; - -message DNSResourceRecord { - required string qname = 1; - required int32 qtype = 2; - required string content = 3; - required int32 ttl = 4; - optional int32 priority = 5; - enum Place { - QUESTION = 0; - ANSWER = 1; - AUTHORITY = 2; - ADDITIONAL = 3; - } - required Place place = 6; -} - -message DNSResourceRecordVector { - repeated DNSResourceRecord dnsrecord = 1; -} diff --git a/pdns/rdtsc.hh b/pdns/rdtsc.hh deleted file mode 100644 index c65dee3b0..000000000 --- a/pdns/rdtsc.hh +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef PDNS_RDTSC_HH -#define PDNS_RDTSC_HH - -#define rdtsc() \ -({ \ - unsigned long lowPart, highPart; \ - __asm__ __volatile__("cpuid"); \ - __asm__ __volatile__("rdtsc" : "=a" (lowPart), "=d" (highPart)); \ - ((((unsigned long long) highPart) << 32) | lowPart); \ -}) - - - -#define RDTSC(qp) \ -do { \ - unsigned long lowPart, highPart; \ - __asm__ __volatile__("cpuid"); \ - __asm__ __volatile__("rdtsc" : "=a" (lowPart), "=d" (highPart)); \ - qp = (((unsigned long long) highPart) << 32) | lowPart; \ -} while (0) - -#endif diff --git a/pdns/recursor_memcached.cc b/pdns/recursor_memcached.cc deleted file mode 100644 index 6b3aa1d7c..000000000 --- a/pdns/recursor_memcached.cc +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include "statbag.hh" -#include "iputils.hh" -#include "recursor_memcached.hh" -#include - -#include "namespaces.hh" -using boost::lexical_cast; - -MemcachedCommunicator::MemcachedCommunicator(const std::string& servers) -{ - d_socket=socket(AF_INET, SOCK_DGRAM, 0); - Utility::setCloseOnExec(d_socket); - - ComboAddress remote(servers, 11211); - if(connect(d_socket, (struct sockaddr*)&remote, remote.getSocklen()) < 0) - unixDie("connecting to remote memcached server '"+remote.toStringWithPort()+"'"); -} - -string MemcachedCommunicator::get(const std::string& key) -{ - cerr<<"Looking up: '"<(value.length())+"\r\n"+value+"\r\n"); - cerr<<"Message is: '"< - - -class MemcachedCommunicator -{ -public: - MemcachedCommunicator(const std::string& servers); - string get(const std::string& key); - void set(const std::string& key, const std::string& value); - struct UDPHeader - { - UDPHeader() - { - memset(this, 0, sizeof(*this)); - } - uint16_t id; - uint16_t seqNo; - uint16_t totalDgrams; - uint16_t mbZero; - }; - -private: - int d_socket; -}; -#endif diff --git a/pdns/spoofpol.cc b/pdns/spoofpol.cc deleted file mode 100644 index d2d2ad1ae..000000000 --- a/pdns/spoofpol.cc +++ /dev/null @@ -1,23 +0,0 @@ -#include "spoofpol.hh" - -void SpoofPolicy::report(const ComboAddress& remote, const std::string& auth, int policy, const struct timeval& tv) -{ - SpoofEntry se; - se.ttd = tv.tv_sec + 3600; - se.policy = policy; - d_spoofmap[make_pair(remote,auth)] = se; -} - -int SpoofPolicy::getPolicy(const ComboAddress& remote, const std::string& auth, const struct timeval& tv) -{ - spoofmap_t::iterator iter = d_spoofmap.find(make_pair(remote,auth)); - if(iter == d_spoofmap.end()) - return 0; - - if(iter->second.ttd > tv.tv_sec) - return iter->second.policy; - else - d_spoofmap.erase(iter); - - return 0; -} diff --git a/pdns/spoofpol.hh b/pdns/spoofpol.hh deleted file mode 100644 index 96f3e3c88..000000000 --- a/pdns/spoofpol.hh +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef PDNS_SPOOFPOL_HH -#define PDNS_SPOOFPOL_HH -#include -#include -#include -#include "iputils.hh" -#include - -class SpoofPolicy -{ -public: - void report(const ComboAddress& remote, - const std::string& auth, - int policy, - const struct timeval& ); - int getPolicy(const ComboAddress& remote, const std::string& aith, const struct timeval& ); - -private: - struct SpoofEntry - { - time_t ttd; - int policy; - }; - typedef std::map, SpoofEntry > spoofmap_t; - spoofmap_t d_spoofmap; -}; - -#endif