Tunnels: Improved logging and handling of offline signature expiration

Store back ref to controller in tunnel
Stop server controller on I2PException
Support generation of keys with fractional days expiration for testing
This commit is contained in:
zzz
2020-10-29 15:20:56 +00:00
parent 8d0b1214d2
commit 190b76d7fd
10 changed files with 93 additions and 23 deletions

View File

@@ -7,6 +7,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import net.i2p.I2PAppContext;
import net.i2p.client.I2PSession;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.SessionKey;
import net.i2p.data.SessionTag;
@@ -235,6 +236,10 @@ class PacketLocal extends Packet implements MessageOutputStream.WriteStatus {
* @since 0.9.20 moved from Packet
*/
public int writeSignedPacket(byte buffer[], int offset) throws IllegalStateException {
if (isFlagSet(FLAG_SIGNATURE_OFFLINE)) {
if (_transientExpires < _context.clock().now())
throw new IllegalStateException("Offline signature expired " + DataHelper.formatTime(_transientExpires));
}
setFlag(FLAG_SIGNATURE_INCLUDED);
SigningPrivateKey key = _session.getPrivateKey();
int size = writePacket(buffer, offset, key.getType().getSigLen());