interface.go 651 B

123456789101112131415161718192021222324252627
  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 Device interface {
  18. ID() string
  19. GetLocalIPAddress() net.IP
  20. AddPortMapping(ctx context.Context, protocol Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error)
  21. GetExternalIPAddress(ctx context.Context) (net.IP, error)
  22. }