00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SOCKETS_MinionSocket_H
00024 #define _SOCKETS_MinionSocket_H
00025 #include "sockets-config.h"
00026 #ifdef HAVE_OPENSSL
00027
00028
00029
00030 #include "CTcpSocket.h"
00031 #include "Parse.h"
00032
00033 #include "ISocketHandler.h"
00034
00035 #ifdef SOCKETS_NAMESPACE
00036 namespace SOCKETS_NAMESPACE {
00037 #endif
00038
00039
00040 class ICrypt;
00041
00042
00043
00044 typedef std::vector<unsigned long> ulong_v;
00045
00048 class MinionSocket : public CTcpSocket
00049 {
00050 public:
00051 MinionSocket(ISocketHandler& );
00052 MinionSocket(ISocketHandler&,const std::string&,ipaddr_t,port_t);
00053 ~MinionSocket();
00054
00055
00056
00057 void SendConnectList();
00058
00059 void SetMyIpPort(ipaddr_t l,port_t s) { my_ip = l; my_port = s; }
00060
00061 void SendHello(const std::string&);
00062 ipaddr_t GetIP() { return m_ip; }
00063 port_t GetPort() { return m_port; }
00064
00065 void OnAccept();
00066
00067 const std::string& GetRemoteId() { return m_remote_id; }
00068 virtual bool OnVerifiedLine(const std::string& cmd,Parse& pa);
00069 void StopMessage(bool x = true) { m_bStopMessage = x; }
00070
00071 long GetMessageCount() { return m_messagecount; }
00072 long GetSeenCount() { return m_seencount; }
00073 virtual void Notify(const std::string& ) {}
00074
00075 void SetRemoteHostId(long x) { m_remote_host_id = x; }
00076 long GetRemoteHostId() { return m_remote_host_id; }
00077
00078 virtual int GetMaxConnections() = 0;
00079 virtual unsigned char *GetKey_m2minion() = 0;
00080
00081 ipaddr_t GetMyIP() { return my_ip; }
00082 port_t GetMyPort() { return my_port; }
00083 void SetRemoteId(const std::string& x) { m_remote_id = x; }
00084 void SetIP(ipaddr_t x) { m_ip = x; }
00085 void SetPort(port_t x) { m_port = x; }
00086 void SetIDVerified(bool x = true) { m_bIDVerified = x; }
00087
00088 protected:
00089 void OnDelete();
00090 void OnConnect();
00091 void OnLine(const std::string& line);
00092
00093 private:
00094 MinionSocket& operator=(const MinionSocket& ) { return *this; }
00095 std::string m_remote_id;
00096 ipaddr_t m_ip;
00097 port_t m_port;
00098 ipaddr_t my_ip;
00099 port_t my_port;
00100 bool m_bIDVerified;
00101 std::list<std::string> m_clist;
00102 bool m_bStopMessage;
00103 long m_messagecount;
00104 long m_seencount;
00105 long m_remote_host_id;
00106 };
00107
00108
00109 #ifdef SOCKETS_NAMESPACE
00110 }
00111 #endif
00112
00113 #endif // HAVE_OPENSSL
00114 #endif // _SOCKETS_MinionSocket_H