PathChecker.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
  4. */
  5. package com.zerotier.sdk;
  6. import java.net.InetSocketAddress;
  7. public interface PathChecker {
  8. /**
  9. * Callback to check whether a path should be used for ZeroTier traffic
  10. *
  11. * This function must return true if the path should be used.
  12. *
  13. * If no path check function is specified, ZeroTier will still exclude paths
  14. * that overlap with ZeroTier-assigned and managed IP address blocks. But the
  15. * use of a path check function is recommended to ensure that recursion does
  16. * not occur in cases where addresses are assigned by the OS or managed by
  17. * an out of band mechanism like DHCP. The path check function should examine
  18. * all configured ZeroTier interfaces and check to ensure that the supplied
  19. * addresses will not result in ZeroTier traffic being sent over a ZeroTier
  20. * interface (recursion).
  21. *
  22. * Obviously this is not required in configurations where this can't happen,
  23. * such as network containers or embedded.
  24. *
  25. * @param ztAddress ZeroTier address or 0 for none/any
  26. * @param localAddress Local interface address
  27. * @param remoteAddress remote address
  28. */
  29. boolean onPathCheck(long ztAddress, InetSocketAddress localAddress, InetSocketAddress remoteAddress);
  30. /**
  31. * Function to get physical addresses for ZeroTier peers
  32. *
  33. * If provided this function will be occasionally called to get physical
  34. * addresses that might be tried to reach a ZeroTier address.
  35. *
  36. * @param ztAddress ZeroTier address (least significant 40 bits)
  37. * @param ss_family desired address family or -1 for any
  38. * @return address and port of ztAddress or null
  39. */
  40. InetSocketAddress onPathLookup(long ztAddress, int ss_family);
  41. }