Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Analyze.h

Go to the documentation of this file.
00001 #ifndef PRIVATE_ANALYZE_H
00002 #define PRIVATE_ANALYZE_H
00003 #include <exception>
00004 #include <string>
00005 #include <list>
00006 #include <abuse/Url.h>
00007 #include <abuse/Dnsbl.h>
00008 #include <abuse/Received.h>
00009 #include <abuse/Event.h>
00010 #include <abuse/ZeWhois.h>
00011 #include <abuse/ThreadedDnsbl.h>
00012 #include <abuse/AbuseAddiesCache.h>
00013 #include <abuse/RefCounted.h>
00014 #include <map>
00015 #include <memory>
00016 #include <abuse/VirtStream.h>
00017 
00019 
00020 
00021 typedef struct {
00022         int cntAnalyzed;                
00023         int cntGetContacts;                     
00024         int cntUnverifiedD;                     
00025         int cntUnverifiedMX;            
00026         int cntArinErr;                         
00027         int cntAbuseNetErr;                     
00028         int cntCyberabuseErr;           
00029         int cntNoAbuseNetContacts;      
00030         int cntNoCyberabuseContacts;
00031         int cntVerifyAbuseNetErr;
00032         int cntOnlineAbuseErr;
00033         int cntMassiveCheckErr;         
00034         int cntWhoisThreadErr;          
00035         int cntLastServerNotOK;
00036 } error_Cnts;
00037 
00039 enum EmailTrust{
00040         NONE=0,                 
00041         NOINFO=30,              
00042         UNVERIFIED=40,  
00043         NONABUSE=60,    
00044         ABUSENET=80,    
00045         CACHE=90,               
00046         TOTALLY=100             
00047 };
00048 
00049 class Win32Initializer;
00050 
00052 struct AbuseDesks
00053 {
00054         EmailTrust trustLevel;                          
00055         int receivedLineCnt;                            
00056         Url url;                                                        
00057         Result why;                                                     
00058         std::list<std::string> abusemails;      
00059         ZeWhois::WhoisList whoisinfo;           
00060         AbuseDesks(const Url& _url):url(_url),trustLevel(NONE){}
00061 };
00062 
00064 
00068 class AnalyzerFeedback
00069 {
00070 public:
00072         virtual void onStop()const=0;
00074 
00077         virtual void onComplete(std::list<AbuseDesks> abuseDesks)const=0;
00079         virtual void onStart()const=0;
00080 };
00081 
00083 
00088 class Analyzer
00089 {
00090 public:
00092         enum Option{
00093                 VIEWWHOIS,                      
00094                 ABUSEDETAILS,           
00095                 USEONLYCACHE,           
00096                 NODISPLAYOUTPUT         
00097         };
00099         enum Type{
00100                 EMAILHEADER, 
00101                 IP_URL           
00102         };
00104 
00108         static void setDnsbls(std::list<Dnsbl> lst);
00110 
00114         static void addDnsbl(const Dnsbl& to_add);
00116 
00120         static void removeDnsbl(const std::string& name);
00122 
00129         static void analyze(const std::string& is,VirtStream& hOut,const AnalyzerFeedback* listener=NULL,Type type=EMAILHEADER)/*throw(std::exception)*/;
00131         static void stop();
00133 
00137         static bool getBoolOption(Option opt);
00139 
00143         static void setOption(Option opt,bool newvalue);
00145 
00149         static void setAbuseCache(AbuseAddiesCache* cache);
00151 
00158         static void setSafeAddresses(const std::list<UrlRange>& safe);
00160 
00164         static AbuseAddiesCache* getAbuseCache();
00166 
00169         static void getVersionStrings(std::string& versionData);
00171 
00174         static void Analyzer::setThreshold(const int value);
00176 
00179         static void Analyzer::getErrorCnts(error_Cnts& cnts);
00180 private:
00182         Analyzer(); //only a static class...
00184         static const char* NOTSET;
00186         static const AnalyzerFeedback* listener;
00188         static std::list<RefCounted<ThreadedDnsbl> > dnsbls;
00190         static Event eTerminate;
00192         static void doAnalyzeIP_URL(const std::string& is,VirtStream& hOut)throw(std::exception);
00194 
00200         static void doAnalyze(const std::string& is,VirtStream& hOut)throw(std::exception);
00202 
00208         static Result massiveCheck(const Url& url,std::list<std::string>* names=NULL);
00210 
00215         static void dump(VirtStream& ss,const Received& curr);
00217 
00221         static THREADRETVALUE threadBegin(LPVOID lpv);
00223 
00230         static int checkChain(const Received& curr,const Received& prev,VirtStream& os,int initialLevel=0);
00232         static bool checkMX(const Received& curr,VirtStream& os);
00234         static EmailTrust Analyzer::checkAbuseOnline(const Url& thisUrl,std::list<std::string>& contacts,VirtStream& os);
00236         static EmailTrust getAbuse(ZeWhois::WhoisList& we,std::list<std::string>& emails,Url &thisUrl,VirtStream& os);
00238         typedef std::map<Option,bool>BoolOptions;
00239         friend class Win32Initializer;
00241         static BoolOptions& boolOptions();
00243         static void init();     
00245         static AbuseAddiesCache* m_cache;
00247         static std::list<UrlRange> m_safeAddies;
00249         static bool isTrusted(const Received& rec);
00251         static bool canBeDynamic(const Url& url,const std::string& declared_to_be);
00252 /* OK
00253  * Those are the thresholds for the Received: line affidability
00254  * Can be #defines or const static vars, but I keep'em as static mutable members
00255  * for customization via the user interface
00256 */
00257         static int THRESHOLD;
00258 
00259         static int NAMEMISMATCH;
00261         static int NAMELOOKSDYNAMIC;
00263         static int BLACKLISTED;
00265         static int RECBYMISMATCH;
00267         static int SIMILARNAMES;
00269         static int SAMEDOMAINS;
00270 
00271 };
00273 #endif

Generated on Thu Jun 16 00:13:14 2005 for Netlib for Abuse! by  doxygen 1.4.3