adapter.go 984 B

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