register I2CP with the PortMapper

This commit is contained in:
zzz
2015-09-21 15:13:39 +00:00
parent 53ae727935
commit 3f213cf1db
2 changed files with 14 additions and 1 deletions

View File

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

View File

@@ -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;