Transports: Remove IPv6 addresses on transition to IPv6 firewalled

log tweaks
This commit is contained in:
zzz
2019-09-06 15:51:32 +00:00
parent 71376d53c5
commit aed6d433c8
5 changed files with 68 additions and 29 deletions

View File

@ -1,5 +1,19 @@
2019-09-06 zzz
* Transports: Remove IPv6 addresses on transition to IPv6 firewalled
2019-09-04 zzz
* SSU: Don't mark peer unreachable if it reports
we have a bad port (ticket #2467)
* SusiMail:
- Show "to" rather than "from" in sent and drafts folder (ticket #2571)
- Fix sort links going to wrong folder
2019-09-03 zzz 2019-09-03 zzz
* SSU: Fix IPv6 peer test not firing
* Tunnels: Use context AES for hop processing * Tunnels: Use context AES for hop processing
* Utils:
- Fix SAN verification for IPv6 hostnames
- Add Quad9 DoH servers
2019-09-02 zzz 2019-09-02 zzz
* Unit test fixes * Unit test fixes

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 2; public final static long BUILD = 3;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";

View File

@ -371,7 +371,8 @@ public abstract class TransportImpl implements Transport {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Took too long from preparation to afterSend(ok? " + sendSuccessful _log.info("Took too long from preparation to afterSend(ok? " + sendSuccessful
+ "): " + allTime + "ms/" + sendTime + "ms after failing on: " + "): " + allTime + "ms/" + sendTime + "ms after failing on: "
+ msg.getFailedTransports() + " and succeeding on " + getStyle()); + msg.getFailedTransports()
+ (sendSuccessful ? (" and succeeding on " + getStyle()) : ""));
if ( (allTime > 60*1000) && (sendSuccessful) ) { if ( (allTime > 60*1000) && (sendSuccessful) ) {
// VERY slow // VERY slow
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
@ -942,8 +943,8 @@ public abstract class TransportImpl implements Transport {
_wasUnreachableEntries.remove(peer); _wasUnreachableEntries.remove(peer);
} }
} }
if (_log.shouldLog(Log.INFO)) if (_log.shouldDebug())
_log.info(this.getStyle() + " setting wasUnreachable to " + yes + " for " + peer, _log.debug(this.getStyle() + " setting wasUnreachable to " + yes + " for " + peer,
yes ? new Exception() : null); yes ? new Exception() : null);
} }

View File

@ -1674,7 +1674,15 @@ public class NTCPTransport extends TransportImpl {
return false; return false;
} }
} }
if (!isIPv6 || newProps.containsKey(RouterAddress.PROP_HOST) || getIPv6Config() == IPV6_ONLY) {
addNTCP2Options(newProps); addNTCP2Options(newProps);
} else {
// IPv6
// We have an IPv4 address, IPv6 transitioned to firewalled,
// so just remove the v6 address
newAddr = null;
}
// stopListening stops the pumper, readers, and writers, so required even if // stopListening stops the pumper, readers, and writers, so required even if
// oldAddr == null since startListening starts them all again // oldAddr == null since startListening starts them all again

View File

@ -960,8 +960,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
// Note that this fails us if we switch from one IP to a second, then back to the first, // Note that this fails us if we switch from one IP to a second, then back to the first,
// as some routers still have the first IP and will successfully connect, // as some routers still have the first IP and will successfully connect,
// leaving us thinking the second IP is still good. // leaving us thinking the second IP is still good.
if (_log.shouldLog(Log.INFO)) if (_log.shouldDebug())
_log.info("Ignoring IP address suggestion, since we have received an inbound con recently"); _log.debug("Ignoring IP address suggestion, since we have received an inbound con recently");
} else { } else {
// New IP // New IP
boolean changeIt = false; boolean changeIt = false;
@ -982,7 +982,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
} }
if (changeIt) { if (changeIt) {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info(from + " and " + _lastFrom + " agree we have a new IP - " _log.info(from + " and " + _lastFrom + " agree we have the IP "
+ Addresses.toString(ourIP, ourPort) + ". Changing address."); + Addresses.toString(ourIP, ourPort) + ". Changing address.");
changeAddress(ourIP, ourPort); changeAddress(ourIP, ourPort);
} }
@ -1011,8 +1011,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
byte[] externalListenHost = current != null ? current.getIP() : null; byte[] externalListenHost = current != null ? current.getIP() : null;
int externalListenPort = current != null ? current.getPort() : getRequestedPort(isIPv6); int externalListenPort = current != null ? current.getPort() : getRequestedPort(isIPv6);
if (_log.shouldLog(Log.INFO)) if (_log.shouldDebug())
_log.info("Change address? status = " + _reachabilityStatus + _log.debug("Change address? status = " + _reachabilityStatus +
" diff = " + (_context.clock().now() - _reachabilityStatusLastUpdated) + " diff = " + (_context.clock().now() - _reachabilityStatusLastUpdated) +
" old = " + Addresses.toString(externalListenHost, externalListenPort) + " old = " + Addresses.toString(externalListenHost, externalListenPort) +
" new = " + Addresses.toString(ourIP, ourPort)); " new = " + Addresses.toString(ourIP, ourPort));
@ -1041,8 +1041,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
//} //}
} else { } else {
// matched what we expect // matched what we expect
if (_log.shouldLog(Log.INFO)) if (_log.shouldDebug())
_log.info("Same address as the current one"); _log.debug("Same address as the current one");
} }
} }
@ -1288,8 +1288,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
* *
*/ */
boolean addRemotePeerState(PeerState peer) { boolean addRemotePeerState(PeerState peer) {
if (_log.shouldLog(Log.INFO)) if (_log.shouldDebug())
_log.info("Add remote peer state: " + peer); _log.debug("Add remote peer state: " + peer);
synchronized(_addDropLock) { synchronized(_addDropLock) {
return locked_addRemotePeerState(peer); return locked_addRemotePeerState(peer);
} }
@ -1485,7 +1485,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
* @param shouldBanlist doesn't really, only sets unreachable * @param shouldBanlist doesn't really, only sets unreachable
*/ */
void dropPeer(PeerState peer, boolean shouldBanlist, String why) { void dropPeer(PeerState peer, boolean shouldBanlist, String why) {
if (_log.shouldLog(Log.INFO)) { if (_log.shouldDebug()) {
long now = _context.clock().now(); long now = _context.clock().now();
StringBuilder buf = new StringBuilder(4096); StringBuilder buf = new StringBuilder(4096);
long timeSinceSend = now - peer.getLastSendTime(); long timeSinceSend = now - peer.getLastSendTime();
@ -1529,7 +1529,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
} }
} }
*/ */
_log.info(buf.toString(), new Exception("Dropped by")); _log.debug(buf.toString(), new Exception("Dropped by"));
} }
synchronized(_addDropLock) { synchronized(_addDropLock) {
locked_dropPeer(peer, shouldBanlist, why); locked_dropPeer(peer, shouldBanlist, why);
@ -2334,16 +2334,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
RouterAddress local = new RouterAddress(STYLE, localOpts, DEFAULT_COST); RouterAddress local = new RouterAddress(STYLE, localOpts, DEFAULT_COST);
replaceCurrentExternalAddress(local, isIPv6); replaceCurrentExternalAddress(local, isIPv6);
} }
if (getCurrentAddress(false) != null) { removeExternalAddress(isIPv6, allowRebuildRouterInfo);
// We must remove current address, otherwise the user will see
// "firewalled with inbound NTCP enabled" warning in console.
// Remove the IPv4 address only
removeAddress(false);
// warning, this calls back into us with allowRebuildRouterInfo = false,
// via CSFI.createAddresses->TM.getAddresses()->updateAddress()->REA
if (allowRebuildRouterInfo)
_context.router().rebuildRouterInfo();
}
return null; return null;
} }
} }
@ -2364,6 +2355,24 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
_currentOurV4Address = ra; _currentOurV4Address = ra;
} }
/**
* @since 0.9.43 pulled out of locked_rebuildExternalAddress
*/
private void removeExternalAddress(boolean isIPv6, boolean allowRebuildRouterInfo) {
synchronized (_rebuildLock) {
if (getCurrentAddress(isIPv6) != null) {
// We must remove current address, otherwise the user will see
// "firewalled with inbound NTCP enabled" warning in console.
// Remove the v4/v6 address only
removeAddress(isIPv6);
// warning, this calls back into us with allowRebuildRouterInfo = false,
// via CSFI.createAddresses->TM.getAddresses()->updateAddress()->REA
if (allowRebuildRouterInfo)
_context.router().rebuildRouterInfo();
}
}
}
/** /**
* Simple fetch of stored IP and port, since * Simple fetch of stored IP and port, since
* we don't put them in the real, published RouterAddress anymore * we don't put them in the real, published RouterAddress anymore
@ -2885,8 +2894,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
} }
if (!_expireBuffer.isEmpty()) { if (!_expireBuffer.isEmpty()) {
if (_log.shouldLog(Log.INFO)) if (_log.shouldDebug())
_log.info("Expiring " + _expireBuffer.size() + " peers"); _log.debug("Expiring " + _expireBuffer.size() + " peers");
for (PeerState peer : _expireBuffer) { for (PeerState peer : _expireBuffer) {
sendDestroy(peer); sendDestroy(peer);
dropPeer(peer, false, "idle too long"); dropPeer(peer, false, "idle too long");
@ -3014,8 +3023,15 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
// Always rebuild when the status changes, even if our address hasn't changed, // Always rebuild when the status changes, even if our address hasn't changed,
// as rebuildExternalAddress() calls replaceAddress() which calls CSFI.notifyReplaceAddress() // as rebuildExternalAddress() calls replaceAddress() which calls CSFI.notifyReplaceAddress()
// which will start up NTCP inbound when we transition to OK. // which will start up NTCP inbound when we transition to OK.
// if (needsRebuild()) if (isIPv6) {
if (status == Status.IPV4_OK_IPV6_FIREWALLED ||
status == Status.IPV4_UNKNOWN_IPV6_FIREWALLED ||
status == Status.IPV4_DISABLED_IPV6_FIREWALLED) {
removeExternalAddress(true, true);
}
} else {
rebuildExternalAddress(); rebuildExternalAddress();
}
} else { } else {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Status unchanged: " + _reachabilityStatus + _log.info("Status unchanged: " + _reachabilityStatus +