forked from I2P_Developers/i2p.i2p
SSU2: Remove ENABLE_xxx feature flags used in early development
This commit is contained in:
@@ -511,7 +511,7 @@ class EstablishmentManager {
|
||||
requestIntroduction,
|
||||
sessionKey, addr, _transport.getDHFactory());
|
||||
} else if (version == 2) {
|
||||
boolean requestIntroduction = SSU2Util.ENABLE_RELAY && !isIndirect &&
|
||||
boolean requestIntroduction = !isIndirect &&
|
||||
_transport.introducersMaybeRequired(TransportUtil.isIPv6(ra));
|
||||
state = new OutboundEstablishState2(_context, _transport, maybeTo, to,
|
||||
toIdentity, requestIntroduction, sessionKey, ra, addr);
|
||||
@@ -788,8 +788,7 @@ class EstablishmentManager {
|
||||
_log.debug("Receive DUP session/token request from: " + state);
|
||||
}
|
||||
// call for both Session and Token request, why not
|
||||
if (SSU2Util.ENABLE_RELAY &&
|
||||
state.isIntroductionRequested() &&
|
||||
if (state.isIntroductionRequested() &&
|
||||
state.getSentRelayTag() == 0 && // only set once
|
||||
state.getSentPort() >= 1024 &&
|
||||
_transport.canIntroduce(state.getSentIP().length == 16)) {
|
||||
|
||||
@@ -389,8 +389,6 @@ class InboundEstablishState2 extends InboundEstablishState implements SSU2Payloa
|
||||
}
|
||||
|
||||
public void gotRelayTagRequest() {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
if (_log.shouldDebug())
|
||||
_log.debug("Got relay tag request");
|
||||
_introductionRequested = true;
|
||||
@@ -401,29 +399,21 @@ class InboundEstablishState2 extends InboundEstablishState implements SSU2Payloa
|
||||
}
|
||||
|
||||
public void gotRelayRequest(byte[] data) {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
if (_receivedConfirmedIdentity == null)
|
||||
throw new IllegalStateException("RI must be first");
|
||||
}
|
||||
|
||||
public void gotRelayResponse(int status, byte[] data) {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
if (_receivedConfirmedIdentity == null)
|
||||
throw new IllegalStateException("RI must be first");
|
||||
}
|
||||
|
||||
public void gotRelayIntro(Hash aliceHash, byte[] data) {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
if (_receivedConfirmedIdentity == null)
|
||||
throw new IllegalStateException("RI must be first");
|
||||
}
|
||||
|
||||
public void gotPeerTest(int msg, int status, Hash h, byte[] data) {
|
||||
if (!ENABLE_PEER_TEST)
|
||||
return;
|
||||
if (_receivedConfirmedIdentity == null)
|
||||
throw new IllegalStateException("RI must be first");
|
||||
_transport.getPeerTestManager().receiveTest(_remoteHostId, _pstate, msg, status, h, data);
|
||||
|
||||
@@ -141,9 +141,6 @@ class IntroductionManager {
|
||||
|
||||
public void add(PeerState peer) {
|
||||
if (peer == null) return;
|
||||
// Skip SSU2 until we have support for relay
|
||||
if (peer.getVersion() != 1 && !SSU2Util.ENABLE_RELAY)
|
||||
return;
|
||||
// let's not use an introducer on a privileged port, sounds like trouble
|
||||
if (!TransportUtil.isValidPort(peer.getRemotePort()))
|
||||
return;
|
||||
@@ -272,7 +269,7 @@ class IntroductionManager {
|
||||
continue;
|
||||
Hash hash = cur.getRemotePeer();
|
||||
// dup check of reused SSU2 introducers
|
||||
if (SSU2Util.ENABLE_RELAY && cur.getVersion() > 1) {
|
||||
if (cur.getVersion() > 1) {
|
||||
String b64 = hash.toBase64();
|
||||
for (Introducer intro : introducers) {
|
||||
if (b64.equals(intro.shash))
|
||||
|
||||
@@ -315,8 +315,6 @@ class OutboundEstablishState2 extends OutboundEstablishState implements SSU2Payl
|
||||
}
|
||||
|
||||
public void gotRelayTag(long tag) {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
if (_log.shouldDebug())
|
||||
_log.debug("Got relay tag " + tag);
|
||||
_receivedRelayTag = tag;
|
||||
|
||||
@@ -1000,13 +1000,11 @@ class PacketHandler {
|
||||
} else if (type == SSU2Util.PEER_TEST_FLAG_BYTE) {
|
||||
if (_log.shouldDebug())
|
||||
_log.debug("Got a Peer Test");
|
||||
if (SSU2Util.ENABLE_PEER_TEST)
|
||||
_testManager.receiveTest(from, packet);
|
||||
_testManager.receiveTest(from, packet);
|
||||
} else if (type == SSU2Util.HOLE_PUNCH_FLAG_BYTE) {
|
||||
if (_log.shouldDebug())
|
||||
_log.debug("Got a Hole Punch");
|
||||
if (SSU2Util.ENABLE_RELAY)
|
||||
_establisher.receiveHolePunch(from, packet);
|
||||
_establisher.receiveHolePunch(from, packet);
|
||||
} else {
|
||||
if (_log.shouldWarn())
|
||||
_log.warn("Got unknown SSU2 message " + header + " from " + from);
|
||||
|
||||
@@ -479,8 +479,7 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback
|
||||
case MIGRATION_STATE_NONE:
|
||||
if (!from.equals(_remoteHostId)) {
|
||||
// QUIC: Must be highest set to protect against reordered packets
|
||||
if (SSU2Util.ENABLE_PATH_CHALLENGE &&
|
||||
from.getIP().length == _remoteHostId.getIP().length &&
|
||||
if (from.getIP().length == _remoteHostId.getIP().length &&
|
||||
n == _receivedMessages.getHighestSet() &&
|
||||
TransportUtil.isValidPort(from.getPort()) &&
|
||||
_transport.isValid(from.getIP())) {
|
||||
@@ -621,8 +620,6 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback
|
||||
}
|
||||
|
||||
public void gotRelayTagRequest() {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
if (_log.shouldInfo())
|
||||
_log.info("Got RELAY TAG REQUEST on " + this);
|
||||
long tag = getWeRelayToThemAs();
|
||||
@@ -643,8 +640,6 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback
|
||||
}
|
||||
|
||||
public void gotRelayTag(long tag) {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
long old = getTheyRelayToUsAs();
|
||||
if (old != 0) {
|
||||
if (_log.shouldWarn())
|
||||
@@ -656,32 +651,24 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback
|
||||
}
|
||||
|
||||
public void gotRelayRequest(byte[] data) {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
_transport.getIntroManager().receiveRelayRequest(this, data);
|
||||
// Relay blocks are ACK-eliciting
|
||||
messagePartiallyReceived();
|
||||
}
|
||||
|
||||
public void gotRelayResponse(int status, byte[] data) {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
_transport.getIntroManager().receiveRelayResponse(this, status, data);
|
||||
// Relay blocks are ACK-eliciting
|
||||
messagePartiallyReceived();
|
||||
}
|
||||
|
||||
public void gotRelayIntro(Hash aliceHash, byte[] data) {
|
||||
if (!ENABLE_RELAY)
|
||||
return;
|
||||
_transport.getIntroManager().receiveRelayIntro(this, aliceHash, data);
|
||||
// Relay blocks are ACK-eliciting
|
||||
messagePartiallyReceived();
|
||||
}
|
||||
|
||||
public void gotPeerTest(int msg, int status, Hash h, byte[] data) {
|
||||
if (!ENABLE_PEER_TEST)
|
||||
return;
|
||||
_transport.getPeerTestManager().receiveTest(_remoteHostId, this, msg, status, h, data);
|
||||
// Peer Test block is ACK-eliciting
|
||||
messagePartiallyReceived();
|
||||
|
||||
@@ -18,11 +18,6 @@ import net.i2p.data.SigningPublicKey;
|
||||
final class SSU2Util {
|
||||
public static final int PROTOCOL_VERSION = 2;
|
||||
|
||||
// features
|
||||
public static final boolean ENABLE_RELAY = true;
|
||||
public static final boolean ENABLE_PEER_TEST = true;
|
||||
public static final boolean ENABLE_PATH_CHALLENGE = true;
|
||||
|
||||
// lengths
|
||||
/** 32 */
|
||||
public static final int KEY_LEN = EncType.ECIES_X25519.getPubkeyLen();
|
||||
|
||||
@@ -146,7 +146,7 @@ class UDPAddress {
|
||||
InetAddress[] cintroAddresses = null;
|
||||
long[] cintroExps = null;
|
||||
Hash[] cintroHashes = null;
|
||||
final boolean ssu2enable = SSU2Util.ENABLE_RELAY && (ssu2only || "2".equals(addr.getOption("v")));
|
||||
final boolean ssu2enable = ssu2only || "2".equals(addr.getOption("v"));
|
||||
for (int i = MAX_INTRODUCERS - 1; i >= 0; i--) {
|
||||
// This is the only one required for SSU 1 and 2
|
||||
String t = addr.getOption(PROP_INTRO_TAG[i]);
|
||||
|
||||
@@ -982,7 +982,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
if (v == null ||
|
||||
addr.getOption("i") == null ||
|
||||
addr.getOption("s") == null ||
|
||||
(!SSU2Util.ENABLE_RELAY && (addr.getHost() == null || addr.getPort() <= 0)) ||
|
||||
(!v.equals(SSU2_VERSION) && !v.startsWith(SSU2_VERSION_ALT))) {
|
||||
// his address is SSU1 or is outbound SSU2 only
|
||||
return (rv == 1 && _enableSSU1) ? 1 : 0;
|
||||
@@ -2522,9 +2521,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
String caps = addr.getOption(UDPAddress.PROP_CAPACITY);
|
||||
if (caps != null && caps.contains(CAP_IPV6) && !_haveIPv6Address)
|
||||
continue;
|
||||
// Skip SSU2 with introducers until we support relay
|
||||
if (_enableSSU2 && !SSU2Util.ENABLE_RELAY && addr.getTransportStyle().equals(STYLE2))
|
||||
continue;
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
@@ -4064,8 +4060,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
PeerState pickTestPeer(PeerTestState.Role peerRole, int version, boolean isIPv6, RemoteHostId dontInclude) {
|
||||
if (peerRole == ALICE)
|
||||
throw new IllegalArgumentException();
|
||||
if (peerRole == CHARLIE && version != 1 && !SSU2Util.ENABLE_PEER_TEST)
|
||||
return null;
|
||||
List<PeerState> peers = new ArrayList<PeerState>(_peersByIdent.values());
|
||||
for (Iterator<PeerState> iter = new RandomIterator<PeerState>(peers); iter.hasNext(); ) {
|
||||
PeerState peer = iter.next();
|
||||
@@ -4073,8 +4067,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
// Skip SSU2 until we have support for peer test
|
||||
version = peer.getVersion();
|
||||
if (version != 1) {
|
||||
if (!SSU2Util.ENABLE_PEER_TEST)
|
||||
continue;
|
||||
// we must know our IP/port
|
||||
PeerState2 bob = (PeerState2) peer;
|
||||
if (bob.getOurIP() == null || bob.getOurPort() <= 0)
|
||||
|
||||
Reference in New Issue
Block a user