* Comm System: Add new STATUS_HOSED for use when UDP bind fails
* Summary bar: Display helpful errror message when UDP bind fails * UDP: Don't bid when UDP bind fails
This commit is contained in:
@ -130,6 +130,8 @@ public class SummaryHelper {
|
|||||||
return "WARN-Firewalled and Fast";
|
return "WARN-Firewalled and Fast";
|
||||||
else
|
else
|
||||||
return "Firewalled";
|
return "Firewalled";
|
||||||
|
case CommSystemFacade.STATUS_HOSED:
|
||||||
|
return "ERR-UDP Port In Use - Set i2np.udp.internalPort=xxxx in advanced config and restart";
|
||||||
case CommSystemFacade.STATUS_UNKNOWN: // fallthrough
|
case CommSystemFacade.STATUS_UNKNOWN: // fallthrough
|
||||||
default:
|
default:
|
||||||
return "Testing";
|
return "Testing";
|
||||||
|
@ -61,6 +61,9 @@ public abstract class CommSystemFacade implements Service {
|
|||||||
*/
|
*/
|
||||||
public void notifyReplaceAddress(RouterAddress UDPAddr) {}
|
public void notifyReplaceAddress(RouterAddress UDPAddr) {}
|
||||||
/**
|
/**
|
||||||
|
* These must be increasing in "badness" (see TransportManager.java),
|
||||||
|
* but UNKNOWN must be last.
|
||||||
|
*
|
||||||
* We are able to receive unsolicited connections
|
* We are able to receive unsolicited connections
|
||||||
*/
|
*/
|
||||||
public static final short STATUS_OK = 0;
|
public static final short STATUS_OK = 0;
|
||||||
@ -75,10 +78,14 @@ public abstract class CommSystemFacade implements Service {
|
|||||||
* cannot receive unsolicited connections
|
* cannot receive unsolicited connections
|
||||||
*/
|
*/
|
||||||
public static final short STATUS_REJECT_UNSOLICITED = 2;
|
public static final short STATUS_REJECT_UNSOLICITED = 2;
|
||||||
|
/**
|
||||||
|
* Our detection system is broken (SSU bind port failed)
|
||||||
|
*/
|
||||||
|
public static final short STATUS_HOSED = 3;
|
||||||
/**
|
/**
|
||||||
* Our reachability is unknown
|
* Our reachability is unknown
|
||||||
*/
|
*/
|
||||||
public static final short STATUS_UNKNOWN = 3;
|
public static final short STATUS_UNKNOWN = 4;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import java.net.DatagramSocket;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
|
|
||||||
|
import net.i2p.router.CommSystemFacade;
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ public class UDPEndpoint {
|
|||||||
_sender.startup();
|
_sender.startup();
|
||||||
_receiver.startup();
|
_receiver.startup();
|
||||||
} catch (SocketException se) {
|
} catch (SocketException se) {
|
||||||
|
_transport.setReachabilityStatus(CommSystemFacade.STATUS_HOSED);
|
||||||
_log.log(Log.CRIT, "Unable to bind on port " + _listenPort, se);
|
_log.log(Log.CRIT, "Unable to bind on port " + _listenPort, se);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -858,6 +858,12 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
else
|
else
|
||||||
return _fastBid;
|
return _fastBid;
|
||||||
} else {
|
} else {
|
||||||
|
// If we don't have a port, all is lost
|
||||||
|
if ( _reachabilityStatus == CommSystemFacade.STATUS_HOSED) {
|
||||||
|
markUnreachable(to);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Validate his SSU address
|
// Validate his SSU address
|
||||||
RouterAddress addr = toAddress.getTargetAddress(STYLE);
|
RouterAddress addr = toAddress.getTargetAddress(STYLE);
|
||||||
if (addr == null) {
|
if (addr == null) {
|
||||||
@ -1870,6 +1876,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
buf.append(" </tr>\n");
|
buf.append(" </tr>\n");
|
||||||
buf.append("<tr><td colspan=\"15\" valign=\"top\" align=\"left\">");
|
buf.append("<tr><td colspan=\"15\" valign=\"top\" align=\"left\">");
|
||||||
long bytesTransmitted = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
|
long bytesTransmitted = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
|
||||||
|
// NPE here early
|
||||||
double averagePacketSize = _context.statManager().getRate("udp.sendPacketSize").getLifetimeAverageValue();
|
double averagePacketSize = _context.statManager().getRate("udp.sendPacketSize").getLifetimeAverageValue();
|
||||||
// lifetime value, not just the retransmitted packets of current connections
|
// lifetime value, not just the retransmitted packets of current connections
|
||||||
resentTotal = (long)_context.statManager().getRate("udp.packetsRetransmitted").getLifetimeEventCount();
|
resentTotal = (long)_context.statManager().getRate("udp.packetsRetransmitted").getLifetimeEventCount();
|
||||||
@ -2005,6 +2012,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
break;
|
break;
|
||||||
case CommSystemFacade.STATUS_REJECT_UNSOLICITED:
|
case CommSystemFacade.STATUS_REJECT_UNSOLICITED:
|
||||||
_context.statManager().addRateData("udp.statusReject", 1, 0);
|
_context.statManager().addRateData("udp.statusReject", 1, 0);
|
||||||
|
// fall through...
|
||||||
|
case CommSystemFacade.STATUS_HOSED:
|
||||||
_reachabilityStatus = status;
|
_reachabilityStatus = status;
|
||||||
_reachabilityStatusLastUpdated = now;
|
_reachabilityStatusLastUpdated = now;
|
||||||
break;
|
break;
|
||||||
@ -2021,6 +2030,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( (status != old) && (status != CommSystemFacade.STATUS_UNKNOWN) ) {
|
if ( (status != old) && (status != CommSystemFacade.STATUS_UNKNOWN) ) {
|
||||||
|
if (_log.shouldLog(Log.INFO))
|
||||||
|
_log.info("Old status: " + old + " New status: " + status + " from: ", new Exception("traceback"));
|
||||||
if (needsRebuild())
|
if (needsRebuild())
|
||||||
rebuildExternalAddress();
|
rebuildExternalAddress();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user