mirror of
https://github.com/hufrea/byedpi.git
synced 2025-07-01 11:03:04 +00:00
UDP: remove events from TCP socket
This commit is contained in:
parent
6651427f3a
commit
9429008264
2
conev.c
2
conev.c
@ -55,7 +55,7 @@ struct eval *add_event(struct poolhd *pool, enum eid type,
|
|||||||
val->type = type;
|
val->type = type;
|
||||||
|
|
||||||
#ifndef NOEPOLL
|
#ifndef NOEPOLL
|
||||||
struct epoll_event ev = { .events = e, .data = {val} };
|
struct epoll_event ev = { .events = EPOLLRDHUP | e, .data = {val} };
|
||||||
if (epoll_ctl(pool->efd, EPOLL_CTL_ADD, fd, &ev)) {
|
if (epoll_ctl(pool->efd, EPOLL_CTL_ADD, fd, &ev)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
22
proxy.c
22
proxy.c
@ -405,7 +405,7 @@ int udp_associate(struct poolhd *pool,
|
|||||||
|
|
||||||
int ufd = nb_socket(params.baddr.sin6_family, SOCK_DGRAM);
|
int ufd = nb_socket(params.baddr.sin6_family, SOCK_DGRAM);
|
||||||
if (ufd < 0) {
|
if (ufd < 0) {
|
||||||
perror("socket");
|
uniperror("socket");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (params.protect_path
|
if (params.protect_path
|
||||||
@ -417,7 +417,7 @@ int udp_associate(struct poolhd *pool,
|
|||||||
int no = 0;
|
int no = 0;
|
||||||
if (setsockopt(ufd, IPPROTO_IPV6,
|
if (setsockopt(ufd, IPPROTO_IPV6,
|
||||||
IPV6_V6ONLY, (char *)&no, sizeof(no))) {
|
IPV6_V6ONLY, (char *)&no, sizeof(no))) {
|
||||||
perror("setsockopt IPV6_V6ONLY");
|
uniperror("setsockopt IPV6_V6ONLY");
|
||||||
close(ufd);
|
close(ufd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -436,7 +436,7 @@ int udp_associate(struct poolhd *pool,
|
|||||||
|
|
||||||
int cfd = nb_socket(addr.sa.sa_family, SOCK_DGRAM);
|
int cfd = nb_socket(addr.sa.sa_family, SOCK_DGRAM);
|
||||||
if (cfd < 0) {
|
if (cfd < 0) {
|
||||||
perror("socket");
|
uniperror("socket");
|
||||||
del_event(pool, pair);
|
del_event(pool, pair);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ int udp_associate(struct poolhd *pool,
|
|||||||
|
|
||||||
socklen_t sz = sizeof(addr);
|
socklen_t sz = sizeof(addr);
|
||||||
if (getsockname(cfd, &addr.sa, &sz)) {
|
if (getsockname(cfd, &addr.sa, &sz)) {
|
||||||
perror("getsockname");
|
uniperror("getsockname");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
struct s5_req s5r = {
|
struct s5_req s5r = {
|
||||||
@ -474,7 +474,11 @@ int udp_associate(struct poolhd *pool,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (send(val->fd, (char *)&s5r, len, 0) < 0) {
|
if (send(val->fd, (char *)&s5r, len, 0) < 0) {
|
||||||
perror("send");
|
uniperror("send");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (mod_etype(pool, val, 0)) {
|
||||||
|
uniperror("mod_etype");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -620,7 +624,7 @@ int on_udp_tunnel(struct eval *val, char *buffer, size_t bfsize)
|
|||||||
if (n < 1) {
|
if (n < 1) {
|
||||||
if (n && errno == EAGAIN)
|
if (n && errno == EAGAIN)
|
||||||
break;
|
break;
|
||||||
perror("recv udp");
|
uniperror("recv udp");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ssize_t ns;
|
ssize_t ns;
|
||||||
@ -661,7 +665,7 @@ int on_udp_tunnel(struct eval *val, char *buffer, size_t bfsize)
|
|||||||
ns = send(val->pair->pair->fd, data - offs, offs + n, 0);
|
ns = send(val->pair->pair->fd, data - offs, offs + n, 0);
|
||||||
}
|
}
|
||||||
if (ns < 0) {
|
if (ns < 0) {
|
||||||
perror("sendto");
|
uniperror("sendto");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} while(1);
|
} while(1);
|
||||||
@ -716,7 +720,7 @@ static inline int on_request(struct poolhd *pool, struct eval *val,
|
|||||||
}
|
}
|
||||||
if (s5e < 0) {
|
if (s5e < 0) {
|
||||||
if (resp_s5_error(val->fd, -s5e) < 0)
|
if (resp_s5_error(val->fd, -s5e) < 0)
|
||||||
perror("send");
|
uniperror("send");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -726,7 +730,7 @@ static inline int on_request(struct poolhd *pool, struct eval *val,
|
|||||||
error = s4_get_addr(buffer, n, &dst);
|
error = s4_get_addr(buffer, n, &dst);
|
||||||
if (error) {
|
if (error) {
|
||||||
if (resp_error(val->fd, error, FLAG_S4) < 0)
|
if (resp_error(val->fd, error, FLAG_S4) < 0)
|
||||||
perror("send");
|
uniperror("send");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
error = connect_hook(pool, val, &dst, EV_CONNECT);
|
error = connect_hook(pool, val, &dst, EV_CONNECT);
|
||||||
|
Loading…
Reference in New Issue
Block a user