diff --git a/core/java/src/net/i2p/client/I2PSession.java b/core/java/src/net/i2p/client/I2PSession.java index 9a5826d98..84a3e9317 100644 --- a/core/java/src/net/i2p/client/I2PSession.java +++ b/core/java/src/net/i2p/client/I2PSession.java @@ -443,6 +443,14 @@ public interface I2PSession { */ public void sendBlindingInfo(BlindData bd) throws I2PSessionException; + /** + * Always valid in RouterContext. Returns null if not yet connected in I2PAppContext. + * + * @return null if unknown + * @since 0.9.46 + */ + public String getRouterVersion(); + /** * Listen on specified protocol and port. * diff --git a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java index 7fa66c8ce..24c8eed89 100644 --- a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java @@ -145,6 +145,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 private final AtomicInteger _lookupID = new AtomicInteger(); protected final Object _bwReceivedLock = new Object(); protected volatile int[] _bwLimits; + private volatile String _routerVersion; protected final I2PClientMessageHandlerMap _handlerMap; @@ -227,6 +228,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 /** @param routerVersion as rcvd in the SetDateMessage, may be null for very old routers */ void dateUpdated(String routerVersion) { + _routerVersion = routerVersion; boolean isrc = _context.isRouterContext(); _routerSupportsFastReceive = isrc || (routerVersion != null && routerVersion.length() > 0 && @@ -1881,6 +1883,18 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 sendMessage_unchecked(new BlindingInfoMessage(bd, id)); } + /** + * Always valid in RouterContext. Returns null if not yet connected in I2PAppContext. + * + * @return null if unknown + * @since 0.9.46 + */ + public String getRouterVersion() { + if (_context.isRouterContext()) + return CoreVersion.VERSION; + return _routerVersion; + } + protected void updateActivity() { _lastActivity = _context.clock().now(); if (_isReduced) {