From 225ccc831969884a78bb78588d3e8bb355f289f6 Mon Sep 17 00:00:00 2001 From: ruti <> Date: Fri, 18 Oct 2024 12:30:48 +0300 Subject: [PATCH] --repeats for UDP --- extend.c | 23 +++++++++++++---------- proxy.c | 5 +++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/extend.c b/extend.c index 802ab7a..6754720 100644 --- a/extend.c +++ b/extend.c @@ -452,21 +452,24 @@ ssize_t tcp_recv_hook(struct poolhd *pool, struct eval *val, ssize_t udp_hook(struct eval *val, char *buffer, size_t bfsize, ssize_t n, struct sockaddr_ina *dst) { - if (val->recv_count) { + if (val->round_count > params.repeats) { return send(val->fd, buffer, n, 0); } int m = val->attempt; - if (!m) for (; m < params.dp_count; m++) { - struct desync_params *dp = ¶ms.dp[m]; - if (!dp->detect && - (!dp->proto || (dp->proto & IS_UDP)) && - (!dp->pf[0] || check_port(dp->pf, &dst->in6))) { - break; + if (!m) { + for (; m < params.dp_count; m++) { + struct desync_params *dp = ¶ms.dp[m]; + if (!dp->detect && + (!dp->proto || (dp->proto & IS_UDP)) && + (!dp->pf[0] || check_port(dp->pf, &dst->in6))) { + break; + } } + if (m >= params.dp_count) { + return -1; + } + val->attempt = m; } - if (m >= params.dp_count) { - return -1; - } return desync_udp(val->fd, buffer, bfsize, n, &dst->sa, m); } diff --git a/proxy.c b/proxy.c index 6e33bdf..151abeb 100644 --- a/proxy.c +++ b/proxy.c @@ -746,6 +746,11 @@ int on_udp_tunnel(struct eval *val, char *buffer, size_t bfsize) return -1; } val->recv_count += n; + if (val->round_sent == 0) { + val->round_count++; + val->round_sent += n; + val->pair->round_sent = 0; + } ssize_t ns; if (val->flag == FLAG_CONN) {