mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-09-23 01:27:04 +00:00
https://github.com/XTLS/Xray-core/pull/6327#issuecomment-5645958010 https://github.com/XTLS/Xray-core/pull/6754#issuecomment-5720818254 https://github.com/XTLS/Xray-core/pull/6754#issuecomment-5751585906
26 lines
767 B
Go
26 lines
767 B
Go
package udp
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/xtls/xray-core/common"
|
|
"github.com/xtls/xray-core/common/net"
|
|
"github.com/xtls/xray-core/transport/internet"
|
|
"github.com/xtls/xray-core/transport/internet/stat"
|
|
)
|
|
|
|
func init() {
|
|
common.Must(internet.RegisterTransportDialer(protocolName,
|
|
func(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) {
|
|
if streamSettings != nil && streamSettings.FinalMask != nil {
|
|
return streamSettings.FinalMask.DialUDP(ctx, dest)
|
|
} else {
|
|
var sockopt *internet.SocketConfig
|
|
if streamSettings != nil && streamSettings.SocketSettings != nil {
|
|
sockopt = streamSettings.SocketSettings
|
|
}
|
|
return internet.DialSystem(ctx, dest, sockopt)
|
|
}
|
|
}))
|
|
}
|