Use compatible version with latest TomP2P lib

This commit is contained in:
Manfred Karrer 2014-11-06 16:43:09 +01:00
parent e4743ca469
commit 1dde1f361f

View file

@ -86,7 +86,7 @@ public class UtilsDHT2 {
boolean firewallTCP) throws UnknownHostException { boolean firewallTCP) throws UnknownHostException {
InetAddress inetSend = InetAddress.getByName(inetSender); InetAddress inetSend = InetAddress.getByName(inetSender);
PeerSocketAddress peerSocketAddress = new PeerSocketAddress(inetSend, tcpPortSender, udpPortSender); PeerSocketAddress peerSocketAddress = new PeerSocketAddress(inetSend, tcpPortSender, udpPortSender);
PeerAddress n1 = new PeerAddress(idSender, peerSocketAddress, firewallTCP, firewallUDP, false, false, PeerAddress n1 = new PeerAddress(idSender, peerSocketAddress, firewallTCP, firewallUDP, false, false, false,
PeerAddress.EMPTY_PEER_SOCKET_ADDRESSES); PeerAddress.EMPTY_PEER_SOCKET_ADDRESSES);
return n1; return n1;
} }
@ -94,8 +94,7 @@ public class UtilsDHT2 {
public static Message createDummyMessage(Number160 idSender, String inetSender, int tcpPortSendor, public static Message createDummyMessage(Number160 idSender, String inetSender, int tcpPortSendor,
int udpPortSender, Number160 idRecipien, String inetRecipient, int udpPortSender, Number160 idRecipien, String inetRecipient,
int tcpPortRecipient, int tcpPortRecipient,
int udpPortRecipient, byte command, Type type, boolean firewallUDP, int udpPortRecipient, byte command, Type type, boolean firewallUDP, boolean firewallTCP)
boolean firewallTCP)
throws UnknownHostException { throws UnknownHostException {
Message message = new Message(); Message message = new Message();
PeerAddress n1 = createAddress(idSender, inetSender, tcpPortSendor, udpPortSender, firewallUDP, PeerAddress n1 = createAddress(idSender, inetSender, tcpPortSendor, udpPortSender, firewallUDP,
@ -123,11 +122,15 @@ public class UtilsDHT2 {
* Creates peers for testing. The first peer (peer[0]) will be used as the master. This means that shutting down * Creates peers for testing. The first peer (peer[0]) will be used as the master. This means that shutting down
* peer[0] will shut down all other peers * peer[0] will shut down all other peers
* *
* @param nrOfPeers The number of peers to create including the master * @param nrOfPeers
* @param rnd The random object to create random peer IDs * The number of peers to create including the master
* @param port The port where the master peer will listen to * @param rnd
* The random object to create random peer IDs
* @param port
* The port where the master peer will listen to
* @return All the peers, with the master peer at position 0 -> peer[0] * @return All the peers, with the master peer at position 0 -> peer[0]
* @throws Exception If the creation of nodes fail. * @throws Exception
* If the creation of nodes fail.
*/ */
public static PeerDHT[] createNodes(int nrOfPeers, Random rnd, int port, AutomaticFuture automaticFuture, public static PeerDHT[] createNodes(int nrOfPeers, Random rnd, int port, AutomaticFuture automaticFuture,
boolean maintenance) throws Exception { boolean maintenance) throws Exception {
@ -160,8 +163,7 @@ public class UtilsDHT2 {
PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId)); PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
Peer peer = new PeerBuilder(peerId) Peer peer = new PeerBuilder(peerId)
.masterPeer(master) .masterPeer(master)
.enableMaintenance(maintenance).enableMaintenance(maintenance).peerMap(peerMap).bindings .enableMaintenance(maintenance).enableMaintenance(maintenance).peerMap(peerMap).bindings(bindings).start().addAutomaticFuture(automaticFuture);
(bindings).start().addAutomaticFuture(automaticFuture);
peers[i] = new PeerBuilderDHT(peer).start(); peers[i] = new PeerBuilderDHT(peer).start();
} }
else { else {
@ -209,7 +211,8 @@ public class UtilsDHT2 {
* Perfect routing, where each neighbor has contacted each other. This means that for small number of peers, every * Perfect routing, where each neighbor has contacted each other. This means that for small number of peers, every
* peer knows every other peer. * peer knows every other peer.
* *
* @param peers The peers taking part in the p2p network. * @param peers
* The peers taking part in the p2p network.
*/ */
public static void perfectRouting(PeerDHT... peers) { public static void perfectRouting(PeerDHT... peers) {
for (int i = 0; i < peers.length; i++) { for (int i = 0; i < peers.length; i++) {