mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-23 17:11:29 +00:00
25 lines
662 B
Go
25 lines
662 B
Go
package dialer
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/sagernet/sing-box/adapter"
|
|
"github.com/sagernet/sing-box/option"
|
|
"github.com/sagernet/sing-dns"
|
|
N "github.com/sagernet/sing/common/network"
|
|
)
|
|
|
|
func New(router adapter.Router, options option.DialerOptions) N.Dialer {
|
|
var dialer N.Dialer
|
|
if options.Detour == "" {
|
|
dialer = NewDefault(router, options)
|
|
} else {
|
|
dialer = NewDetour(router, options.Detour)
|
|
}
|
|
domainStrategy := dns.DomainStrategy(options.DomainStrategy)
|
|
if domainStrategy != dns.DomainStrategyAsIS || options.Detour == "" {
|
|
dialer = NewResolveDialer(router, dialer, domainStrategy, time.Duration(options.FallbackDelay))
|
|
}
|
|
return dialer
|
|
}
|