forked from I2P_Developers/i2p.i2p
* I2PTunnel: Register ports with the PortMapper
* Update: Find the proxy port in the PortMapper
This commit is contained in:
@@ -25,6 +25,7 @@ import net.i2p.data.Destination;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.PortMapper;
|
||||
|
||||
/**
|
||||
* Supports the following:
|
||||
@@ -152,6 +153,20 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
||||
return opts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startRunning() {
|
||||
super.startRunning();
|
||||
_context.portMapper().register(PortMapper.SVC_HTTPS_PROXY, getLocalPort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close(boolean forced) {
|
||||
int reg = _context.portMapper().getPort(PortMapper.SVC_HTTPS_PROXY);
|
||||
if (reg == getLocalPort())
|
||||
_context.portMapper().unregister(PortMapper.SVC_HTTPS_PROXY);
|
||||
return super.close(forced);
|
||||
}
|
||||
|
||||
protected void clientConnectionRun(Socket s) {
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
|
@@ -39,6 +39,7 @@ import net.i2p.data.Hash;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.PortMapper;
|
||||
import net.i2p.util.Translate;
|
||||
|
||||
/**
|
||||
@@ -291,6 +292,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
public void startRunning() {
|
||||
super.startRunning();
|
||||
this.isr = new InternalSocketRunner(this);
|
||||
_context.portMapper().register(PortMapper.SVC_HTTP_PROXY, getLocalPort());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,6 +300,9 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
||||
*/
|
||||
@Override
|
||||
public boolean close(boolean forced) {
|
||||
int reg = _context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY);
|
||||
if (reg == getLocalPort())
|
||||
_context.portMapper().unregister(PortMapper.SVC_HTTP_PROXY);
|
||||
boolean rv = super.close(forced);
|
||||
if (this.isr != null)
|
||||
this.isr.stopRunning();
|
||||
|
@@ -21,6 +21,7 @@ import net.i2p.i2ptunnel.irc.IrcOutboundFilter;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.PortMapper;
|
||||
|
||||
/**
|
||||
* Todo: Can we extend I2PTunnelClient instead and remove some duplicated code?
|
||||
@@ -151,8 +152,17 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase {
|
||||
return dests.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startRunning() {
|
||||
super.startRunning();
|
||||
_context.portMapper().register(PortMapper.SVC_IRC, getLocalPort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close(boolean forced) {
|
||||
int reg = _context.portMapper().getPort(PortMapper.SVC_IRC);
|
||||
if (reg == getLocalPort())
|
||||
_context.portMapper().unregister(PortMapper.SVC_IRC);
|
||||
synchronized(this) {
|
||||
if (_DCCServer != null) {
|
||||
_DCCServer.close(forced);
|
||||
|
Reference in New Issue
Block a user