adapter.go 929 B

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