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) {} | |
| hv::UdpClient *getClient() { return &cli; } | |
| bool init(); | |
| void close(); | |
| bool isDns() { | |
| return ntohs(t_addr.sin_port) == 53; | |
| }; | |
| private: | |
| void onRecv(const hv::SocketChannelPtr &channel, hv::Buffer *buf); | |
| void onWrited(const hv::SocketChannelPtr &channel, hv::Buffer *buf); | |
| public: | |
| struct sockaddr_in t_addr, u_addr; | |
| private: | |
| hv::UdpClient cli; | |
| TimerThread 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; | |
| }; | |