diff --git a/src/redir.c b/src/redir.c index b5dbde34..05a3671a 100644 --- a/src/redir.c +++ b/src/redir.c @@ -147,10 +147,6 @@ int create_and_bind(const char *addr, const char *port) LOGI("tcp port reuse enabled"); } - // Set QoS flag - int tos = 46; - setsockopt(remotefd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) - s = bind(listen_sock, rp->ai_addr, rp->ai_addrlen); if (s == 0) { /* We managed to bind successfully! */ @@ -647,10 +643,6 @@ static void accept_cb(EV_P_ ev_io *w, int revents) setsockopt(remotefd, SOL_TCP, TCP_KEEPINTVL, (void *)&keepInterval, sizeof(keepInterval)); setsockopt(remotefd, SOL_TCP, TCP_KEEPCNT, (void *)&keepCount, sizeof(keepCount)); - // Set QoS flag - int tos = 46; - setsockopt(remotefd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) - // Set non blocking setnonblocking(remotefd); diff --git a/src/udprelay.c b/src/udprelay.c index 67e80767..f91017c2 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -429,6 +429,11 @@ int create_server_socket(const char *host, const char *port) if (err == 0) { LOGI("udp port reuse enabled"); } +#ifdef IP_TOS + // Set QoS flag + int tos = 46; + setsockopt(server_sock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)); +#endif #ifdef MODULE_REDIR if (setsockopt(server_sock, SOL_IP, IP_TRANSPARENT, &opt, sizeof(opt))) { @@ -574,6 +579,11 @@ static void query_resolve_cb(struct sockaddr *addr, void *data) #ifdef SO_NOSIGPIPE set_nosigpipe(remotefd); #endif +#ifdef IP_TOS + // Set QoS flag + int tos = 46; + setsockopt(remotefd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)); +#endif #ifdef SET_INTERFACE if (query_ctx->server_ctx->iface) { if (setinterface(remotefd, query_ctx->server_ctx->iface) == -1) @@ -756,6 +766,11 @@ static void remote_recv_cb(EV_P_ ev_io *w, int revents) close(src_fd); goto CLEAN_UP; } +#ifdef IP_TOS + // Set QoS flag + int tos = 46; + setsockopt(src_fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)); +#endif if (bind(src_fd, (struct sockaddr *)&dst_addr, remote_dst_addr_len) != 0) { ERROR("[udp] remote_recv_bind"); close(src_fd); @@ -1079,6 +1094,11 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) #ifdef SO_NOSIGPIPE set_nosigpipe(remotefd); #endif +#ifdef IP_TOS + // Set QoS flag + int tos = 46; + setsockopt(remotefd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)); +#endif #ifdef SET_INTERFACE if (server_ctx->iface) { if (setinterface(remotefd, server_ctx->iface) == -1) @@ -1170,6 +1190,11 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) #ifdef SO_NOSIGPIPE set_nosigpipe(remotefd); #endif +#ifdef IP_TOS + // Set QoS flag + int tos = 46; + setsockopt(remotefd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)); +#endif #ifdef SET_INTERFACE if (server_ctx->iface) { if (setinterface(remotefd, server_ctx->iface) == -1)