2022-07-03 12:59:25 +00:00
|
|
|
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"
|
2022-07-03 12:59:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
2022-07-03 12:59:25 +00:00
|
|
|
} else {
|
2022-07-06 15:11:48 +00:00
|
|
|
dialer = NewDetour(router, options.Detour)
|
2022-07-03 12:59:25 +00:00
|
|
|
}
|
2022-07-03 15:23:18 +00:00
|
|
|
if options.OverrideOptions.IsValid() {
|
2022-07-06 15:11:48 +00:00
|
|
|
dialer = NewOverride(dialer, common.PtrValueOrDefault(options.OverrideOptions))
|
2022-07-03 12:59:25 +00:00
|
|
|
}
|
|
|
|
return dialer
|
|
|
|
}
|