I2CP: Consolidate all the port 7654 definitions

This commit is contained in:
zzz
2018-12-03 15:22:36 +00:00
parent af2eea5916
commit 5e7a277e98
15 changed files with 44 additions and 28 deletions

View File

@ -37,6 +37,7 @@ import java.util.jar.Manifest;
import net.i2p.I2PAppContext;
import net.i2p.app.*;
import net.i2p.client.I2PClient;
import net.i2p.client.I2PSession;
import net.i2p.util.I2PAppThread;
import net.i2p.util.PortMapper;
import net.i2p.util.SimpleTimer2;
@ -242,7 +243,7 @@ public class BOB implements Runnable, ClientApp {
save = true;
}
if (!props.containsKey(I2PClient.PROP_TCP_PORT)) {
props.setProperty(I2PClient.PROP_TCP_PORT, "7654");
props.setProperty(I2PClient.PROP_TCP_PORT, Integer.toString(I2PSession.DEFAULT_LISTEN_PORT));
save = true;
}
if (!props.containsKey(PROP_BOB_PORT)) {

View File

@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import net.i2p.I2PException;
import net.i2p.client.I2PClient;
import net.i2p.client.I2PSession;
import net.i2p.client.streaming.I2PServerSocket;
import net.i2p.client.streaming.I2PSocketManager;
import net.i2p.client.streaming.I2PSocketManagerFactory;
@ -96,13 +97,15 @@ public class MUXlisten implements Runnable {
}
String i2cpHost = Q.getProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1");
int i2cpPort = 7654;
String i2cpPortStr = Q.getProperty(I2PClient.PROP_TCP_PORT, "7654");
int i2cpPort = I2PSession.DEFAULT_LISTEN_PORT;
String i2cpPortStr = Q.getProperty(I2PClient.PROP_TCP_PORT);
if (i2cpPortStr != null) {
try {
i2cpPort = Integer.parseInt(i2cpPortStr);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Invalid I2CP port specified [" + i2cpPortStr + "]");
}
}
if (this.come_in) {
this.listener = new ServerSocket(port, backlog, host);

View File

@ -99,7 +99,7 @@ public class I2PSnarkUtil {
_baseName = baseName;
_opts = new HashMap<String, String>();
//setProxy("127.0.0.1", 4444);
setI2CPConfig("127.0.0.1", 7654, null);
setI2CPConfig("127.0.0.1", I2PSession.DEFAULT_LISTEN_PORT, null);
_banlist = new ConcurrentHashSet<Hash>();
_maxUploaders = Snark.MAX_TOTAL_UPLOADERS;
_maxUpBW = SnarkManager.DEFAULT_MAX_UP_BW;

View File

@ -28,6 +28,7 @@ import net.i2p.I2PAppContext;
import net.i2p.app.ClientApp;
import net.i2p.app.ClientAppManager;
import net.i2p.app.ClientAppState;
import net.i2p.client.I2PSession;
import net.i2p.crypto.SHA1Hash;
import net.i2p.crypto.SigType;
import net.i2p.data.Base64;
@ -785,7 +786,7 @@ public class SnarkManager implements CompleteListener, ClientApp {
if (!_config.containsKey(PROP_I2CP_HOST))
_config.setProperty(PROP_I2CP_HOST, "127.0.0.1");
if (!_config.containsKey(PROP_I2CP_PORT))
_config.setProperty(PROP_I2CP_PORT, "7654");
_config.setProperty(PROP_I2CP_PORT, Integer.toString(I2PSession.DEFAULT_LISTEN_PORT));
if (!_config.containsKey(PROP_I2CP_OPTS))
_config.setProperty(PROP_I2CP_OPTS, "inbound.length=3 outbound.length=3" +
" inbound.quantity=" + DEFAULT_TUNNEL_QUANTITY +
@ -911,7 +912,7 @@ public class SnarkManager implements CompleteListener, ClientApp {
private void updateConfig() {
String i2cpHost = _config.getProperty(PROP_I2CP_HOST);
int i2cpPort = getInt(PROP_I2CP_PORT, 7654);
int i2cpPort = getInt(PROP_I2CP_PORT, I2PSession.DEFAULT_LISTEN_PORT);
String opts = _config.getProperty(PROP_I2CP_OPTS);
Map<String, String> i2cpOpts = new HashMap<String, String>();
if (opts != null) {

View File

@ -97,7 +97,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
public boolean ownDest = false;
/** the I2CP port, non-null */
public String port = System.getProperty(I2PClient.PROP_TCP_PORT, "7654");
public String port = System.getProperty(I2PClient.PROP_TCP_PORT, Integer.toString(I2PSession.DEFAULT_LISTEN_PORT));
/** the I2CP host, non-null */
public String host = System.getProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1");
/** the listen-on host. Sadly the listen-on port does not have a field. */

View File

@ -409,7 +409,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
Log _log = tunnel.getContext().logManager().getLog(I2PTunnelClientBase.class);
Properties props = new Properties();
props.putAll(tunnel.getClientOptions());
int portNum = 7654;
int portNum = I2PSession.DEFAULT_LISTEN_PORT;
if (tunnel.port != null) {
try {
portNum = Integer.parseInt(tunnel.port);
@ -471,7 +471,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
// try to make this error sensible as it will happen...
String portNum = getTunnel().port;
if (portNum == null)
portNum = "7654";
portNum = Integer.toString(I2PSession.DEFAULT_LISTEN_PORT);
String msg;
if (getTunnel().getContext().isRouterContext())
msg = "Unable to build tunnels for the client";

View File

@ -210,7 +210,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
private I2PSocketManager createManager(InputStream privData) {
Properties props = new Properties();
props.putAll(getTunnel().getClientOptions());
int portNum = 7654;
int portNum = I2PSession.DEFAULT_LISTEN_PORT;
if (getTunnel().port != null) {
try {
portNum = Integer.parseInt(getTunnel().port);
@ -305,7 +305,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
// try to make this error sensible as it will happen...
String portNum = getTunnel().port;
if (portNum == null)
portNum = "7654";
portNum = Integer.toString(I2PSession.DEFAULT_LISTEN_PORT);
String msg;
if (getTunnel().getContext().isRouterContext())
msg = "Unable to build tunnels for the server at " + remoteHost.getHostAddress() + ':' + remotePort;

View File

@ -733,10 +733,10 @@ public class TunnelController implements Logging {
int portNum = Integer.parseInt(port);
_tunnel.port = String.valueOf(portNum);
} catch (NumberFormatException nfe) {
_tunnel.port = "7654";
_tunnel.port = Integer.toString(I2PSession.DEFAULT_LISTEN_PORT);
}
} else {
_tunnel.port = "7654";
_tunnel.port = Integer.toString(I2PSession.DEFAULT_LISTEN_PORT);
}
}

View File

@ -11,6 +11,7 @@ import java.util.concurrent.ConcurrentHashMap;
import net.i2p.I2PAppContext;
import net.i2p.client.I2PClient;
import net.i2p.client.I2PSession;
import net.i2p.crypto.KeyGenerator;
import net.i2p.crypto.SigType;
import net.i2p.data.Base64;
@ -836,7 +837,7 @@ public class TunnelConfig {
if ( (_i2cpPort != null) && (_i2cpPort.trim().length() > 0) ) {
config.setProperty(TunnelController.PROP_I2CP_PORT, _i2cpPort);
} else {
config.setProperty(TunnelController.PROP_I2CP_PORT, "7654");
config.setProperty(TunnelController.PROP_I2CP_PORT, Integer.toString(I2PSession.DEFAULT_LISTEN_PORT));
}
}
if (_privKeyFile != null)

View File

@ -14,6 +14,7 @@ import java.util.List;
import java.util.Set;
import net.i2p.I2PException;
import net.i2p.client.I2PSession;
import net.i2p.crypto.SigType;
import net.i2p.data.Base64;
import net.i2p.data.DataHelper;
@ -446,7 +447,7 @@ public class EditBean extends IndexBean {
if (tun != null)
return tun.getI2CPPort();
else
return "7654";
return Integer.toString(I2PSession.DEFAULT_LISTEN_PORT);
}
public String getCustomOptions(int tunnel) {

View File

@ -275,7 +275,7 @@ public class I2PSocketManagerFactory {
}
private static int getPort() {
int i2cpPort = 7654;
int i2cpPort = I2PSession.DEFAULT_LISTEN_PORT;
String i2cpPortStr = System.getProperty(I2PClient.PROP_TCP_PORT);
if (i2cpPortStr != null) {
try {

View File

@ -146,12 +146,14 @@ class SAMStreamSession implements SAMMessageSess {
allprops.putAll(props);
String i2cpHost = allprops.getProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1");
int i2cpPort = 7654;
String port = allprops.getProperty(I2PClient.PROP_TCP_PORT, "7654");
int i2cpPort = I2PSession.DEFAULT_LISTEN_PORT;
String sport = allprops.getProperty(I2PClient.PROP_TCP_PORT);
if (sport != null) {
try {
i2cpPort = Integer.parseInt(port);
i2cpPort = Integer.parseInt(sport);
} catch (NumberFormatException nfe) {
throw new SAMException("Invalid I2CP port specified [" + port + "]");
throw new SAMException("Invalid I2CP port specified [" + sport + "]");
}
}
if (!canReceive)
allprops.setProperty("i2cp.dontPublishLeaseSet", "true");

View File

@ -444,4 +444,10 @@ public interface I2PSession {
* @since 0.9.2
*/
public static final int PROTO_DATAGRAM_RAW = 18;
/**
* 7654
* @since 0.9.38
*/
public static final int DEFAULT_LISTEN_PORT = 7654;
}

View File

@ -224,7 +224,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
}
}
public static final int LISTEN_PORT = 7654;
public static final int LISTEN_PORT = DEFAULT_LISTEN_PORT;
private static final int BUF_SIZE = 32*1024;

View File

@ -13,6 +13,7 @@ import java.io.Writer;
import java.util.Collections;
import java.util.Set;
import net.i2p.client.I2PSession;
import net.i2p.client.I2PSessionException;
import net.i2p.crypto.SessionKeyManager;
import net.i2p.data.DataHelper;
@ -40,7 +41,7 @@ public class ClientManagerFacadeImpl extends ClientManagerFacade implements Inte
private final RouterContext _context;
/** note that this is different than the property the client side uses, i2cp.tcp.port */
public final static String PROP_CLIENT_PORT = "i2cp.port";
public final static int DEFAULT_PORT = 7654;
public final static int DEFAULT_PORT = I2PSession.DEFAULT_LISTEN_PORT;
/** note that this is different than the property the client side uses, i2cp.tcp.host */
public final static String PROP_CLIENT_HOST = "i2cp.hostname";
public final static String DEFAULT_HOST = "127.0.0.1";