- Timestamp:
- Apr 8, 2019 4:12:14 PM (22 months ago)
- Branches:
- master
- Children:
- cde5353
- Parents:
- 488e89a
- Location:
- router/java
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
router/java/src/net/i2p/router/message/GarlicConfig.java
r488e89a r5490de1 28 28 private RouterInfo _recipient; 29 29 private PublicKey _recipientPublicKey; 30 private Certificate _cert;31 private long _id;32 private long _expiration;30 private final Certificate _cert; 31 private final long _id; 32 private final long _expiration; 33 33 private final List<GarlicConfig> _cloveConfigs; 34 private DeliveryInstructions _instructions;34 private final DeliveryInstructions _instructions; 35 35 // unused 36 36 //private boolean _requestAck; … … 42 42 //private long _replyBlockExpiration; 43 43 44 public GarlicConfig( ) {45 this(new ArrayList<GarlicConfig>(4) );44 public GarlicConfig(Certificate cert, long id, long expiration, DeliveryInstructions di) { 45 this(new ArrayList<GarlicConfig>(4), cert, id, expiration, di); 46 46 } 47 47 48 protected GarlicConfig(List<GarlicConfig> cloveConfigs) { 49 _id = -1; 50 _expiration = -1; 48 protected GarlicConfig(List<GarlicConfig> cloveConfigs, Certificate cert, long id, 49 long expiration, DeliveryInstructions di) { 50 _cert = cert; 51 _id = id; 52 _expiration = expiration; 51 53 _cloveConfigs = cloveConfigs; 54 _instructions = di; 52 55 //_replyBlockMessageId = -1; 53 56 //_replyBlockExpiration = -1; … … 80 83 * 81 84 */ 82 public void setCertificate(Certificate cert) { _cert = cert; }83 85 public Certificate getCertificate() { return _cert; } 84 86 … … 87 89 * 88 90 */ 89 public void setId(long id) { _id = id; }90 91 public long getId() { return _id; } 91 92 … … 94 95 * 95 96 */ 96 public void setExpiration(long expiration) { _expiration = expiration; }97 97 public long getExpiration() { return _expiration; } 98 98 … … 101 101 * 102 102 */ 103 public void setDeliveryInstructions(DeliveryInstructions instructions) { _instructions = instructions; }104 103 public DeliveryInstructions getDeliveryInstructions() { return _instructions; } 105 104 -
router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java
r488e89a r5490de1 147 147 if (replyToken >= 0 && log.shouldLog(Log.DEBUG)) 148 148 log.debug("Reply token: " + replyToken); 149 GarlicConfig config = new GarlicConfig(); 149 GarlicConfig config = new GarlicConfig(Certificate.NULL_CERT, 150 ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE), 151 expiration, DeliveryInstructions.LOCAL); 150 152 151 153 if (requireAck) { … … 168 170 config.addClove(dataClove); 169 171 170 config.setCertificate(Certificate.NULL_CERT);171 config.setDeliveryInstructions(DeliveryInstructions.LOCAL);172 config.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));173 config.setExpiration(expiration); // +2*Router.CLOCK_FUDGE_FACTOR);174 172 config.setRecipientPublicKey(recipientPK); 175 173 … … 214 212 //ackInstructions.setEncrypted(false); 215 213 216 PayloadGarlicConfig ackClove = new PayloadGarlicConfig();217 ackClove.setCertificate(Certificate.NULL_CERT);218 ackClove.setDeliveryInstructions(ackInstructions);219 ackClove.setExpiration(expiration);220 ackClove.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));221 214 DeliveryStatusMessage dsm = buildDSM(ctx, replyToken); 222 215 GarlicMessage msg = wrapDSM(ctx, skm, dsm); … … 226 219 return null; 227 220 } 228 ackClove.setPayload(msg); 221 PayloadGarlicConfig ackClove = new PayloadGarlicConfig(Certificate.NULL_CERT, 222 ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE), 223 expiration, ackInstructions, msg); 229 224 // this does nothing, the clove is not separately encrypted 230 225 //ackClove.setRecipient(ctx.router().getRouterInfo()); … … 284 279 //instructions.setEncrypted(false); 285 280 286 PayloadGarlicConfig clove = new PayloadGarlicConfig();287 clove.setCertificate(Certificate.NULL_CERT);288 clove.setDeliveryInstructions(instructions);289 clove.setExpiration(expiration);290 clove.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));291 281 DataMessage msg = new DataMessage(ctx); 292 282 msg.setData(data.getEncryptedData()); 293 clove.setPayload(msg); 283 PayloadGarlicConfig clove = new PayloadGarlicConfig(Certificate.NULL_CERT, 284 ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE), 285 expiration, instructions, msg); 294 286 // defaults 295 287 //clove.setRecipientPublicKey(null); … … 304 296 */ 305 297 private static PayloadGarlicConfig buildLeaseSetClove(RouterContext ctx, long expiration, LeaseSet replyLeaseSet) { 306 PayloadGarlicConfig clove = new PayloadGarlicConfig();307 clove.setCertificate(Certificate.NULL_CERT);308 clove.setDeliveryInstructions(DeliveryInstructions.LOCAL);309 clove.setExpiration(expiration);310 clove.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));311 298 DatabaseStoreMessage msg = new DatabaseStoreMessage(ctx); 312 299 msg.setEntry(replyLeaseSet); 313 300 msg.setMessageExpiration(expiration); 314 clove.setPayload(msg); 301 PayloadGarlicConfig clove = new PayloadGarlicConfig(Certificate.NULL_CERT, 302 ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE), 303 expiration, DeliveryInstructions.LOCAL, msg); 315 304 // defaults 316 305 //clove.setRecipientPublicKey(null); -
router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java
r488e89a r5490de1 904 904 */ 905 905 private PayloadGarlicConfig buildClove() { 906 PayloadGarlicConfig clove = new PayloadGarlicConfig();907 908 906 DeliveryInstructions instructions = new DeliveryInstructions(); 909 907 instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_DESTINATION); … … 914 912 //instructions.setDelaySeconds(0); 915 913 //instructions.setEncrypted(false); 916 917 clove.setCertificate(Certificate.NULL_CERT);918 clove.setDeliveryInstructions(instructions);919 clove.setExpiration(OVERALL_TIMEOUT_MS_DEFAULT+getContext().clock().now());920 clove.setId(getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE));921 914 922 915 DataMessage msg = new DataMessage(getContext()); … … 928 921 return null; 929 922 msg.setData(d); 930 msg.setMessageExpiration(clove.getExpiration()); 931 932 clove.setPayload(msg); 923 long expires = OVERALL_TIMEOUT_MS_DEFAULT + getContext().clock().now(); 924 msg.setMessageExpiration(expires); 925 PayloadGarlicConfig clove = new PayloadGarlicConfig(Certificate.NULL_CERT, 926 getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE), 927 expires, 928 instructions, msg); 929 933 930 // defaults 934 931 //clove.setRecipientPublicKey(null); -
router/java/src/net/i2p/router/message/PayloadGarlicConfig.java
r488e89a r5490de1 9 9 */ 10 10 11 import net.i2p.data.Certificate; 12 import net.i2p.data.i2np.DeliveryInstructions; 11 13 import net.i2p.data.i2np.I2NPMessage; 12 14 … … 18 20 */ 19 21 public class PayloadGarlicConfig extends GarlicConfig { 20 private I2NPMessage _payload;22 private final I2NPMessage _payload; 21 23 22 public PayloadGarlicConfig() { 23 super(null); 24 public PayloadGarlicConfig(Certificate cert, long id, long expiration, 25 DeliveryInstructions di, I2NPMessage message) { 26 super(null, cert, id, expiration, di); 27 _payload = message; 24 28 } 25 29 … … 28 32 * in this block 29 33 */ 30 public void setPayload(I2NPMessage message) {31 _payload = message;32 }33 34 34 public I2NPMessage getPayload() { return _payload; } 35 35 -
router/java/src/net/i2p/router/networkdb/kademlia/MessageWrapper.java
r488e89a r5490de1 44 44 */ 45 45 static WrappedMessage wrap(RouterContext ctx, I2NPMessage m, Hash from, RouterInfo to) { 46 PayloadGarlicConfig payload = new PayloadGarlicConfig( );47 payload.setCertificate(Certificate.NULL_CERT);48 payload.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));49 payload.setPayload(m);46 PayloadGarlicConfig payload = new PayloadGarlicConfig(Certificate.NULL_CERT, 47 ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE), 48 m.getMessageExpiration(), 49 DeliveryInstructions.LOCAL, m); 50 50 payload.setRecipient(to); 51 payload.setDeliveryInstructions(DeliveryInstructions.LOCAL);52 payload.setExpiration(m.getMessageExpiration());53 51 54 52 SessionKeyManager skm; … … 125 123 */ 126 124 static GarlicMessage wrap(RouterContext ctx, I2NPMessage m, RouterInfo to) { 127 PayloadGarlicConfig payload = new PayloadGarlicConfig( );128 payload.setCertificate(Certificate.NULL_CERT);129 payload.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));130 payload.setPayload(m);125 PayloadGarlicConfig payload = new PayloadGarlicConfig(Certificate.NULL_CERT, 126 ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE), 127 m.getMessageExpiration(), 128 DeliveryInstructions.LOCAL, m); 131 129 payload.setRecipient(to); 132 payload.setDeliveryInstructions(DeliveryInstructions.LOCAL);133 payload.setExpiration(m.getMessageExpiration());134 130 135 131 SessionKey sentKey = ctx.keyGenerator().generateSessionKey(); … … 225 221 */ 226 222 public static GarlicMessage wrap(RouterContext ctx, I2NPMessage m, SessionKey encryptKey, SessionTag encryptTag) { 227 PayloadGarlicConfig payload = new PayloadGarlicConfig(); 228 payload.setCertificate(Certificate.NULL_CERT); 229 payload.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE)); 230 payload.setPayload(m); 231 payload.setDeliveryInstructions(DeliveryInstructions.LOCAL); 232 payload.setExpiration(m.getMessageExpiration()); 223 PayloadGarlicConfig payload = new PayloadGarlicConfig(Certificate.NULL_CERT, 224 ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE), 225 m.getMessageExpiration(), 226 DeliveryInstructions.LOCAL, m); 233 227 234 228 GarlicMessage msg = GarlicMessageBuilder.buildMessage(ctx, payload, null, null, -
router/java/src/net/i2p/router/tunnel/pool/TestJob.java
r488e89a r5490de1 116 116 // remembering that key+tag so that we can decrypt it later. this means we can do the 117 117 // garlic encryption without any ElGamal (yay) 118 PayloadGarlicConfig payload = new PayloadGarlicConfig( );119 payload.setCertificate(Certificate.NULL_CERT);120 payload.setId(getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE));121 payload.setPayload(m);118 PayloadGarlicConfig payload = new PayloadGarlicConfig(Certificate.NULL_CERT, 119 getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE), 120 m.getMessageExpiration(), 121 DeliveryInstructions.LOCAL, m); 122 122 payload.setRecipient(getContext().router().getRouterInfo()); 123 payload.setDeliveryInstructions(DeliveryInstructions.LOCAL);124 payload.setExpiration(m.getMessageExpiration());125 123 126 124 SessionKey encryptKey = getContext().keyGenerator().generateSessionKey(); -
router/java/test/junit/net/i2p/router/message/BuildTestMessageJob.java
r488e89a r5490de1 104 104 if (_log.shouldLog(Log.INFO)) 105 105 _log.info("Test message key: " + _testMessageKey); 106 GarlicConfig config = new GarlicConfig(); 107 108 PayloadGarlicConfig ackClove = buildAckClove(); 109 config.addClove(ackClove); 110 106 111 107 DeliveryInstructions instructions = new DeliveryInstructions(); 112 108 instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_ROUTER); … … 114 110 instructions.setTunnelId(null); 115 111 116 config.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null)); 117 config.setDeliveryInstructions(instructions); 118 config.setId(getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE)); 119 config.setExpiration(_timeoutMs+getContext().clock().now()+2*Router.CLOCK_FUDGE_FACTOR); 112 GarlicConfig config = new GarlicConfig(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null), 113 getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE), 114 _timeoutMs+getContext().clock().now()+2*Router.CLOCK_FUDGE_FACTOR, 115 instructions); 116 117 PayloadGarlicConfig ackClove = buildAckClove(); 118 config.addClove(ackClove); 119 120 120 config.setRecipient(_target); 121 121 … … 127 127 */ 128 128 private PayloadGarlicConfig buildAckClove() { 129 PayloadGarlicConfig ackClove = new PayloadGarlicConfig();130 129 131 130 DeliveryInstructions ackInstructions = new DeliveryInstructions(); … … 139 138 _log.debug("Delivery status message key: " + _testMessageKey + " arrival: " + msg.getArrival()); 140 139 141 ackClove.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));142 ackClove.setDeliveryInstructions(ackInstructions);143 ackClove.setExpiration(_timeoutMs+getContext().clock().now());144 ackClove.setId(getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE));145 ackClove.setPayload(msg);140 PayloadGarlicConfig ackClove = new PayloadGarlicConfig(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null), 141 getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE), 142 _timeoutMs+getContext().clock().now(), 143 ackInstructions, 144 msg); 146 145 ackClove.setRecipient(_target); 147 146
Note: See TracChangeset
for help on using the changeset viewer.