I2CP: Add API method to get router version

This commit is contained in:
zzz
2020-05-20 19:03:28 +00:00
parent e1d8e360a5
commit ded4bde905
2 changed files with 22 additions and 0 deletions

View File

@ -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.
*

View File

@ -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) {