SSU2: Minor updates

send timeout code in termination
remove unused intro key block handling
log tweaks
This commit is contained in:
zzz
2022-04-12 09:23:48 -04:00
parent 806046df64
commit 3edc235104
7 changed files with 7 additions and 21 deletions
@@ -1961,7 +1961,7 @@ class EstablishmentManager {
try {
doPass();
} catch (RuntimeException re) {
_log.log(Log.CRIT, "Error in the establisher", re);
_log.error("Error in the establisher", re);
// don't loop too fast
try { Thread.sleep(1000); } catch (InterruptedException ie) {}
}
@@ -237,7 +237,7 @@ class InboundEstablishState2 extends InboundEstablishState implements SSU2Payloa
}
if (ra == null)
throw new DataFormatException("no SSU2 addr");
throw new DataFormatException("no SSU2 addr, ipv6? " + isIPv6 + ": " + ri);
String siv = ra.getOption("i");
if (siv == null)
throw new DataFormatException("no SSU2 IKey");
@@ -324,11 +324,6 @@ class InboundEstablishState2 extends InboundEstablishState implements SSU2Payloa
//_bobPort = port;
}
public void gotIntroKey(byte[] key) {
if (_log.shouldDebug())
_log.debug("Got Intro key: " + Base64.encode(key));
}
public void gotRelayTagRequest() {
if (!ENABLE_RELAY)
return;
@@ -572,7 +567,7 @@ class InboundEstablishState2 extends InboundEstablishState implements SSU2Payloa
}
}
if (_log.shouldWarn())
_log.warn("Got sess conf frag " + frag + " len " + len + " on " + this);
_log.warn("Got sess conf frag " + frag + '/' + totalfrag + " len " + len + " on " + this);
byte[] fragdata;
if (frag == 0) {
// preserve header
@@ -214,11 +214,6 @@ class OutboundEstablishState2 extends OutboundEstablishState implements SSU2Payl
_alicePort = port;
}
public void gotIntroKey(byte[] key) {
if (_log.shouldDebug())
_log.debug("Got Intro key: " + Base64.encode(key));
}
public void gotRelayTagRequest() {
throw new IllegalStateException("Relay tag req in Sess Created");
}
@@ -483,6 +483,8 @@ class PacketBuilder2 {
int len;
if (numFragments > 1) {
if (numFragments > 15)
throw new IllegalArgumentException();
if (_log.shouldWarn())
_log.warn("RI size " + info.length + " requires " + numFragments + " packets");
len = max;
@@ -381,9 +381,6 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback
public void gotAddress(byte[] ip, int port) {
}
public void gotIntroKey(byte[] key) {
}
public void gotRelayTagRequest() {
if (!ENABLE_RELAY)
return;
@@ -39,12 +39,12 @@ class SSU2Payload {
private static final int BLOCK_NEXTNONCE = 11;
private static final int BLOCK_ACK = 12;
private static final int BLOCK_ADDRESS = 13;
private static final int BLOCK_INTROKEY= 14;
private static final int BLOCK_RELAYTAGREQ = 15;
private static final int BLOCK_RELAYTAG = 16;
private static final int BLOCK_NEWTOKEN = 17;
private static final int BLOCK_PATHCHALLENGE = 18;
private static final int BLOCK_PATHRESP = 19;
private static final int BLOCK_CONGESTION = 21;
private static final int BLOCK_PADDING = 254;
/**
@@ -90,8 +90,6 @@ class SSU2Payload {
public void gotAddress(byte[] ip, int port);
public void gotIntroKey(byte[] key);
public void gotRelayTagRequest();
public void gotRelayTag(long tag);
@@ -2140,8 +2140,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
return;
pkt = _packetBuilder.buildSessionDestroyPacket(peer);
} else {
// unspecified reason
pkt = _packetBuilder2.buildSessionDestroyPacket(0, (PeerState2) peer);
pkt = _packetBuilder2.buildSessionDestroyPacket(SSU2Util.REASON_TIMEOUT, (PeerState2) peer);
}
if (_log.shouldLog(Log.DEBUG))
_log.debug("Sending destroy to : " + peer);