heiher / hev-socks5-tunnel

A high-performance tun2socks for Linux/Android/FreeBSD/macOS/iOS/WSL2 (IPv4/IPv6/TCP/UDP)
MIT License
635 stars 130 forks source link

Question. Log a used traffic count. #91

Closed evgenybozhko2 closed 4 months ago

evgenybozhko2 commented 4 months ago

Hello, dear creators of these useful tools. I faced a feature that required me a count the traffic that passed during the VPN connection. On IOS it can be done by interface settings. But on Android it no way to get this value. Can I make some counting into hev socks5 lib? I guess that should be counting somewhere around hev_task_io_socket_recvmsg() hev_task_io_socket_sendmsg() calls. Can you make me some prompt, which can be placed counter in the correct place? Thank you a lot.

heiher commented 4 months ago

Fixed: https://github.com/heiher/hev-socks5-tunnel/releases/tag/2.6.5

API:

/**
 * hev_socks5_tunnel_stats:
 * @tx_packets (out): transmitted packets
 * @tx_bytes (out): transmitted bytes
 * @rx_packets (out): received packets
 * @rx_bytes (out): received bytes
 *
 * Retrieve tunnel interface traffic statistics.
 *
 * Since: 2.6.5
 */
void hev_socks5_tunnel_stats (size_t *tx_packets, size_t *tx_bytes,
                              size_t *rx_packets, size_t *rx_bytes);