Compare commits

...

2 Commits

3 changed files with 48 additions and 45 deletions

View File

@ -90,7 +90,7 @@ class IntroductionManager {
/** map of relay tag to PeerState who have given us introduction tags */
private final Map<Long, PeerState> _inbound;
/** map of relay nonce to alice PeerState who requested it */
private final Map<Long, PeerState2> _nonceToAlice;
private final ConcurrentHashMap<Long, PeerState2> _nonceToAlice;
private final Set<InetAddress> _recentHolePunches;
private long _lastHolePunchClean;

View File

@ -343,7 +343,7 @@ class PacketBuilder2 {
*
*/
public UDPPacket buildACK(PeerState2 peer) {
return buildPacket(Collections.emptyList(), peer);
return buildPacket(Collections.<Fragment>emptyList(), peer);
}
/**
@ -363,7 +363,7 @@ class PacketBuilder2 {
}
Block block = new SSU2Payload.TerminationBlock(reason, peer.getReceivedMessages().getHighestSet());
blocks.add(block);
UDPPacket packet = buildPacket(Collections.emptyList(), blocks, peer);
UDPPacket packet = buildPacket(Collections.<Fragment>emptyList(), blocks, peer);
packet.setMessageType(TYPE_DESTROY);
return packet;
}
@ -652,7 +652,7 @@ class PacketBuilder2 {
*/
public UDPPacket buildPeerTestFromAlice(byte[] signedData, PeerState2 bob) {
Block block = new SSU2Payload.PeerTestBlock(1, 0, null, signedData);
UDPPacket rv = buildPacket(Collections.emptyList(), Collections.singletonList(block), bob);
UDPPacket rv = buildPacket(Collections.<Fragment>emptyList(), Collections.singletonList(block), bob);
rv.setMessageType(TYPE_TFA);
return rv;
}
@ -688,7 +688,7 @@ class PacketBuilder2 {
*/
public UDPPacket buildPeerTestToAlice(int code, Hash charlieHash, byte[] signedData, PeerState2 alice) {
Block block = new SSU2Payload.PeerTestBlock(4, code, charlieHash, signedData);
UDPPacket rv = buildPacket(Collections.emptyList(), Collections.singletonList(block), alice);
UDPPacket rv = buildPacket(Collections.<Fragment>emptyList(), Collections.singletonList(block), alice);
rv.setMessageType(TYPE_TTA);
return rv;
}
@ -724,7 +724,7 @@ class PacketBuilder2 {
*/
public UDPPacket buildPeerTestToCharlie(Hash aliceHash, byte[] signedData, PeerState2 charlie) {
Block block = new SSU2Payload.PeerTestBlock(2, 0, aliceHash, signedData);
UDPPacket rv = buildPacket(Collections.emptyList(), Collections.singletonList(block), charlie);
UDPPacket rv = buildPacket(Collections.<Fragment>emptyList(), Collections.singletonList(block), charlie);
rv.setMessageType(TYPE_TBC);
return rv;
}
@ -737,7 +737,7 @@ class PacketBuilder2 {
*/
public UDPPacket buildPeerTestToBob(int code, byte[] signedData, PeerState2 bob) {
Block block = new SSU2Payload.PeerTestBlock(3, code, null, signedData);
UDPPacket rv = buildPacket(Collections.emptyList(), Collections.singletonList(block), bob);
UDPPacket rv = buildPacket(Collections.<Fragment>emptyList(), Collections.singletonList(block), bob);
rv.setMessageType(TYPE_TCB);
return rv;
}
@ -751,7 +751,7 @@ class PacketBuilder2 {
*/
UDPPacket buildRelayRequest(byte[] signedData, PeerState2 bob) {
Block block = new SSU2Payload.RelayRequestBlock(signedData);
UDPPacket rv = buildPacket(Collections.emptyList(), Collections.singletonList(block), bob);
UDPPacket rv = buildPacket(Collections.<Fragment>emptyList(), Collections.singletonList(block), bob);
rv.setMessageType(TYPE_RREQ);
rv.setPriority(PRIORITY_HIGH);
return rv;
@ -766,7 +766,7 @@ class PacketBuilder2 {
*/
UDPPacket buildRelayIntro(byte[] signedData, PeerState2 charlie) {
Block block = new SSU2Payload.RelayIntroBlock(signedData);
UDPPacket rv = buildPacket(Collections.emptyList(), Collections.singletonList(block), charlie);
UDPPacket rv = buildPacket(Collections.<Fragment>emptyList(), Collections.singletonList(block), charlie);
rv.setMessageType(TYPE_INTRO);
return rv;
}
@ -781,7 +781,7 @@ class PacketBuilder2 {
*/
UDPPacket buildRelayResponse(byte[] signedData, PeerState2 state) {
Block block = new SSU2Payload.RelayResponseBlock(signedData);
UDPPacket rv = buildPacket(Collections.emptyList(), Collections.singletonList(block), state);
UDPPacket rv = buildPacket(Collections.<Fragment>emptyList(), Collections.singletonList(block), state);
rv.setMessageType(TYPE_RESP);
return rv;
}

View File

@ -5,6 +5,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@ -25,6 +26,8 @@ import net.i2p.data.i2np.I2NPMessageImpl;
import net.i2p.router.RouterContext;
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
import net.i2p.router.transport.udp.InboundMessageFragments.ModifiableLong;
import net.i2p.router.transport.udp.PacketBuilder.Fragment;
import static net.i2p.router.transport.udp.SSU2Util.*;
import net.i2p.util.HexDump;
import net.i2p.util.Log;
@ -457,7 +460,7 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback
}
if (tag > 0) {
SSU2Payload.Block block = new SSU2Payload.RelayTagBlock(tag);
UDPPacket pkt = _transport.getBuilder2().buildPacket(Collections.emptyList(),
UDPPacket pkt = _transport.getBuilder2().buildPacket(Collections.<Fragment>emptyList(),
Collections.singletonList(block),
this);
_transport.send(pkt);
@ -649,7 +652,7 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback
if (_log.shouldInfo())
_log.info("Got PATH CHALLENGE block, length: " + data.length + " on " + this);
SSU2Payload.Block block = new SSU2Payload.PathResponseBlock(data);
UDPPacket pkt = _transport.getBuilder2().buildPacket(Collections.emptyList(),
UDPPacket pkt = _transport.getBuilder2().buildPacket(Collections.<Fragment>emptyList(),
Collections.singletonList(block),
this);
// TODO send to from address?