I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 3f213cf1 authored by zzz's avatar zzz
Browse files

register I2CP with the PortMapper

parent 53ae7279
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment