sing-box/adapter/outbound/adapter.go

46 lines
989 B
Go
Raw Normal View History

2024-11-02 00:39:02 +08:00
package outbound
import (
"github.com/sagernet/sing-box/option"
)
type Adapter struct {
2024-11-21 18:10:41 +08:00
outboundType string
outboundTag string
2024-11-02 00:39:02 +08:00
network []string
dependencies []string
}
2024-11-21 18:10:41 +08:00
func NewAdapter(outboundType string, outboundTag string, network []string, dependencies []string) Adapter {
2024-11-02 00:39:02 +08:00
return Adapter{
2024-11-21 18:10:41 +08:00
outboundType: outboundType,
outboundTag: outboundTag,
2024-11-02 00:39:02 +08:00
network: network,
dependencies: dependencies,
}
}
2024-11-21 18:10:41 +08:00
func NewAdapterWithDialerOptions(outboundType string, outboundTag string, network []string, dialOptions option.DialerOptions) Adapter {
2024-11-02 00:39:02 +08:00
var dependencies []string
if dialOptions.Detour != "" {
dependencies = []string{dialOptions.Detour}
}
2024-11-21 18:10:41 +08:00
return NewAdapter(outboundType, outboundTag, network, dependencies)
2024-11-02 00:39:02 +08:00
}
func (a *Adapter) Type() string {
2024-11-21 18:10:41 +08:00
return a.outboundType
2024-11-02 00:39:02 +08:00
}
func (a *Adapter) Tag() string {
2024-11-21 18:10:41 +08:00
return a.outboundTag
2024-11-02 00:39:02 +08:00
}
func (a *Adapter) Network() []string {
return a.network
}
func (a *Adapter) Dependencies() []string {
return a.dependencies
}