Skip to content

Commit 3e5bedd

Browse files
authored
example, todo & issues update
1 parent 6f04a62 commit 3e5bedd

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,24 @@
55
```cpp
66
// announce callbacks:
77
ep::callback<udp_callback_t> udp_callback;
8+
ep::callback<tcp_callback_t> tcp_callback;
89

910
// install detour functions:
1011
udp_callback.install([&](ep::client* person, unsigned int& source_ip, unsigned int& dest_ip, unsigned short& source_port, unsigned short& dest_port, ep::buffer* buf) -> bool {
11-
printf("[%s -> %s | %d -> %d] length: %d\n\n", ep::utils::dip_to_strip(source_ip).c_str(), ep::utils::dip_to_strip(dest_ip).c_str(), source_port, dest_port, buf->length);
12+
printf("[%s -> %s | %d -> %d] length: %d\n", ep::utils::dip_to_strip(source_ip).c_str(), ep::utils::dip_to_strip(dest_ip).c_str(), source_port, dest_port, buf->length);
13+
return true;
14+
});
15+
16+
tcp_callback.install([&](ep::client* person, std::string source_ip, std::string dest_ip, ep::buffer* buf) -> bool {
17+
printf("[%s -> %s] length: %d\n", source_ip.c_str(), dest_ip.c_str(), buf->length);
1218
return true;
1319
});
1420

1521
// enable callbacks treatment:
1622
proxy.callback_enable(ep::callback_t::udp, &udp_callback);
23+
proxy.callback_enable(ep::callback_t::tcp, &tcp_callback);
1724
```
18-
###### due to the peculiarities of the TCP/IP protocol, the dest IP and port cannot be changed on the go, because of this, the TCP callback has a different structure: ```(client* person, std::string source_ip, std::string dest_ip, proxys::data* buf)```
19-
###### one-header solution available in "one-header" branch
20-
21-
<hr>
22-
23-
###### known issues:
24-
> *small memory leak when the connection to the proxied object does not break* <br>
25-
2625
<hr>
2726

2827
###### todo list:
29-
> *bind command support* <br>
30-
> *support ipv6* <br>
31-
> *backward compatibility with socsk4* <br>
3228
> *add more comments (or write small doc) to internal functional* <br>

0 commit comments

Comments
 (0)