Add resolver for inbound

This commit is contained in:
世界 2022-07-07 23:36:32 +08:00
parent 538a1f5909
commit 9c256afc1a
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
22 changed files with 261 additions and 173 deletions

View file

@ -10,16 +10,18 @@ import (
)
func New(router adapter.Router, options option.DialerOptions) N.Dialer {
domainStrategy := C.DomainStrategy(options.DomainStrategy)
var dialer N.Dialer
if options.Detour == "" {
dialer = NewDefault(options)
dialer = NewResolveDialer(router, dialer, domainStrategy)
return NewDefault(options)
} else {
dialer = NewDetour(router, options.Detour)
if domainStrategy != C.DomainStrategyAsIS {
dialer = NewResolveDialer(router, dialer, domainStrategy)
}
return NewDetour(router, options.Detour)
}
}
func NewOutbound(router adapter.Router, options option.OutboundDialerOptions) N.Dialer {
dialer := New(router, options.DialerOptions)
domainStrategy := C.DomainStrategy(options.DomainStrategy)
if domainStrategy != C.DomainStrategyAsIS || options.Detour == "" && !C.CGO_ENABLED {
dialer = NewResolveDialer(router, dialer, domainStrategy)
}
if options.OverrideOptions.IsValid() {
dialer = NewOverride(dialer, common.PtrValueOrDefault(options.OverrideOptions))