-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathkcptun_server.h
54 lines (46 loc) · 1.43 KB
/
kcptun_server.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
#ifndef KCPTUN_KCPTUN_SERVER_H
#define KCPTUN_KCPTUN_SERVER_H
#include "config.h"
#include "server.h"
class kcptun_server_session final
: public std::enable_shared_from_this<kcptun_server_session>,
public kvar_,
public Destroy {
public:
kcptun_server_session(asio::io_service &io_service,
std::shared_ptr<smux_sess> sess,
asio::ip::tcp::endpoint target_endpoint);
void run();
private:
void do_pipe1();
void do_pipe2();
void call_this_on_destroy() override;
private:
char buf1_[4096];
char buf2_[4096];
asio::io_service &service_;
std::shared_ptr<smux_sess> sess_;
asio::ip::tcp::socket socket_;
asio::ip::tcp::endpoint target_endpoint_;
};
class kcptun_server final : public std::enable_shared_from_this<kcptun_server> {
public:
kcptun_server(asio::io_service &io_service,
asio::ip::udp::endpoint local_endpoint,
asio::ip::tcp::endpoint target_point);
void run();
void do_receive();
private:
void accept_handler(std::shared_ptr<smux_sess> sess);
private:
bool isfec_;
char buf_[2048];
asio::io_service &service_;
asio::ip::udp::socket usocket_;
asio::ip::udp::endpoint ep_;
asio::ip::tcp::endpoint target_endpoint_;
std::unique_ptr<BaseDecEncrypter> dec_or_enc_;
std::map<asio::ip::udp::endpoint, std::weak_ptr<Server>> servers_;
Buffers buffers_;
};
#endif