00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef DNSBL_H
00011 #define DNSBL_H
00012 #pragma warning(disable:4786)
00013 #include <map>
00014 #include <string>
00015 #include <abuse/Url.h>
00016 #include <abuse/CriticalSection.h>
00017 #include <abuse/RefCounted.h>
00018
00019 class DnsblCache;
00020
00021
00022 typedef char Result;
00023
00024 #define NOTLISTED (Result)0x00
00025 #define VIRUSSOURCE (Result)0xFE//0b1111 1110
00026 #define LISTEDUNKNOWN (Result)0x40//0b01000000
00027 #define SPAMSOURCE (Result)0x81//0b1000 0001
00028 #define SPAMVERTIZED (Result)0x03//0b00000011
00029 #define SPAMWARE (Result)0x05//0b00000101
00030 #define OPENPROXY (Result)0x88//0b10001000
00031 #define DIALUP (Result)0xa0//0b10100000
00032 #define OPENRELAY (Result)0x90//0b10010000
00033 #define FROMMAIL (Result)0x80//0b10000000
00034 #define SPAM (Result)0x01//0b00000001
00035
00036 #define MAIL_ORIGIN(n) (n & FROMMAIL)
00037 #define SPAM_ORIGIN(n) (n & SPAM)
00038 #define ISLISTED(n) (n)
00039 #define IS(what,n) ((n & what)==what)
00040
00041 class Dnsbl
00042 {
00043 public:
00044 Dnsbl(const std::string& zone,Result ifListed,const std::string& desc="");
00045 Dnsbl(const std::string& zone,const std::map<Url,Result>& results,const std::string& desc="");
00046 virtual ~Dnsbl();
00047 void setCache(DnsblCache* cache);
00048 const DnsblCache* getCache()const;
00049 Result check(const Url& url, std::string* comments=NULL)const throw(net_error);
00050 const std::string& name()const;
00051 std::map<Url,Result> getResults()const;
00052 const std::string& getDescription()const;
00053 void setDescription(const std::string& desc);
00054 void addResult(const Url& url,Result res);
00055 void addResults(const std::map<Url,Result>& results);
00056 void clearResults();
00057 const static Url ANY;
00058 private:
00059 std::string m_zone;
00060 std::string m_description;
00061 typedef std::map<Url,Result> ResultMap;
00062 ResultMap m_results;
00063 mutable CriticalSection m_section;
00064 mutable RefCounted<DnsblCache> m_cache;
00065 };
00066
00067 #endif//DNSBL_H