tun.go 929 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package test
  2. import (
  3. "errors"
  4. "io"
  5. "net/netip"
  6. "github.com/slackhq/nebula/routing"
  7. )
  8. type NoopTun struct{}
  9. func (NoopTun) UnsafeNetworks() []netip.Prefix {
  10. return nil
  11. }
  12. func (NoopTun) SNATAddress() netip.Prefix {
  13. return netip.Prefix{}
  14. }
  15. func (NoopTun) UnsafeIPv4OriginAddress() netip.Prefix {
  16. return netip.Prefix{}
  17. }
  18. func (NoopTun) RoutesFor(addr netip.Addr) routing.Gateways {
  19. return routing.Gateways{}
  20. }
  21. func (NoopTun) Activate() error {
  22. return nil
  23. }
  24. func (NoopTun) Networks() []netip.Prefix {
  25. return []netip.Prefix{}
  26. }
  27. func (NoopTun) Name() string {
  28. return "noop"
  29. }
  30. func (NoopTun) Read([]byte) (int, error) {
  31. return 0, nil
  32. }
  33. func (NoopTun) Write([]byte) (int, error) {
  34. return 0, nil
  35. }
  36. func (NoopTun) SupportsMultiqueue() bool {
  37. return false
  38. }
  39. func (NoopTun) NewMultiQueueReader() (io.ReadWriteCloser, error) {
  40. return nil, errors.New("unsupported")
  41. }
  42. func (NoopTun) Close() error {
  43. return nil
  44. }