mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Add request_strategy
option to wireguard outbound
This commit is contained in:
parent
1c26f56749
commit
91d2ff1b95
@ -42,6 +42,7 @@ icon: material/new-box
|
||||
"workers": 4,
|
||||
"mtu": 1408,
|
||||
"network": "tcp",
|
||||
"request_strategy": "prefer_ipv4",
|
||||
|
||||
... // Dial Fields
|
||||
}
|
||||
@ -162,6 +163,12 @@ One of `tcp` `udp`.
|
||||
|
||||
Both is enabled by default.
|
||||
|
||||
#### request_strategy
|
||||
|
||||
One of `prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`.
|
||||
|
||||
The DNS strategy used in resolving requested domains.
|
||||
|
||||
### Dial Fields
|
||||
|
||||
See [Dial Fields](/configuration/shared/dial) for details.
|
||||
|
@ -30,6 +30,7 @@ icon: material/new-box
|
||||
"workers": 4,
|
||||
"mtu": 1408,
|
||||
"network": "tcp",
|
||||
"request_strategy": "prefer_ipv4",
|
||||
|
||||
... // 拨号字段
|
||||
}
|
||||
@ -136,6 +137,12 @@ WireGuard MTU。
|
||||
|
||||
默认所有。
|
||||
|
||||
#### request_strategy
|
||||
|
||||
可选值:`prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`。
|
||||
|
||||
解析请求的域名时使用的 DNS 策略。
|
||||
|
||||
### 拨号字段
|
||||
|
||||
参阅 [拨号字段](/zh/configuration/shared/dial/)。
|
||||
|
@ -12,12 +12,13 @@ type WireGuardOutboundOptions struct {
|
||||
PrivateKey string `json:"private_key"`
|
||||
Peers []WireGuardPeer `json:"peers,omitempty"`
|
||||
ServerOptions
|
||||
PeerPublicKey string `json:"peer_public_key"`
|
||||
PreSharedKey string `json:"pre_shared_key,omitempty"`
|
||||
Reserved []uint8 `json:"reserved,omitempty"`
|
||||
Workers int `json:"workers,omitempty"`
|
||||
MTU uint32 `json:"mtu,omitempty"`
|
||||
Network NetworkList `json:"network,omitempty"`
|
||||
PeerPublicKey string `json:"peer_public_key"`
|
||||
PreSharedKey string `json:"pre_shared_key,omitempty"`
|
||||
Reserved []uint8 `json:"reserved,omitempty"`
|
||||
Workers int `json:"workers,omitempty"`
|
||||
MTU uint32 `json:"mtu,omitempty"`
|
||||
Network NetworkList `json:"network,omitempty"`
|
||||
RequestStrategy DomainStrategy `json:"request_strategy,omitempty"`
|
||||
}
|
||||
|
||||
type WireGuardPeer struct {
|
||||
|
@ -32,9 +32,10 @@ var (
|
||||
|
||||
type WireGuard struct {
|
||||
myOutboundAdapter
|
||||
bind *wireguard.ClientBind
|
||||
device *device.Device
|
||||
tunDevice wireguard.Device
|
||||
bind *wireguard.ClientBind
|
||||
device *device.Device
|
||||
tunDevice wireguard.Device
|
||||
requestStrategy dns.DomainStrategy
|
||||
}
|
||||
|
||||
func NewWireGuard(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.WireGuardOutboundOptions) (*WireGuard, error) {
|
||||
@ -47,6 +48,7 @@ func NewWireGuard(ctx context.Context, router adapter.Router, logger log.Context
|
||||
tag: tag,
|
||||
dependencies: withDialerDependency(options.DialerOptions),
|
||||
},
|
||||
requestStrategy: dns.DomainStrategy(options.RequestStrategy),
|
||||
}
|
||||
var reserved [3]uint8
|
||||
if len(options.Reserved) > 0 {
|
||||
@ -227,11 +229,11 @@ func (w *WireGuard) ListenPacket(ctx context.Context, destination M.Socksaddr) (
|
||||
}
|
||||
|
||||
func (w *WireGuard) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext) error {
|
||||
return NewDirectConnection(ctx, w.router, w, conn, metadata, dns.DomainStrategyAsIS)
|
||||
return NewDirectConnection(ctx, w.router, w, conn, metadata, w.requestStrategy)
|
||||
}
|
||||
|
||||
func (w *WireGuard) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata adapter.InboundContext) error {
|
||||
return NewDirectPacketConnection(ctx, w.router, w, conn, metadata, dns.DomainStrategyAsIS)
|
||||
return NewDirectPacketConnection(ctx, w.router, w, conn, metadata, w.requestStrategy)
|
||||
}
|
||||
|
||||
func (w *WireGuard) Start() error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user