Transport: Pass UDP destination to dialer controllers (#7201)

https://github.com/XTLS/Xray-core/pull/7201#issuecomment-6275732621

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
Eliot the Cougar
2026-10-21 10:20:35 +00:00
committed by GitHub
co-authored by 风扇滑翔翼
parent 41797c234d
commit 23e2292344
+4 -2
View File
@@ -69,9 +69,10 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
}
var lc net.ListenConfig
if sockopt != nil || len(Controllers) > 0 {
lc.Control = func(network, address string, c syscall.RawConn) error {
lc.Control = func(network, _ string, c syscall.RawConn) error {
// ListenPacket supplies a local address; dialer controllers need the destination.
for _, ctl := range Controllers {
if err := ctl(network, address, c); err != nil {
if err := ctl(network, destAddr.String(), c); err != nil {
return errors.New("failed to apply external controller").Base(err)
}
}
@@ -197,6 +198,7 @@ func UseAlternativeSystemDialer(dialer SystemDialer) {
// RegisterDialerController adds a controller to the effective system dialer.
// The controller can be used to operate on file descriptors before they are put into use.
// It receives the network and resolved remote address, as in net.Dialer.Control.
// It only works when effective dialer is the default dialer.
//
// xray:api:beta