Unsupported library that attempts to punch holes through NAT
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

NatType.java 760B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package com.md87.nat;
  6. /**
  7. *
  8. * @author chris
  9. */
  10. public enum NatType {
  11. OPEN(true),
  12. FULL_CONE(true),
  13. RESTRICTED_CONE(false),
  14. PORT_RESTRICTED_CONE(false),
  15. SYMMETRIC(false);
  16. private final boolean canTraverseWithSymmetric;
  17. NatType(final boolean canTraverseWithSymmetric) {
  18. this.canTraverseWithSymmetric = canTraverseWithSymmetric;
  19. }
  20. public boolean canTraverseWith(final NatType type) {
  21. if (type == SYMMETRIC) {
  22. return canTraverseWithSymmetric;
  23. } else if (this == SYMMETRIC) {
  24. return type.canTraverseWith(this);
  25. } else {
  26. return true;
  27. }
  28. }
  29. }