forked from I2P_Developers/i2p.i2p
i2ptunnel: Don't register port mapper in clients overriding startRunning()
if super.startRunning() failed Register as HTTPS proxy also in HTTP client
This commit is contained in:
@@ -53,7 +53,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
protected boolean _ownDest;
|
protected boolean _ownDest;
|
||||||
|
|
||||||
protected Destination dest;
|
protected Destination dest;
|
||||||
private int localPort;
|
private volatile int localPort;
|
||||||
private final String _handlerName;
|
private final String _handlerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -477,6 +477,9 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
* This will be fast if i2cp.delayOpen is true, but could take
|
* This will be fast if i2cp.delayOpen is true, but could take
|
||||||
* a LONG TIME if it is false, as it connects to the router and builds tunnels.
|
* a LONG TIME if it is false, as it connects to the router and builds tunnels.
|
||||||
*
|
*
|
||||||
|
* Extending classes must check the value of boolean open after calling
|
||||||
|
* super.startRunning(), if false then something went wrong.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public void startRunning() {
|
public void startRunning() {
|
||||||
boolean openNow = !Boolean.parseBoolean(getTunnel().getClientOptions().getProperty("i2cp.delayOpen"));
|
boolean openNow = !Boolean.parseBoolean(getTunnel().getClientOptions().getProperty("i2cp.delayOpen"));
|
||||||
|
@@ -120,7 +120,8 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
|
|||||||
@Override
|
@Override
|
||||||
public void startRunning() {
|
public void startRunning() {
|
||||||
super.startRunning();
|
super.startRunning();
|
||||||
_context.portMapper().register(PortMapper.SVC_HTTPS_PROXY, getLocalPort());
|
if (open)
|
||||||
|
_context.portMapper().register(PortMapper.SVC_HTTPS_PROXY, getLocalPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -293,9 +293,13 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
|||||||
_context.statManager().createRateStat("i2ptunnel.httpCompressed", "compressed size transferred", "I2PTunnel", new long[] { 60*60*1000 });
|
_context.statManager().createRateStat("i2ptunnel.httpCompressed", "compressed size transferred", "I2PTunnel", new long[] { 60*60*1000 });
|
||||||
_context.statManager().createRateStat("i2ptunnel.httpExpanded", "size transferred after expansion", "I2PTunnel", new long[] { 60*60*1000 });
|
_context.statManager().createRateStat("i2ptunnel.httpExpanded", "size transferred after expansion", "I2PTunnel", new long[] { 60*60*1000 });
|
||||||
super.startRunning();
|
super.startRunning();
|
||||||
this.isr = new InternalSocketRunner(this);
|
if (open) {
|
||||||
this.isr.start();
|
this.isr = new InternalSocketRunner(this);
|
||||||
_context.portMapper().register(PortMapper.SVC_HTTP_PROXY, getLocalPort());
|
this.isr.start();
|
||||||
|
int port = getLocalPort();
|
||||||
|
_context.portMapper().register(PortMapper.SVC_HTTP_PROXY, port);
|
||||||
|
_context.portMapper().register(PortMapper.SVC_HTTPS_PROXY, port);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -303,10 +307,15 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean close(boolean forced) {
|
public boolean close(boolean forced) {
|
||||||
|
int port = getLocalPort();
|
||||||
int reg = _context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY);
|
int reg = _context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY);
|
||||||
if(reg == getLocalPort()) {
|
if (reg == port) {
|
||||||
_context.portMapper().unregister(PortMapper.SVC_HTTP_PROXY);
|
_context.portMapper().unregister(PortMapper.SVC_HTTP_PROXY);
|
||||||
}
|
}
|
||||||
|
reg = _context.portMapper().getPort(PortMapper.SVC_HTTPS_PROXY);
|
||||||
|
if (reg == port) {
|
||||||
|
_context.portMapper().unregister(PortMapper.SVC_HTTPS_PROXY);
|
||||||
|
}
|
||||||
boolean rv = super.close(forced);
|
boolean rv = super.close(forced);
|
||||||
if(this.isr != null) {
|
if(this.isr != null) {
|
||||||
this.isr.stopRunning();
|
this.isr.stopRunning();
|
||||||
|
@@ -198,7 +198,8 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase {
|
|||||||
@Override
|
@Override
|
||||||
public void startRunning() {
|
public void startRunning() {
|
||||||
super.startRunning();
|
super.startRunning();
|
||||||
_context.portMapper().register(PortMapper.SVC_IRC, getLocalPort());
|
if (open)
|
||||||
|
_context.portMapper().register(PortMapper.SVC_IRC, getLocalPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user