|
5 | 5 | ```cpp
|
6 | 6 | // announce callbacks:
|
7 | 7 | ep::callback<udp_callback_t> udp_callback;
|
| 8 | +ep::callback<tcp_callback_t> tcp_callback; |
8 | 9 |
|
9 | 10 | // install detour functions:
|
10 | 11 | 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); |
12 | 18 | return true;
|
13 | 19 | });
|
14 | 20 |
|
15 | 21 | // enable callbacks treatment:
|
16 | 22 | proxy.callback_enable(ep::callback_t::udp, &udp_callback);
|
| 23 | +proxy.callback_enable(ep::callback_t::tcp, &tcp_callback); |
17 | 24 | ```
|
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 |
| -
|
26 | 25 | <hr>
|
27 | 26 |
|
28 | 27 | ###### todo list:
|
29 |
| -> *bind command support* <br> |
30 |
| -> *support ipv6* <br> |
31 |
| -> *backward compatibility with socsk4* <br> |
32 | 28 | > *add more comments (or write small doc) to internal functional* <br>
|
0 commit comments