Spaces:
Paused
Paused
File size: 1,171 Bytes
2faa101 |
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 |
#ifndef PROXYSERVER_TCP_CLIENT_H
#define PROXYSERVER_TCP_CLIENT_H
#include "hv/hloop.h"
#include "hv/TcpClient.h"
#include "bolt/crypt.h"
class tcpBoltConfig
{
public:
uint32_t request_id;
uint32_t session_id;
std::string signal_id;
std::string data_st;
bool encrypt = false;
CRYPT_TYPE ept_type;
char ept_key;
};
class TcpClientBolt {
public:
TcpClientBolt(hio_t* _io) : io(_io) {}
bool hasHandshake() { return cli.isConnected(); }
bool handShake(void* buf, int readbytes);
int send(char* data, int size);
void close();
private:
bool connect(struct sockaddr* addr);
void onConnection(const hv::SocketChannelPtr &channel);
void onDisConnection(const hv::SocketChannelPtr &channel);
void onRecv(const hv::SocketChannelPtr &channel, hv::Buffer *buf);
void onWrited(const hv::SocketChannelPtr &channel, hv::Buffer *buf);
private:
hv::TcpClient cli;
hio_t* io;
struct sockaddr_in t_addr, u_addr;
uint32_t session_id;
bool is_bolt_server;
tcpBoltConfig *config;
};
#endif //PROXYSERVER_TCP_CLIENT_H |