diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 8 | ||||
-rw-r--r-- | include/dns.h | 31 | ||||
-rw-r--r-- | include/modules.h | 7 | ||||
-rw-r--r-- | include/servers.h | 3 |
4 files changed, 36 insertions, 13 deletions
diff --git a/include/config.h b/include/config.h index 554959e38..947daa3e5 100644 --- a/include/config.h +++ b/include/config.h @@ -394,6 +394,10 @@ class CoreExport ServerConfig /* Max length of channel names */ unsigned ChanLen; + /* User and group to run as */ + Anope::string User; + Anope::string Group; + /* Casemapping to use */ Anope::string CaseMap; @@ -494,8 +498,10 @@ class CoreExport ServerConfig /* Nameserver to use for resolving hostnames */ Anope::string NameServer; - /* TIme before a DNS query is considered dead */ + /* Time before a DNS query is considered dead */ time_t DNSTimeout; + /* The port DNS queries come in on */ + int DNSPort; /* Prefix of guest nicks when a user gets forced off of a nick */ Anope::string NSGuestNickPrefix; diff --git a/include/dns.h b/include/dns.h index 3102ec72c..062fed26f 100644 --- a/include/dns.h +++ b/include/dns.h @@ -95,7 +95,6 @@ struct CoreExport DNSQuery DNSQuery(); DNSQuery(const Question &q); - DNSQuery(const DNSPacket &p); }; /** The request @@ -124,7 +123,7 @@ class CoreExport DNSRequest : public Timer, public Question void Tick(time_t) anope_override; }; -/** A full packet sent or recieved to/from the nameserver, may contain multiple queries +/** A full packet sent or recieved to/from the nameserver */ class DNSPacket : public DNSQuery { @@ -139,12 +138,14 @@ class DNSPacket : public DNSQuery public: static const int HEADER_LENGTH = 12; - /* Our 16-bit id for this header */ + /* Source or destination of the packet */ + sockaddrs addr; + /* ID for this packet */ unsigned short id; - /* Flags on the query */ + /* Flags on the packet */ unsigned short flags; - DNSPacket(); + DNSPacket(const sockaddrs &a); void Fill(const unsigned char *input, const unsigned short len); unsigned short Pack(unsigned char *output, unsigned short output_size); }; @@ -155,20 +156,19 @@ class CoreExport DNSManager : public Timer, public Socket { typedef std::multimap<Anope::string, ResourceRecord, ci::less> cache_map; cache_map cache; - sockaddrs addrs; - public: + std::deque<DNSPacket *> packets; + public: + sockaddrs addrs; std::map<unsigned short, DNSRequest *> requests; - static const int DNSPort = 53; - DNSManager(const Anope::string &nameserver, int port); ~DNSManager(); - bool ProcessRead(); + bool ProcessRead() anope_override; - bool ProcessWrite(); + bool ProcessWrite() anope_override; /** Add a record to the dns cache * @param r The record @@ -189,6 +189,15 @@ class CoreExport DNSManager : public Timer, public Socket */ void Cleanup(Module *mod); + /** Get the list of packets pending to be sent + */ + std::deque<DNSPacket *>& GetPackets(); + + /** Queues a packet for sending + * @param p The packet + */ + void SendPacket(DNSPacket *p); + /** Does a BLOCKING DNS query and returns the first IP. * Only use this if you know what you are doing. Unless you specifically * need a blocking query use the DNSRequest system diff --git a/include/modules.h b/include/modules.h index 29da80cf3..3827e9234 100644 --- a/include/modules.h +++ b/include/modules.h @@ -917,6 +917,11 @@ class CoreExport Module : public Extensible */ virtual void OnLog(Log *l) { } + /** Called when a DNS request (question) is recieved. + * @param req The dns request + */ + virtual void OnDnsRequest(DNSPacket &req) { } + /** Called when a channels modes are being checked to see if they are allowed, * mostly to ensure mlock/+r are set. * @param c The channel @@ -995,7 +1000,7 @@ enum Implementation I_OnServerQuit, I_OnTopicUpdated, I_OnEncrypt, I_OnDecrypt, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, - I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnLog, + I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnLog, I_OnDnsRequest, I_OnSerializeCheck, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate, I_END diff --git a/include/servers.h b/include/servers.h index 94dc5491e..36da6bbd8 100644 --- a/include/servers.h +++ b/include/servers.h @@ -63,6 +63,9 @@ class CoreExport Server : public Flags<ServerFlag> ~Server(); public: + /* Number of users on the server */ + unsigned Users; + /** Delete this server with a reason * @param reason The reason */ |