|
|
|
|
@ -133,7 +133,17 @@ static err_t tcp_output_cb(void *arg, struct pbuf *p, uint32_t src_ip, uint32_t
|
|
|
|
|
if (proxy->tun) { |
|
|
|
|
pbuf_copy_partial(p, buf, len, 0); |
|
|
|
|
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); |
|
|
|
|
if (wr != (ssize_t)len) { |
|
|
|
|
uint16_t ip_total = ((uint16_t)buf[2] << 8) | buf[3]; |
|
|
|
|
uint32_t src_ip, dst_ip; memcpy(&src_ip, buf + 12, 4); memcpy(&dst_ip, buf + 16, 4); |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_TRAFFIC, "TUN_WRITE_ERR ret=%zd len=%u ip_total=%u vhl=%02x proto=%u %u.%u.%u.%u→%u.%u.%u.%u errno=%d", |
|
|
|
|
wr, len, ip_total, buf[0], buf[9], |
|
|
|
|
(uint8_t)(src_ip),(uint8_t)(src_ip>>8),(uint8_t)(src_ip>>16),(uint8_t)(src_ip>>24), |
|
|
|
|
(uint8_t)(dst_ip),(uint8_t)(dst_ip>>8),(uint8_t)(dst_ip>>16),(uint8_t)(dst_ip>>24), errno); |
|
|
|
|
{ char hx[128]; int p = 0; size_t n = len < 32 ? len : 32; |
|
|
|
|
for (size_t i = 0; i < n && p < 124; i++) p += snprintf(hx + p, sizeof(hx) - p, "%02x", buf[i]); |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_TRAFFIC, "TUN_WRITE_ERR hex[0..%zu]: %s", n, hx); } |
|
|
|
|
} |
|
|
|
|
} else if (proxy->ip_fd >= 0) { |
|
|
|
|
buf[0] = (len >> 8) & 0xFF; buf[1] = len & 0xFF; |
|
|
|
|
pbuf_copy_partial(p, buf + 2, len, 0); |
|
|
|
|
|