From b864f69ce98841fd54e2328b49e34b5be49525b8 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 12 Jul 2006 12:20:36 +0000 Subject: Added class Resolver (needs testing) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4353 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/dns.h | 31 +++++++++++++++++++++++++++++++ include/socketengine.h | 1 + 2 files changed, 32 insertions(+) (limited to 'include') diff --git a/include/dns.h b/include/dns.h index b0dc3636f..89dd4e270 100644 --- a/include/dns.h +++ b/include/dns.h @@ -29,6 +29,14 @@ struct dns_ip4list dns_ip4list *next; }; +enum ResolverError +{ + RESOLVER_NOERROR = 0, + RESOLVER_NSDOWN = 1, + RESOLVER_NXDOMAIN = 2, + RESOLVER_NOTREADY = 3 +}; + /** The DNS class allows fast nonblocking resolution of hostnames * and ip addresses. It is based heavily upon firedns by Ian Gulliver. @@ -101,6 +109,29 @@ public: void SetNS(const std::string &dnsserver); }; +class Resolver : public Extensible +{ + private: + DNS Query; + std::string input; + bool fwd; + std::string server; + int fd; + std::string result; + public: + Resolver(const std::string &source, bool forward, const std::string &dnsserver); + virtual ~Resolver(); + virtual void OnLookupComplete(const std::string &result); + virtual void OnError(ResolverError e); + + bool ProcessResult(); + int GetFd(); +}; + +void init_dns(); +void dns_deal_with_classes(int fd); +bool dns_add_class(Resolver* r); + /** This is the handler function for multi-threaded DNS. * It cannot be a class member as pthread will not let us * create a thread whos handler function is a member of diff --git a/include/socketengine.h b/include/socketengine.h index bbd34a302..e07642fa1 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -44,6 +44,7 @@ const char X_LISTEN = 1; const char X_ESTAB_CLIENT = 2; const char X_ESTAB_MODULE = 3; const char X_ESTAB_DNS = 4; +const char X_ESTAB_CLASSDNS = 5; /** * To indicate that a socket is readable, we -- cgit v1.2.3