2022-07-03 12:59:25 +00:00
|
|
|
package dialer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/sagernet/sing-box/adapter"
|
|
|
|
"github.com/sagernet/sing-box/option"
|
|
|
|
"github.com/sagernet/sing/common"
|
|
|
|
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(options)
|
|
|
|
} else {
|
|
|
|
dialer = newDetour(router, options)
|
|
|
|
}
|
2022-07-03 15:23:18 +00:00
|
|
|
if options.OverrideOptions.IsValid() {
|
2022-07-03 12:59:25 +00:00
|
|
|
dialer = newOverride(dialer, common.PtrValueOrDefault(options.OverrideOptions))
|
|
|
|
}
|
|
|
|
return dialer
|
|
|
|
}
|