Merge branch 'hufrea:main' into cmake

This commit is contained in:
Nikolay Raspopov 2024-08-19 06:17:58 +03:00 committed by GitHub
commit cf393f1a77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

19
proxy.c
View File

@ -437,17 +437,22 @@ int udp_associate(struct poolhd *pool,
return -1; return -1;
} }
if (dst->in6.sin6_port != 0) { if (dst->in6.sin6_port != 0) {
if (socket_mod(ufd, &addr.sa) < 0) {
del_event(pool, pair);
return -1;
}
if (connect(ufd, &addr.sa, SA_SIZE(&addr)) < 0) { if (connect(ufd, &addr.sa, SA_SIZE(&addr)) < 0) {
uniperror("connect"); uniperror("connect");
del_event(pool, pair); del_event(pool, pair);
return -1; return -1;
} }
if (socket_mod(ufd, &addr.sa) < 0) {
del_event(pool, pair);
return -1;
}
pair->in6 = addr.in6; pair->in6 = addr.in6;
} }
if (params.debug) {
INIT_ADDR_STR((*dst));
LOG(LOG_S, "udp associate: fd=%d, addr=%s:%d\n",
ufd, ADDR_STR, ntohs(dst->in.sin_port));
}
// //
socklen_t sz = sizeof(addr); socklen_t sz = sizeof(addr);
@ -689,11 +694,11 @@ int on_udp_tunnel(struct eval *val, char *buffer, size_t bfsize)
if (params.baddr.sin6_family != addr.sa.sa_family) { if (params.baddr.sin6_family != addr.sa.sa_family) {
return -1; return -1;
} }
if (connect(val->pair->fd, &addr.sa, SA_SIZE(&addr)) < 0) { if (socket_mod(val->pair->fd, &addr.sa) < 0) {
uniperror("connect");
return -1; return -1;
} }
if (socket_mod(val->pair->fd, &addr.sa) < 0) { if (connect(val->pair->fd, &addr.sa, SA_SIZE(&addr)) < 0) {
uniperror("connect");
return -1; return -1;
} }
val->pair->in6 = addr.in6; val->pair->in6 = addr.in6;