-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSocks_Core.cpp
More file actions
33 lines (28 loc) · 837 Bytes
/
Copy pathSocks_Core.cpp
File metadata and controls
33 lines (28 loc) · 837 Bytes
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
//
// Created by mc on 3/8/18.
//
#include "Socks_Core.hpp"
void Socks_Core::load_config() {
ifstream setting_file;
setting_file.open("socks_settings.txt");
if (setting_file.good()){
setting_file >> listen_address >> listen_port ;
}else{
cout << "Cannot load settings" << endl;
exit(1);
}
}
void Socks_Core::start() {
proxy_server = new Async_Accept(loop, listen_address, listen_port);
proxy_server->accepted_event = [this](int d, sockaddr_storage r, socklen_t rl){
fcntl(d, F_SETFL, fcntl(d, F_GETFL) & (~O_NONBLOCK));
Handshake * h = new Handshake(loop, d);
thread * t = new thread(&Handshake::start, h);
t->detach();
};
proxy_server->start();
}
Socks_Core::Socks_Core(ev::default_loop *loop) {
this->loop = loop;
load_config();
}