-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
90 lines (75 loc) · 2.75 KB
/
main.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "main.hpp"
using namespace std;
int main(int argc, char **argv) {
//Signal issue
signal(SIGPIPE, SIG_IGN);
//EV loop
ev::default_loop loop;
//EV listener
Timeout_Listener timeout_l(&loop, 0, 1);
timeout_l.after_launch = [argc, argv](Container *c) {
if (argc > 1) {
string s(argv[1]);
if (s == "client") {
c->mode = "client ";
c->cc = new Client_Core(c->loop);
c->cc->start();
} else if (s == "peer") {
c->mode = "peer ";
c->pc = new Peer_Core(c->loop);
c->pc->start();
} else if (s == "socks5") {
c->mode = "server-socks5 ";
c->sc = new Socks_Core(c->loop);
c->sc->start();
}
} else {
c->mode = "test ";
}
for (int i = 1; i < argc; ++i) {
string s(argv[i]);
if (s == "clear"){
c->clear_screen = true;
}
}
};
timeout_l.repeat_event = [](Container *c, int i) {
// DEBUG
if (c->clear_screen){
printf("\033c");
}
cout << c->mode << " - Page " << i << "\tTime " << c->get_time() << endl;
if (c->cc != nullptr) {
cout << "\n-----------------------------------" << endl;
cout << "Client A: Browser to Client Program" << endl;
for (const auto &kv : c->cc->connection_a) {
if (kv.second == nullptr)continue;
cout << kv.first << "\t" << kv.second->info() << endl;
}
cout << "\n-----------------------------------" << endl;
cout << "Client B: Client Program to Proxy Peer" << endl;
for (const auto &v : c->cc->connection_b_available) {
cout << v->info() << endl;
}
cout << "\n-----------------------------------" << endl;
}
if (c->pc != nullptr) {
cout << "\n-----------------------------------" << endl;
cout << "Peer A: Client Program to Proxy Peer" << endl;
for (const auto &v : c->pc->connection_a_available) {
cout << v->info() << endl;
}
cout << "\n-----------------------------------" << endl;
cout << "Peer B: Proxy Peer to SOCKS proxy server" << endl;
for (const auto &kv : c->pc->connection_b) {
if (kv.second == nullptr)continue;
cout << kv.first << "\t" << kv.second->info() << endl;
}
cout << "\n-----------------------------------" << endl;
}
};
Command_Listener command_l(&loop);
//Start
loop.run();
return 0;
}