private TunnelCreatorConfig configOutbound(I2PAppContext ctx) { _peers = new Hash[4]; _pubKeys = new PublicKey[_peers.length]; _privKeys = new PrivateKey[_peers.length]; for (int i = 0; i < _peers.length; i++) { byte buf[] = new byte[Hash.HASH_LENGTH]; Arrays.fill(buf, (byte) i); // consistent for repeatability Hash h = new Hash(buf); _peers[i] = h; Object kp[] = ctx.keyGenerator().generatePKIKeypair(); _pubKeys[i] = (PublicKey) kp[0]; _privKeys[i] = (PrivateKey) kp[1]; } TunnelCreatorConfig cfg = new TunnelCreatorConfig(null, _peers.length, false); long now = ctx.clock().now(); // peers[] is ordered endpoint first, but cfg.getPeer() is ordered gateway first for (int i = 0; i < _peers.length; i++) { cfg.setPeer(i, _peers[i]); HopConfig hop = cfg.getConfig(i); hop.setExpiration(now + 10 * 60 * 1000); hop.setIVKey(ctx.keyGenerator().generateSessionKey()); hop.setLayerKey(ctx.keyGenerator().generateSessionKey()); hop.setReplyKey(ctx.keyGenerator().generateSessionKey()); byte iv[] = new byte[BuildRequestRecord.IV_SIZE]; Arrays.fill(iv, (byte) i); // consistent for repeatability hop.setReplyIV(new ByteArray(iv)); hop.setReceiveTunnelId(new TunnelId(i + 1)); } return cfg; }
/** * The local router has joined the given tunnel operating in the given state. * * @param state {"free inbound", "allocated inbound", "inactive inbound", "outbound", * "participant", "pending"} * @param tunnel tunnel joined */ public void tunnelJoined(String state, HopConfig tunnel) { if (!_doLog) return; if (tunnel == null) return; StringBuilder buf = new StringBuilder(128); buf.append(getPrefix()); buf.append("joining as [").append(state); buf.append("] to tunnel: ").append(tunnel.toString()); addEntry(buf.toString()); }