feat(xdns): add resolver-based DNS tunneling with multi-resolver fan-out; fix sendLoop starvation#5871
feat(xdns): add resolver-based DNS tunneling with multi-resolver fan-out; fix sendLoop starvation#5871nnemirovsky wants to merge 2 commits intoXTLS:mainfrom
Conversation
Add optional `resolvers` config field to XDNS finalmask. When set, the client sends DNS queries through public DNS resolvers instead of connecting directly to the server on port 53. - One UDP socket per resolver with independent receive goroutines - Round-robin query distribution across resolvers - Backward compatible: omitting resolvers preserves direct mode - Server unchanged (uses embedded clientID for demux) - Unit tests for resolver parsing and mock resolver round-trip
- Remove nextRec query preemption from sendLoop inner select - Drain excess records before processing to skip stale queries - Reduce response wait from 1s to 50ms for faster turnaround - Increase server write queue from 512 to 4096 - Increase mKCP connection timeout from 30s to 120s
|
这个不是本来就是在 outbound address 填 1.1.1.1 这类 public DNS 地址吗? |
e06f0d7 to
c9faf7b
Compare
|
@RPRX, you're right that setting a public DNS address like The This can't be achieved with multiple The sendLoop fix in the second commit is independent and addresses a real bug where downstream data delivery stalls under mKCP retransmission load. |
|
大概懂了你是想实现 #4846 (comment) 这种多路径加速,这对于 XDNS 来说确实挺有用, 有没有兴趣顺便实现 #4846 (comment) |
|
我发现这些 AI PR 虽然无法被直接合并但有时候想法是有可取之处的,@LjhAUMEM 你看下吧 |
|
@RPRX @Fangliding @LjhAUMEM, check this out please #5872. I cleaned up some AI artifacts and fixed what @RPRX asked for |

Summary
Two related changes to XDNS finalmask:
1. Resolver-based DNS tunneling (new feature)
Add optional
resolversconfig field. When set, the client sends DNS queries through public resolvers (1.1.1.1, 8.8.8.8, etc.) instead of connecting directly to the server on port 53.resolverspreserves current direct-connection behaviorConfig example:
Why: Direct connection to server:53 is easily blocked by IP. Routing through public DNS resolvers makes traffic look like normal DNS queries and enables multi-resolver multiplexing for better throughput.
2. Fix sendLoop starvation under mKCP load (bug fix)
The XDNS server sendLoop failed to deliver downstream data when mKCP generated retransmission floods. HTTPS connections through the tunnel would time out because:
nextRec = <-c.chcase in the inner select caused the sendLoop to abandon responses whenever a new query arrived, resulting in empty responses under loadmaxResponseDelaywas too slow, causing the sendLoop to fall behindChanges:
Test plan
TestParseResolverAddr)TestResolverModeRoundTrip)TestDirectModeRoundTrip)