mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Merge 05c860a58aca53b965426022e14edad46b7c39a2 into e3f85676904846d9186a4a3884e7ffe0bd3b9ce8
This commit is contained in:
commit
96ce5980d9
@ -31,6 +31,7 @@
|
|||||||
"workers": 4,
|
"workers": 4,
|
||||||
"mtu": 1408,
|
"mtu": 1408,
|
||||||
"network": "tcp",
|
"network": "tcp",
|
||||||
|
"request_strategy": "prefer_ipv4",
|
||||||
|
|
||||||
... // Dial Fields
|
... // Dial Fields
|
||||||
}
|
}
|
||||||
@ -137,6 +138,12 @@ One of `tcp` `udp`.
|
|||||||
|
|
||||||
Both is enabled by default.
|
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
|
### Dial Fields
|
||||||
|
|
||||||
See [Dial Fields](/configuration/shared/dial/) for details.
|
See [Dial Fields](/configuration/shared/dial/) for details.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
"workers": 4,
|
"workers": 4,
|
||||||
"mtu": 1408,
|
"mtu": 1408,
|
||||||
"network": "tcp",
|
"network": "tcp",
|
||||||
|
"request_strategy": "prefer_ipv4",
|
||||||
|
|
||||||
... // 拨号字段
|
... // 拨号字段
|
||||||
}
|
}
|
||||||
@ -111,6 +112,12 @@ WireGuard MTU。
|
|||||||
|
|
||||||
默认所有。
|
默认所有。
|
||||||
|
|
||||||
|
#### request_strategy
|
||||||
|
|
||||||
|
可选值:`prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`。
|
||||||
|
|
||||||
|
解析请求的域名时使用的 DNS 策略。
|
||||||
|
|
||||||
### 拨号字段
|
### 拨号字段
|
||||||
|
|
||||||
参阅 [拨号字段](/zh/configuration/shared/dial/)。
|
参阅 [拨号字段](/zh/configuration/shared/dial/)。
|
||||||
|
@ -10,12 +10,13 @@ type WireGuardOutboundOptions struct {
|
|||||||
PrivateKey string `json:"private_key"`
|
PrivateKey string `json:"private_key"`
|
||||||
Peers []WireGuardPeer `json:"peers,omitempty"`
|
Peers []WireGuardPeer `json:"peers,omitempty"`
|
||||||
ServerOptions
|
ServerOptions
|
||||||
PeerPublicKey string `json:"peer_public_key"`
|
PeerPublicKey string `json:"peer_public_key"`
|
||||||
PreSharedKey string `json:"pre_shared_key,omitempty"`
|
PreSharedKey string `json:"pre_shared_key,omitempty"`
|
||||||
Reserved []uint8 `json:"reserved,omitempty"`
|
Reserved []uint8 `json:"reserved,omitempty"`
|
||||||
Workers int `json:"workers,omitempty"`
|
Workers int `json:"workers,omitempty"`
|
||||||
MTU uint32 `json:"mtu,omitempty"`
|
MTU uint32 `json:"mtu,omitempty"`
|
||||||
Network NetworkList `json:"network,omitempty"`
|
Network NetworkList `json:"network,omitempty"`
|
||||||
|
RequestStrategy DomainStrategy `json:"request_strategy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WireGuardPeer struct {
|
type WireGuardPeer struct {
|
||||||
|
@ -32,9 +32,10 @@ var (
|
|||||||
|
|
||||||
type WireGuard struct {
|
type WireGuard struct {
|
||||||
myOutboundAdapter
|
myOutboundAdapter
|
||||||
bind *wireguard.ClientBind
|
bind *wireguard.ClientBind
|
||||||
device *device.Device
|
device *device.Device
|
||||||
tunDevice wireguard.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) {
|
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,
|
tag: tag,
|
||||||
dependencies: withDialerDependency(options.DialerOptions),
|
dependencies: withDialerDependency(options.DialerOptions),
|
||||||
},
|
},
|
||||||
|
requestStrategy: dns.DomainStrategy(options.RequestStrategy),
|
||||||
}
|
}
|
||||||
var reserved [3]uint8
|
var reserved [3]uint8
|
||||||
if len(options.Reserved) > 0 {
|
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 {
|
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 {
|
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 {
|
func (w *WireGuard) Start() error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user