Browse Source

add TUN write diagnostic: log tun_platform_write errors

congestion
Evgeny 4 months ago
parent
commit
f708b1d095
  1. 3
      src/tcp_proxy.c

3
src/tcp_proxy.c

@ -132,7 +132,8 @@ static err_t tcp_output_cb(void *arg, struct pbuf *p, uint32_t src_ip, uint32_t
uint8_t buf[2002]; uint8_t buf[2002];
if (proxy->tun) { if (proxy->tun) {
pbuf_copy_partial(p, buf, len, 0); pbuf_copy_partial(p, buf, len, 0);
tun_platform_write(proxy->tun, buf, len); ssize_t wr = tun_platform_write(proxy->tun, buf, len);
if (wr != (ssize_t)len) DEBUG_ERROR(DEBUG_CATEGORY_TRAFFIC, "PROXY TCP_OUT TUN write failed: ret=%zd len=%u errno=%d", wr, len, errno);
} else if (proxy->ip_fd >= 0) { } else if (proxy->ip_fd >= 0) {
buf[0] = (len >> 8) & 0xFF; buf[1] = len & 0xFF; buf[0] = (len >> 8) & 0xFF; buf[1] = len & 0xFF;
pbuf_copy_partial(p, buf + 2, len, 0); pbuf_copy_partial(p, buf + 2, len, 0);

Loading…
Cancel
Save