mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-27 19:11:28 +00:00
a99c3108a7
Refactor Authenticator interface to struct & Update smux & Update gVisor to 20231204.0 & Update wireguard-go & Add GSO support for TUN/WireGuard & Fix router pre-start & Fix bind forwarder to interface for systems stack
39 lines
880 B
Go
39 lines
880 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, error) {
|
|
if options.IsWireGuardListener {
|
|
return NewDefault(router, options)
|
|
}
|
|
var (
|
|
dialer N.Dialer
|
|
err error
|
|
)
|
|
if options.Detour == "" {
|
|
dialer, err = NewDefault(router, options)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
} else {
|
|
dialer = NewDetour(router, options.Detour)
|
|
}
|
|
domainStrategy := dns.DomainStrategy(options.DomainStrategy)
|
|
if domainStrategy != dns.DomainStrategyAsIS || options.Detour == "" {
|
|
dialer = NewResolveDialer(
|
|
router,
|
|
dialer,
|
|
options.Detour == "" && !options.TCPFastOpen,
|
|
domainStrategy,
|
|
time.Duration(options.FallbackDelay))
|
|
}
|
|
return dialer, nil
|
|
}
|