From 0df93bfab7c3132a333f3e6b2013c4ba1945eaa9 Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Wed, 26 Aug 2026 16:55:37 +0300 Subject: [PATCH] Let a Windows UDP service bind the socket it answers from A UDP service on Windows binds a second socket to the address it listens on, so a reply leaves the port the client sent to. Windows only allows that when both sockets ask for it, and the listening socket was never asked, so the bind failed and dnspr answered nothing at all on Windows. Ask for it on the listening socket of a UDP service, and there only: the reason it is withheld otherwise, that another local process could take a listening port, is unchanged for everything else. --- src/proxymain.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/proxymain.c b/src/proxymain.c index a09bcaa..8b3f141 100644 --- a/src/proxymain.c +++ b/src/proxymain.c @@ -830,6 +830,14 @@ int MODULEMAINFUNC (int argc, char** argv){ #ifndef _WIN32 opt = 1; if(srv.so._setsockopt(srv.so.state, sock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int)))perror("setsockopt()"); +#else + /* A UDP service on Windows answers from a second socket bound to + the address it listens on, and Windows only allows that bind + when both sockets ask for it. */ + if(isudp){ + opt = 1; + if(srv.so._setsockopt(srv.so.state, sock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int)))perror("setsockopt()"); + } #endif #ifdef SO_REUSEPORT opt = 1;