candAddress = di.getPublicIP() != null ? di.getPublicIP().getHostAddress() : null;
nodeNatted = true; socketTest1 = null; di = new DiscoveryInfo(sourceIaddress); di.setOpenAccess(); di.setFullCone(); di.setSymmetricUDPFirewall(); di.setRestrictedCone(); di.setPortRestrictedCone();
ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode); if (ec != null) { di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return false; di.setError(700, "The server is sending an incomplete response (Mapped Address and Changed Address message attributes are missing). The client should not retry."); LOGGER.debug("Response does not contain a Mapped Address or Changed Address message attribute."); return false; } else { di.setPublicIP(ma.getAddress().getInetAddress()); di.setPublicPort(ma.getPort()); if ((ma.getPort() == socketTest1.getLocalPort()) && (ma.getAddress().getInetAddress().equals(socketTest1.getLocalAddress()))) { LOGGER.debug("Node is not natted."); di.setBlockedUDP(); LOGGER.debug("Node is not capable of UDP communication."); return false;
di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return false; di.setOpenAccess(); LOGGER.debug("Node has open access to the Internet (or, at least the node is behind a full-cone NAT without translation)."); } else { di.setFullCone(); LOGGER.debug("Node is behind a full-cone NAT."); LOGGER.debug("Test 2: Socket timeout while receiving the response. Maximum retry limit exceed. Give up."); if (!nodeNatted) { di.setSymmetricUDPFirewall(); LOGGER.debug("Node is behind a symmetric UDP firewall."); return false;
di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return; di.setRestrictedCone(); LOGGER.debug("Node is behind a restricted NAT."); return; } else { LOGGER.debug("Test 3: Socket timeout while receiving the response. Maximum retry limit exceed. Give up."); di.setPortRestrictedCone(); LOGGER.debug("Node is behind a port restricted NAT."); return;
ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode); if (ec != null) { di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return false; di.setError(700, "The server is sending an incomplete response (Mapped Address message attribute is missing). The client should not retry."); LOGGER.debug("Response does not contain a Mapped Address message attribute."); return false; } else { if ((ma.getPort() != ma2.getPort()) || (!(ma.getAddress().getInetAddress().equals(ma2.getAddress().getInetAddress())))) { di.setSymmetric(); LOGGER.debug("Node is behind a symmetric NAT."); return false;
di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return ERROR;
public DiscoveryInfo test() throws UtilityException, SocketException, UnknownHostException, IOException, MessageAttributeParsingException, MessageAttributeException, MessageHeaderParsingException{ ma = null; ca = null; nodeNatted = true; socketTest1 = null; di = new DiscoveryInfo(sourceIaddress); if (test1()) { if (test2()) { if (test1Redo()) { test3(); } } } socketTest1.close(); return di; }
nodeNatted = true; socketTest1 = null; di = new DiscoveryInfo(sourceIaddress); di.setOpenAccess(); di.setFullCone(); di.setSymmetricUDPFirewall(); di.setRestrictedCone(); di.setPortRestrictedCone();
ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode); if (ec != null) { di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return false; di.setError(700, "The server is sending an incomplete response (Mapped Address and Changed Address message attributes are missing). The client should not retry."); LOGGER.debug("Response does not contain a Mapped Address or Changed Address message attribute."); return false; } else { di.setPublicIP(ma.getAddress().getInetAddress()); di.setPublicPort(ma.getPort()); if ((ma.getPort() == socketTest1.getLocalPort()) && (ma.getAddress().getInetAddress().equals(socketTest1.getLocalAddress()))) { LOGGER.debug("Node is not natted."); di.setBlockedUDP(); LOGGER.debug("Node is not capable of UDP communication."); return false;
di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return false; di.setOpenAccess(); LOGGER.debug("Node has open access to the Internet (or, at least the node is behind a full-cone NAT without translation)."); } else { di.setFullCone(); LOGGER.debug("Node is behind a full-cone NAT."); LOGGER.debug("Test 2: Socket timeout while receiving the response. Maximum retry limit exceed. Give up."); if (!nodeNatted) { di.setSymmetricUDPFirewall(); LOGGER.debug("Node is behind a symmetric UDP firewall."); return false;
di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return; di.setRestrictedCone(); LOGGER.debug("Node is behind a restricted NAT."); return; } else { LOGGER.debug("Test 3: Socket timeout while receiving the response. Maximum retry limit exceed. Give up."); di.setPortRestrictedCone(); LOGGER.debug("Node is behind a port restricted NAT."); return;
ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode); if (ec != null) { di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return false; di.setError(700, "The server is sending an incomplete response (Mapped Address message attribute is missing). The client should not retry."); LOGGER.debug("Response does not contain a Mapped Address message attribute."); return false; } else { if ((ma.getPort() != ma2.getPort()) || (!(ma.getAddress().getInetAddress().equals(ma2.getAddress().getInetAddress())))) { di.setSymmetric(); LOGGER.debug("Node is behind a symmetric NAT."); return false;
di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return ERROR;
public DiscoveryInfo test() throws UtilityException, SocketException, UnknownHostException, IOException, MessageAttributeParsingException, MessageAttributeException, MessageHeaderParsingException{ ma = null; ca = null; nodeNatted = true; socketTest1 = null; di = new DiscoveryInfo(sourceIaddress); if (test1()) { if (test2()) { if (test1Redo()) { test3(); } } } socketTest1.close(); return di; }
if (di.getPublicIP() != null) { Candidate cand = new Candidate(new Address(di.getPublicIP().getAddress()), CandidateType.ServerReflexive, componentId, local); cand.setComponentId(componentId); candidates.add(cand);
ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode); if (ec != null) { di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return false; di.setError(700, "The server is sending an incomplete response (Mapped Address and Changed Address message attributes are missing). The client should not retry."); LOGGER.debug("Response does not contain a Mapped Address or Changed Address message attribute."); return false; } else { di.setPublicIP(ma.getAddress().getInetAddress()); di.setPublicPort(ma.getPort()); if ((ma.getPort() == socketTest1.getLocalPort()) && (ma.getAddress().getInetAddress().equals(socketTest1.getLocalAddress()))) { LOGGER.debug("Node is not natted."); di.setBlockedUDP(); LOGGER.debug("Node is not capable of UDP communication."); return false;
ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode); if (ec != null) { di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return false; di.setError(700, "The server is sending an incomplete response (Mapped Address message attribute is missing). The client should not retry."); LOGGER.debug("Response does not contain a Mapped Address message attribute."); return false; } else { if ((ma.getPort() != ma2.getPort()) || (!(ma.getAddress().getInetAddress().equals(ma2.getAddress().getInetAddress())))) { di.setSymmetric(); LOGGER.debug("Node is behind a symmetric NAT."); return false;
di.setError(ec.getResponseCode(), ec.getReason()); LOGGER.debug("Message header contains an Errorcode message attribute."); return ERROR;
if (di.getPublicIP() != null) { Candidate cand = new Candidate(new Address(di.getPublicIP().getAddress()), CandidateType.ServerReflexive, componentId, local); cand.setComponentId(componentId); candidates.add(cand);