/** * Returns a String representation of the object. * @return a String representation of the object. */ public override string ToString() { return("net.java.stun4j.stack.AccessPoint@" + apDescriptor.GetAddress() + " status: " + (isRunning? "not":"") + " running"); }
/** * Implements the discovery process itself (see class description). * @return a StunDiscoveryReport containing details about the network * configuration of the host where the class is executed. * @throws StunException ILLEGAL_STATE if the discoverer has not been started * NETWORK_ERROR or ILLEGAL_ARGUMENT if a failure occurs while executing * the discovery algorithm */ virtual public StunDiscoveryReport determineAddress() { checkStarted(); StunDiscoveryReport report = new StunDiscoveryReport(); StunMessageEvent evt = doTestI(serverAddress); if (evt == null) { //UDP Blocked report.SetNatType(StunDiscoveryReport.UDP_BLOCKING_FIREWALL); return(report); } else { StunAddress mappedAddress = ((MappedAddressAttribute)evt.GetMessage(). GetAttribute(Attribute.MAPPED_ADDRESS)).GetAddress(); StunAddress backupServerAddress = ((ChangedAddressAttribute)evt.GetMessage(). GetAttribute(Attribute.CHANGED_ADDRESS)).GetAddress(); report.SetPublicAddress(mappedAddress); if (mappedAddress.Equals(apDescriptor.GetAddress())) { evt = doTestII(serverAddress); if (evt == null) { //Sym UDP Firewall report.SetNatType(StunDiscoveryReport.SYMMETRIC_UDP_FIREWALL); return(report); } else { //open internet report.SetNatType(StunDiscoveryReport.OPEN_INTERNET); return(report); } } else { evt = doTestII(serverAddress); if (evt == null) { evt = doTestI(backupServerAddress); if (evt == null) { // System.oout.println("Failed to receive a response from backup stun server!"); return(report); } StunAddress mappedAddress2 = ((MappedAddressAttribute)evt.GetMessage(). GetAttribute(Attribute.MAPPED_ADDRESS)).GetAddress(); if (mappedAddress.Equals(mappedAddress2)) { evt = doTestIII(serverAddress); if (evt == null) { //port restricted cone report.SetNatType(StunDiscoveryReport.PORT_RESTRICTED_CONE_NAT); return(report); } else { //restricted cone report.SetNatType(StunDiscoveryReport.RESTRICTED_CONE_NAT); return(report); } } else { //Symmetric NAT report.SetNatType(StunDiscoveryReport.SYMMETRIC_NAT); return(report); } } else { //full cone report.SetNatType(StunDiscoveryReport.FULL_CONE_NAT); return(report); } } } }