From 3f213cf1dbfbcdce50eec622506e4f7d8d6058c4 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Mon, 21 Sep 2015 15:13:39 +0000 Subject: [PATCH] register I2CP with the PortMapper --- core/java/src/net/i2p/util/PortMapper.java | 2 ++ .../net/i2p/router/client/ClientListenerRunner.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/java/src/net/i2p/util/PortMapper.java b/core/java/src/net/i2p/util/PortMapper.java index 8160204335..d32a4f5a5a 100644 --- a/core/java/src/net/i2p/util/PortMapper.java +++ b/core/java/src/net/i2p/util/PortMapper.java @@ -33,6 +33,8 @@ public class PortMapper { public static final String SVC_BOB = "BOB"; /** not necessary, already in config? */ public static final String SVC_I2CP = "I2CP"; + /** @since 0.9.23 */ + public static final String SVC_I2CP_SSL = "I2CP-SSL"; /** * @param context unused for now diff --git a/router/java/src/net/i2p/router/client/ClientListenerRunner.java b/router/java/src/net/i2p/router/client/ClientListenerRunner.java index e88339b0e1..10e9241064 100644 --- a/router/java/src/net/i2p/router/client/ClientListenerRunner.java +++ b/router/java/src/net/i2p/router/client/ClientListenerRunner.java @@ -18,6 +18,7 @@ import net.i2p.client.I2PClient; import net.i2p.router.Router; import net.i2p.router.RouterContext; import net.i2p.util.Log; +import net.i2p.util.PortMapper; /** * Listen for connections on the specified port, and toss them onto the client manager's @@ -78,13 +79,18 @@ class ClientListenerRunner implements Runnable { protected void runServer() { _running = true; int curDelay = 1000; + final String portMapperService = (this instanceof SSLClientListenerRunner) ? PortMapper.SVC_I2CP_SSL + : PortMapper.SVC_I2CP; while (_running) { try { _socket = getServerSocket(); if (_log.shouldLog(Log.DEBUG)) _log.debug("ServerSocket created, before accept: " + _socket); - + if (_port > 0) { + // not for DomainClientListenerRunner + _context.portMapper().register(portMapperService, _socket.getInetAddress().getHostAddress(), _port); + } curDelay = 1000; _listening = true; while (_running) { @@ -115,6 +121,11 @@ class ClientListenerRunner implements Runnable { } catch (IOException ioe) { if (isAlive()) _log.error("Error listening on port " + _port, ioe); + } finally { + if (_port > 0) { + // not for DomainClientListenerRunner + _context.portMapper().unregister(portMapperService); + } } _listening = false; -- GitLab