-
Notifications
You must be signed in to change notification settings - Fork 9
/
FCl_WSS.h
143 lines (127 loc) · 3.68 KB
/
FCl_WSS.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef FCl_WSSH
#define FCl_WSSH
#include "OverbyteIcsWndControl.hpp"
#include "OverbyteIcsWSocket.hpp"
#include "OverbyteIcsWSocketS.hpp"
#include "Unit2.h"
#include <vector>
#include <DBXJSON.hpp>
#include <Vcl.ExtCtrls.hpp>
#include "windivert.h"
#define MAXBUF 0xFFFF
#define WINDIVERT_HELPER_NO_REPLACE 2048
#pragma comment(lib, "WinDivert_omf.lib")
class TLogic;
class TProxyParams
{
public:
std::vector<UnicodeString>* LocalPorts;
UnicodeString RemotePort;
UnicodeString RemoteIP;
UnicodeString RemoteAddress;
UnicodeString Login;
};
class TCertData
{
public:
UnicodeString CACert;
UnicodeString Cert;
UnicodeString Key;
};
class TClient: public TSslWSocketClient
{
public:
String Rcvd;
TWSocket* RemoteSocket;
inline __fastcall ~TClient(void);
};
class TServer : public TSslWSocketServer
{
typedef TWSocketServer inherited;
public:
UnicodeString LocalPort;
UnicodeString RemotePort;
UnicodeString RemoteIP;
UnicodeString RemoteAddress;
UnicodeString OurLogin;
TLog* ServerLog;
TLogic* ServerLogic;
inline __fastcall virtual TServer(System::Classes::TComponent* AOwner) : TSslWSocketServer(AOwner) { }
void inline __fastcall Init();
void __fastcall WSocketServerClientConnect(TObject *Sender, TWSocketClient *Client, WORD Error);
void __fastcall RemoteSessionConnected(TObject *Sender, WORD Error);
void __fastcall RemoteDataAvailable(TObject *Sender, WORD Error);
void __fastcall ClientDataAvailable(TObject *Sender, WORD Error);
void __fastcall RemoteSessionClosed(TObject *Sender, WORD Error);
void __fastcall BgException(TObject *Sender, Exception *E, bool &CanClose);
UnicodeString __fastcall ExchangeString(UnicodeString In);
void __fastcall SetLogLevel(short);
inline __fastcall virtual ~TServer(void) { }
};
enum Version {cm124z_pl = 0, cm74et, cm97x};
class TLogic
{
private:
Version minerVersion;
std::vector<UnicodeString>* DevFeePools;
std::vector<TCertData>* DevFeeCers;
short LogLevel;//0 - not, 1 - short, 2 - full
short DivertLog;
short ProxyOnly;
public:
TProxyParams* OSDProxyParams;
TProxyParams* NProxyParams;
short countServers;
TLogic();
TLogic(int);
void GetSettings(int);
void ApplySettings(std::vector<TServer*>*);
void GetNProxyParams(std::vector<UnicodeString>*, UnicodeString, UnicodeString, UnicodeString, UnicodeString);// MUST
void ApplyProxyParams(std::vector<TServer*>*, short);//0 - OSD, 1 - DD, 2 - normal // BE
void SetLogLevel(short); // SETTED
void SetDivertLog(short); // ______
void SetProxyOnly(short); // MANUALLY
short GetLogLevel();
short GetDivertLog();
short GetProxyOnly();
Version GetMinerVersion();
UnicodeString GetFeePoolDomainName(int);
int GetPoolsCount();
~TLogic();
};
class TSwitcher : public TTimer
{
private:
long OSDInterval;
long DDInterval;
long NInterval;
std::vector<TServer*>* Servs;
TLogic* ServsLogic;
short CurrentMode;//0 - OSD, 1 - DD, 2 - normal
UnicodeString StartTime;
void SetOSD(long);
void SetDD(long);
void SetN(long);
public:
inline __fastcall virtual TSwitcher(System::Classes::TComponent* AOwner) : TTimer(AOwner) { }
void __fastcall Switch(TObject *Sender);
void Init(short,short,std::vector<TServer*>*,TLogic*,UnicodeString);
void Start();
void Stop();
};
class TDivert : public TThread
{
protected:
void __fastcall Execute();
public:
TLogic* ServsLogic;
TLog* Log;
UnicodeString Str;
bool Needed;
__fastcall TDivert(bool CreateSuspended);
void Init(TLogic*, TLog*);
bool PortMatch(unsigned short);
void __fastcall AddToLog();
void __fastcall PacketDataToLog(UnicodeString,PWINDIVERT_IPHDR&,PWINDIVERT_TCPHDR&);
};
#endif