Unsupported library that attempts to punch holes through NAT
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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. }