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

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

i2ptunnel:

Register actual listen host with port mapper
Register POP and SMTP ports with port mapper
parent 0d46c068
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
......@@ -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
......
......@@ -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);
}
}
......
......@@ -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
......
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