Merge 05c860a58aca53b965426022e14edad46b7c39a2 into e3f85676904846d9186a4a3884e7ffe0bd3b9ce8

This commit is contained in:
Stephanos Komnenos 2024-01-02 04:06:36 -08:00 committed by GitHub
commit 96ce5980d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 11 deletions

View File

@ -31,6 +31,7 @@
"workers": 4,
"mtu": 1408,
"network": "tcp",
"request_strategy": "prefer_ipv4",
... // Dial Fields
}
@ -137,6 +138,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.

View File

@ -19,6 +19,7 @@
"workers": 4,
"mtu": 1408,
"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/)。

View File

@ -10,12 +10,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 {

View File

@ -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 {