adapter.go 989 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package outbound
  2. import (
  3. "github.com/sagernet/sing-box/option"
  4. )
  5. type Adapter struct {
  6. outboundType string
  7. outboundTag string
  8. network []string
  9. dependencies []string
  10. }
  11. func NewAdapter(outboundType string, outboundTag string, network []string, dependencies []string) Adapter {
  12. return Adapter{
  13. outboundType: outboundType,
  14. outboundTag: outboundTag,
  15. network: network,
  16. dependencies: dependencies,
  17. }
  18. }
  19. func NewAdapterWithDialerOptions(outboundType string, outboundTag string, network []string, dialOptions option.DialerOptions) Adapter {
  20. var dependencies []string
  21. if dialOptions.Detour != "" {
  22. dependencies = []string{dialOptions.Detour}
  23. }
  24. return NewAdapter(outboundType, outboundTag, network, dependencies)
  25. }
  26. func (a *Adapter) Type() string {
  27. return a.outboundType
  28. }
  29. func (a *Adapter) Tag() string {
  30. return a.outboundTag
  31. }
  32. func (a *Adapter) Network() []string {
  33. return a.network
  34. }
  35. func (a *Adapter) Dependencies() []string {
  36. return a.dependencies
  37. }