Spaces:
Paused
Paused
class UdpBoltConfig | |
{ | |
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 UdpClientProxy | |
{ | |
public: | |
UdpClientProxy(struct sockaddr_in t_addr, struct sockaddr_in u_addr, uint32_t session_id) : t_addr(t_addr), u_addr(u_addr), session_id(session_id) {} | |
hio_t *getClientIO() { return cli_io; } | |
bool init(hloop_t* loop); | |
void close(); | |
bool isDns() { | |
return ntohs(t_addr.sin_port) == 53; | |
}; | |
private: | |
void onRecv(void* buf, int readbytes); | |
void onWrited(const void* buf, int writebytes); | |
void onClosed(); | |
public: | |
struct sockaddr_in t_addr, u_addr; | |
private: | |
hio_t *cli_io; | |
htimer_t* timer; | |
uint32_t session_id; | |
long long ts; | |
}; | |
class UdpServerBoltProxy | |
{ | |
public: | |
UdpServerBoltProxy(hio_t *_io) : io(_io) {} | |
UdpBoltConfig &getConfig() { return config; } | |
bool analyzeData(struct sockaddr_in t_addr, struct sockaddr_in u_addr, uint32_t session_id, char *data, int data_len, char *extend, int extend_len); | |
int sendData(struct sockaddr_in t_addr, struct sockaddr_in u_addr, void *data, int data_len); | |
void closeClient(struct sockaddr_in &t_addr, struct sockaddr_in &u_addr); | |
void recycle(); | |
private: | |
UdpBoltConfig config; | |
hio_t *io; | |
UdpClientMap<std::string, UdpClientProxy> _map; | |
}; | |