Separate connect error and torst

This commit is contained in:
ruti 2026-02-15 00:16:13 +03:00
parent cc68428b62
commit f3270cb6c8
5 changed files with 21 additions and 11 deletions

View File

@ -122,11 +122,11 @@ int on_socks_recv(struct poolhd *pool, struct eval *val, int t)
ssize_t n = recv(val->fd, (char *)&r, sizeof(r), 0);
if (n < 2) {
uniperror("socks recv");
return on_torst(pool, val);
return on_connerr(pool, val);
}
if (r.ver != S_VER5 || r.cmd != 0x00) {
LOG(LOG_E, "socks answer: %d\n", r.cmd);
return on_torst(pool, val);
return on_connerr(pool, val);
}
if (val->conn_state != FLAG_S5) {
r.cmd = S_CMD_CONN;
@ -134,7 +134,7 @@ int on_socks_recv(struct poolhd *pool, struct eval *val, int t)
if (send(val->fd, (char *)&r, len, 0) < 0) {
uniperror("socks send");
return on_torst(pool, val);
return on_connerr(pool, val);
}
val->conn_state = FLAG_S5;
return 0;
@ -150,7 +150,7 @@ int on_socks_conn(struct poolhd *pool, struct eval *val, int t)
if (send(val->fd, (char *)data, sizeof(data), 0) < 0) {
uniperror("socks send");
return on_torst(pool, val);
return on_connerr(pool, val);
}
if (mod_etype(pool, val, POLLIN) ||
mod_etype(pool, val->pair, POLLIN)) {
@ -359,7 +359,7 @@ static void swop_groups(struct desync_params *dpc, struct desync_params *dpn)
}
static int on_trigger(int type, struct poolhd *pool, struct eval *val, bool client_alive)
int on_trigger(int type, struct poolhd *pool, struct eval *val, bool client_alive)
{
struct eval *lav = val->pair;
@ -426,7 +426,7 @@ static int on_trigger(int type, struct poolhd *pool, struct eval *val, bool clie
}
int on_torst(struct poolhd *pool, struct eval *val)
static int on_torst(struct poolhd *pool, struct eval *val)
{
if (on_trigger(DETECT_TORST, pool, val, 1) == 0) {
return 0;
@ -466,6 +466,12 @@ int on_timeout(struct poolhd *pool, struct eval *val) {
}
int on_connerr(struct poolhd *pool, struct eval *val)
{
return on_trigger(DETECT_CONNECT, pool, val, 1);
}
static int on_response(struct poolhd *pool, struct eval *val,
const char *resp, ssize_t sn)
{

View File

@ -22,7 +22,7 @@ ssize_t udp_hook(struct eval *val,
static bool check_l34(struct desync_params *dp, int st, const union sockaddr_u *dst);
int on_torst(struct poolhd *pool, struct eval *val);
int on_connerr(struct poolhd *pool, struct eval *val);
int on_timeout(struct poolhd *pool, struct eval *val);

7
main.c
View File

@ -84,8 +84,8 @@ static const char help_text[] = {
#ifdef TCP_FASTOPEN_CONNECT
" -F, --tfo Enable TCP Fast Open\n"
#endif
" -A, --auto <t,r,s,n,k,p> Try desync params after this option\n"
" Detect: torst,redirect,ssl_err,none; keep,pri=<group priority>\n"
" -A, --auto <t,r,s,n,k,c> Try desync params after this option\n"
" Detect: torst,redirect,ssl_err,none,conn,keep,pri=<num>\n"
" -L, --auto-mode <s> Mode: sort\n"
" -y, --cache-dump <file|-> Dump cache to file or stdout\n"
#ifdef TIMEOUT_SUPPORT
@ -836,6 +836,9 @@ int parse_args(int argc, char **argv)
case 'k':
dp->detect |= DETECT_RECONN;
break;
case 'c':
dp->detect |= DETECT_CONNECT;
break;
case 'n':
break;
case 'p':

View File

@ -33,6 +33,7 @@
#define DETECT_TLS_ERR 2
#define DETECT_TORST 8
#define DETECT_RECONN 16
#define DETECT_CONNECT 32
#define AUTO_RECONN 1
#define AUTO_NOPOST 2

View File

@ -951,8 +951,8 @@ int on_connect(struct poolhd *pool, struct eval *val, int et)
case ECONNRESET:
case ECONNREFUSED:
case ETIMEDOUT:
case EHOSTUNREACH:
if (on_torst(pool, val) == 0) {
//case EHOSTUNREACH:
if (on_connerr(pool, val) == 0) {
return 0;
}
}