Changeset 636016d1
- Timestamp:
- Feb 7, 2019 2:54:56 PM (2 years ago)
- Branches:
- master
- Children:
- 7544d0a
- Parents:
- b310c60
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
history.txt
rb310c60 r636016d1 1 2019-02-07 zzz 2 * NTCP: 3 - Add option to disable NTCP1 (ticket #2328) 4 - Don't bid for outbound-only NTCP2 addresses 5 - Fix NTCP2 cost when transitioning to inbound 6 7 2019-02-06 zzz 8 * Build: Add targets for alternate debian distros (ticket #2410) 9 * Crypto: Shortcut GroupElement representation conversion 10 * I2CP: Prevent use of repliable datagrams with offline keys 11 12 2019-02-05 zzz 13 * Transport: 14 - Clean up unreachable() methods (ticket #2382) 15 - Speed up NTCP allowConnection() (ticket #2381) 16 - OutNetMessage cleanup (ticket #2386) 17 - SSU PacketHandler cleanup (ticket #2383) 18 19 2019-02-04 zzz 20 * I2CP: Change format and message type of CreateLeaseSet2 message 21 1 22 2019-02-03 zzz 2 23 * I2CP: -
router/java/src/net/i2p/router/RouterVersion.java
rb310c60 r636016d1 19 19 public final static String ID = "Monotone"; 20 20 public final static String VERSION = CoreVersion.VERSION; 21 public final static long BUILD = 6;21 public final static long BUILD = 7; 22 22 23 23 /** for example "-test" */ -
router/java/src/net/i2p/router/transport/TransportManager.java
rb310c60 r636016d1 71 71 private final DHSessionKeyBuilder.PrecalcRunner _dhThread; 72 72 private final X25519KeyFactory _xdhThread; 73 private final boolean _enableUDP; 74 private final boolean _enableNTCP1; 73 75 74 76 /** default true */ … … 79 81 public final static String PROP_ENABLE_UPNP = "i2np.upnp.enable"; 80 82 83 /** default true */ 84 private static final String PROP_NTCP1_ENABLE = "i2np.ntcp1.enable"; 85 private static final boolean DEFAULT_NTCP1_ENABLE = true; 81 86 private static final String PROP_NTCP2_ENABLE = "i2np.ntcp2.enable"; 82 87 private static final boolean DEFAULT_NTCP2_ENABLE = true; … … 103 108 else 104 109 _upnpManager = null; 105 _dhThread = new DHSessionKeyBuilder.PrecalcRunner(context); 110 _enableUDP = _context.getBooleanPropertyDefaultTrue(PROP_ENABLE_UDP); 111 _enableNTCP1 = isNTCPEnabled(context) && 112 context.getProperty(PROP_NTCP1_ENABLE, DEFAULT_NTCP1_ENABLE); 106 113 boolean enableNTCP2 = isNTCPEnabled(context) && 107 114 context.getProperty(PROP_NTCP2_ENABLE, DEFAULT_NTCP2_ENABLE); 115 _dhThread = (_enableUDP || enableNTCP2) ? new DHSessionKeyBuilder.PrecalcRunner(context) : null; 108 116 _xdhThread = enableNTCP2 ? new X25519KeyFactory(context) : null; 109 117 } … … 150 158 * Hook for pluggable transport creation. 151 159 * 160 * @return null if both NTCP1 and SSU are disabled 152 161 * @since 0.9.16 153 162 */ … … 173 182 174 183 private void configTransports() { 175 boolean enableUDP = _context.getBooleanPropertyDefaultTrue(PROP_ENABLE_UDP);176 184 Transport udp = null; 177 if ( enableUDP) {185 if (_enableUDP) { 178 186 udp = new UDPTransport(_context, _dhThread); 179 187 addTransport(udp); … … 181 189 } 182 190 if (isNTCPEnabled(_context)) { 183 Transport ntcp = new NTCPTransport(_context, _dhThread, _xdhThread); 191 DHSessionKeyBuilder.PrecalcRunner dh = _enableNTCP1 ? _dhThread : null; 192 Transport ntcp = new NTCPTransport(_context, dh, _xdhThread); 184 193 addTransport(ntcp); 185 194 initializeAddress(ntcp); … … 316 325 317 326 synchronized void startListening() { 318 if (_dhThread .getState() == Thread.State.NEW)327 if (_dhThread != null && _dhThread.getState() == Thread.State.NEW) 319 328 _dhThread.start(); 320 329 if (_xdhThread != null && _xdhThread.getState() == Thread.State.NEW) … … 378 387 synchronized void shutdown() { 379 388 stopListening(); 380 _dhThread.shutdown(); 389 if (_dhThread != null) 390 _dhThread.shutdown(); 381 391 if (_xdhThread != null) 382 392 _xdhThread.shutdown(); -
router/java/src/net/i2p/router/transport/ntcp/EstablishBase.java
rb310c60 r636016d1 192 192 _transport = transport; 193 193 _con = con; 194 // null if NTCP1 disabled 194 195 _dh = _transport.getDHBuilder(); 195 196 _hX_xor_bobIdentHash = SimpleByteCache.acquire(HXY_SIZE); 196 197 if (_con.isInbound()) { 197 198 _X = SimpleByteCache.acquire(XY_SIZE); 198 _Y = _dh.getMyPublicValueBytes();199 _Y = (_dh != null) ?_dh.getMyPublicValueBytes() : null; 199 200 } else { 201 // OutboundNTCP2State does not extend this, 202 // can't get here with NTCP1 disabled 203 if (_dh == null) 204 throw new IllegalStateException(); 200 205 _X = _dh.getMyPublicValueBytes(); 201 206 _Y = SimpleByteCache.acquire(XY_SIZE); … … 305 310 SimpleByteCache.release(_curDecrypted); 306 311 SimpleByteCache.release(_hX_xor_bobIdentHash); 307 if (_dh .getPeerPublicValue() == null)312 if (_dh != null && _dh.getPeerPublicValue() == null) 308 313 _transport.returnUnused(_dh); 309 314 } -
router/java/src/net/i2p/router/transport/ntcp/InboundEstablishState.java
rb310c60 r636016d1 124 124 if (!_transport.isNTCP2Enabled()) 125 125 return 1; 126 if (!_transport.isNTCP1Enabled()) 127 return 2; 126 128 synchronized (_stateLock) { 127 129 if (_state == State.IB_INIT) … … 161 163 return; 162 164 } 163 if (remaining + _received < NTCP1_MSG1_SIZE) { 165 if (remaining + _received < NTCP1_MSG1_SIZE || 166 !_transport.isNTCP1Enabled()) { 164 167 // Less than 288 total received, assume NTCP2 165 168 // TODO can't change our mind later if we get more than 287 … … 744 747 return; 745 748 } 749 // TODO if NTCP1 disabled, we should allow longer padding 746 750 if (_padlen1 > PADDING1_MAX) { 747 751 fail("bad msg 1 padlen: " + _padlen1); -
router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java
rb310c60 r636016d1 138 138 private static final int NTCP2_KEY_LEN = OutboundNTCP2State.KEY_SIZE; 139 139 private static final long MIN_DOWNTIME_TO_REKEY = 30*24*60*60*1000L; 140 private final boolean _enableNTCP1; 140 141 private final boolean _enableNTCP2; 141 142 private final byte[] _ntcp2StaticPubkey; … … 146 147 147 148 /** 149 * @param dh null to disable NTCP1 148 150 * @param xdh null to disable NTCP2 149 151 */ … … 239 241 _transientFail = new SharedBid(TransportBid.TRANSIENT_FAIL); 240 242 243 _enableNTCP1 = dh != null; 241 244 _enableNTCP2 = xdh != null; 245 if (!_enableNTCP1 && !_enableNTCP2) 246 throw new IllegalArgumentException(); 242 247 if (_enableNTCP2) { 243 248 boolean shouldSave = false; … … 578 583 for (int i = 0; i < addrs.size(); i++) { 579 584 RouterAddress addr = addrs.get(i); 585 // use this to skip outbound-only NTCP2, 586 // and NTCP1 if disabled 587 if (getNTCPVersion(addr) == 0) 588 continue; 580 589 byte[] ip = addr.getIP(); 581 590 if (!TransportUtil.isValidPort(addr.getPort()) || ip == null) { … … 841 850 addNTCP2Options(props); 842 851 int cost = getDefaultCost(ia instanceof Inet6Address); 843 myAddress = new RouterAddress( STYLE, props, cost);852 myAddress = new RouterAddress(getPublishStyle(), props, cost); 844 853 replaceAddress(myAddress); 845 854 } … … 970 979 addNTCP2Options(props); 971 980 int cost = getDefaultCost(false); 972 myAddress = new RouterAddress( STYLE, props, cost);981 myAddress = new RouterAddress(getPublishStyle(), props, cost); 973 982 } 974 983 if (!_endpoints.isEmpty()) { … … 1053 1062 net.i2p.router.transport.ntcp.Writer getWriter() { return _writer; } 1054 1063 1064 /** 1065 * @return always "NTCP" even if NTCP1 is disabled 1066 */ 1055 1067 public String getStyle() { return STYLE; } 1056 1068 … … 1066 1078 1067 1079 /** 1080 * @return "NTCP" if NTCP1 is enabled, else "NTCP2" 1081 * @since 0.9.39 1082 */ 1083 private String getPublishStyle() { 1084 return _enableNTCP1 ? STYLE : STYLE2; 1085 } 1086 1087 /** 1068 1088 * Hook for NTCPConnection 1069 1089 */ … … 1071 1091 1072 1092 /** 1093 * @return null if not configured for NTCP1 1073 1094 * @since 0.9 1074 1095 */ 1075 1096 DHSessionKeyBuilder getDHBuilder() { 1076 return _dhFactory .getBuilder();1097 return _dhFactory != null ? _dhFactory.getBuilder() : null; 1077 1098 } 1078 1099 … … 1093 1114 */ 1094 1115 void returnUnused(DHSessionKeyBuilder builder) { 1095 _dhFactory.returnUnused(builder); 1116 if (_dhFactory != null) 1117 _dhFactory.returnUnused(builder); 1096 1118 } 1097 1119 … … 1186 1208 addNTCP2Options(props); 1187 1209 int cost = getDefaultCost(false); 1188 RouterAddress addr = new RouterAddress( STYLE, props, cost);1210 RouterAddress addr = new RouterAddress(getPublishStyle(), props, cost); 1189 1211 return addr; 1190 1212 } … … 1205 1227 props.setProperty("v", NTCP2_VERSION); 1206 1228 } 1229 1230 /** 1231 * Is NTCP1 enabled? 1232 * 1233 * @since 0.9.39 1234 */ 1235 boolean isNTCP1Enabled() { return _enableNTCP1; } 1207 1236 1208 1237 /** … … 1268 1297 addr.getOption("s") == null || 1269 1298 (!v.equals(NTCP2_VERSION) && !v.startsWith(NTCP2_VERSION_ALT))) { 1270 return (rv == 1) ? 1 : 0; 1271 } 1272 // todo validate s/i b64, or just catch it later? 1299 // his address is NTCP1 or is outbound NTCP2 only 1300 return (rv == 1 && _enableNTCP1) ? 1 : 0; 1301 } 1302 // his address is NTCP2 1303 // do not validate the s/i b64, we will just catch it later 1273 1304 return NTCP2_INT_VERSION; 1274 1305 } … … 1462 1493 newProps.putAll(oldAddr.getOptionsMap()); 1463 1494 } 1464 RouterAddress newAddr = new RouterAddress( STYLE, newProps, cost);1495 RouterAddress newAddr = new RouterAddress(getPublishStyle(), newProps, cost); 1465 1496 1466 1497 boolean changed = false; … … 1533 1564 if (ohost == null || ! ohost.equalsIgnoreCase(nhost)) { 1534 1565 newProps.setProperty(RouterAddress.PROP_HOST, nhost); 1566 if (cost == NTCP2_OUTBOUND_COST) 1567 newAddr.setCost(DEFAULT_COST); 1535 1568 changed = true; 1536 1569 } … … 1544 1577 _log.info("old host: " + ohost + " config: " + name + " new: " + name); 1545 1578 newProps.setProperty(RouterAddress.PROP_HOST, name); 1579 if (cost == NTCP2_OUTBOUND_COST) 1580 newAddr.setCost(DEFAULT_COST); 1546 1581 changed = true; 1547 1582 } else if (ohost == null || ohost.length() <= 0) {
Note: See TracChangeset
for help on using the changeset viewer.