sing-box/common/dialer/dialer.go

28 lines
775 B
Go
Raw Normal View History

package dialer
import (
2022-07-08 12:58:43 +08:00
"time"
2022-07-06 15:01:09 +08:00
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/option"
2022-07-11 18:44:59 +08:00
"github.com/sagernet/sing-dns"
2022-07-08 23:03:57 +08:00
N "github.com/sagernet/sing/common/network"
)
func New(router adapter.Router, options option.DialerOptions) N.Dialer {
if options.Detour == "" {
return NewDefault(router, options)
} else {
2022-07-07 23:36:32 +08:00
return NewDetour(router, options.Detour)
}
}
func NewOutbound(router adapter.Router, options option.OutboundDialerOptions) N.Dialer {
dialer := New(router, options.DialerOptions)
2022-07-11 18:44:59 +08:00
domainStrategy := dns.DomainStrategy(options.DomainStrategy)
if domainStrategy != dns.DomainStrategyAsIS || options.Detour == "" {
dialer = NewResolveDialer(router, dialer, domainStrategy, time.Duration(options.FallbackDelay))
}
return dialer
}