sing-box/outbound/dialer/dialer.go

23 lines
540 B
Go
Raw Normal View History

package dialer
import (
"github.com/sagernet/sing/common"
N "github.com/sagernet/sing/common/network"
2022-07-06 07:01:09 +00:00
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/option"
)
func New(router adapter.Router, options option.DialerOptions) N.Dialer {
var dialer N.Dialer
if options.Detour == "" {
2022-07-06 15:11:48 +00:00
dialer = NewDefault(options)
} else {
2022-07-06 15:11:48 +00:00
dialer = NewDetour(router, options.Detour)
}
if options.OverrideOptions.IsValid() {
2022-07-06 15:11:48 +00:00
dialer = NewOverride(dialer, common.PtrValueOrDefault(options.OverrideOptions))
}
return dialer
}