Spaces:
Paused
Paused
File size: 1,476 Bytes
1bff97b |
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 |
#ifndef PROXYSERVER_UDP_CLIENT_H
#define PROXYSERVER_UDP_CLIENT_H
#include "hv/hloop.h"
#include "hv/UdpClient.h"
#include "bolt/crypt.h"
#include "udp_client_map.h"
#include <string>
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();
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;
uint32_t session_id;
};
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 recycle();
private:
UdpBoltConfig config;
hio_t *io;
UdpClientMap<std::string, UdpClientProxy> _map;
};
#endif // PROXYSERVER_UDP_CLIENT_H |