interface.go 873 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (C) 2015 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package nat
  7. import (
  8. "context"
  9. "net"
  10. "time"
  11. )
  12. type Protocol string
  13. const (
  14. TCP Protocol = "TCP"
  15. UDP Protocol = "UDP"
  16. )
  17. type IPVersion int8
  18. const (
  19. IPvAny = iota
  20. IPv4Only
  21. IPv6Only
  22. )
  23. type Device interface {
  24. ID() string
  25. GetLocalIPv4Address() net.IP
  26. AddPortMapping(ctx context.Context, protocol Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error)
  27. AddPinhole(ctx context.Context, protocol Protocol, addr Address, duration time.Duration) ([]net.IP, error)
  28. GetExternalIPv4Address(ctx context.Context) (net.IP, error)
  29. SupportsIPVersion(version IPVersion) bool
  30. }