forked from I2P_Developers/i2p.i2p
i2ptunnel:
Register actual listen host with port mapper Register POP and SMTP ports with port mapper
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user