diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java index 1add404565e45b1b16021fb74f11b4d663d64707..4ab411baa98ed94d2d5f8666671dbead968d72ff 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java @@ -17,6 +17,7 @@ import net.i2p.client.streaming.I2PSocketAddress; import net.i2p.data.Destination; import net.i2p.util.EventDispatcher; import net.i2p.util.Log; +import net.i2p.util.PortMapper; public class I2PTunnelClient extends I2PTunnelClientBase { @@ -178,4 +179,50 @@ public class I2PTunnelClient extends I2PTunnelClientBase { buildAddresses(targets); super.optionsUpdated(tunnel); } + + /** + * Actually start working on incoming connections. + * Overridden to register with port mapper. + * + * @since 0.9.27 + */ + @Override + public void startRunning() { + super.startRunning(); + if (open) { + I2PSocketAddress addr = pickDestination(); + if (addr != null) { + String svc = null; + String hostname = addr.getHostName(); + if ("smtp.postman.i2p".equals(hostname)) { + svc = PortMapper.SVC_SMTP; + } else if ("pop.postman.i2p".equals(hostname)) { + svc = PortMapper.SVC_POP; + } + if (svc != null) { + _context.portMapper().register(svc, getTunnel().listenHost, getLocalPort()); + } + } + } + } + + /** + * Overridden to unregister with port mapper + * + * @since 0.9.27 + */ + @Override + public boolean close(boolean forced) { + int port = getLocalPort(); + int reg = _context.portMapper().getPort(PortMapper.SVC_SMTP); + if (reg == port) { + _context.portMapper().unregister(PortMapper.SVC_SMTP); + } + reg = _context.portMapper().getPort(PortMapper.SVC_POP); + if (reg == port) { + _context.portMapper().unregister(PortMapper.SVC_POP); + } + boolean rv = super.close(forced); + return rv; + } } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java index 0f5b5dcce5df0937d66b187811d0dcd178605074..fe9e92e947b12f7e0d7364ee6c23889a4d0c436a 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java @@ -125,7 +125,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R public void startRunning() { super.startRunning(); if (open) - _context.portMapper().register(PortMapper.SVC_HTTPS_PROXY, getLocalPort()); + _context.portMapper().register(PortMapper.SVC_HTTPS_PROXY, getTunnel().listenHost, getLocalPort()); } @Override diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index 75e418dd31f6086c7c33a6bdcc52a960c45e3c33..373d1f7d56f60c924a9944b7c7c9a8357c38f307 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -316,8 +316,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn this.isr = new InternalSocketRunner(this); this.isr.start(); int port = getLocalPort(); - _context.portMapper().register(PortMapper.SVC_HTTP_PROXY, port); - _context.portMapper().register(PortMapper.SVC_HTTPS_PROXY, port); + _context.portMapper().register(PortMapper.SVC_HTTP_PROXY, getTunnel().listenHost, port); + _context.portMapper().register(PortMapper.SVC_HTTPS_PROXY, getTunnel().listenHost, port); } } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java index f53a72cd1221c464f5b9dc2194e6b44de47d1773..669492b016efdb10dfa45447b829a7d83ec1c2e2 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java @@ -217,7 +217,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase { public void startRunning() { super.startRunning(); if (open) - _context.portMapper().register(PortMapper.SVC_IRC, getLocalPort()); + _context.portMapper().register(PortMapper.SVC_IRC, getTunnel().listenHost, getLocalPort()); } @Override