From a35b7250dfee0e35f06398e1da72f8af158d49ac Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 16 Nov 2015 17:52:27 +0100 Subject: [PATCH] rename --- network/src/main/java/io/bitsquare/p2p/P2PService.java | 2 +- .../main/java/io/bitsquare/p2p/network/Connection.java | 6 +++--- .../java/io/bitsquare/p2p/network/ConnectionMode.java | 8 -------- .../io/bitsquare/p2p/peers/AuthenticationHandshake.java | 8 ++++---- .../src/main/java/io/bitsquare/p2p/peers/PeerGroup.java | 6 +++--- 5 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 network/src/main/java/io/bitsquare/p2p/network/ConnectionMode.java diff --git a/network/src/main/java/io/bitsquare/p2p/P2PService.java b/network/src/main/java/io/bitsquare/p2p/P2PService.java index 204c8c5a8e..67d18230ee 100644 --- a/network/src/main/java/io/bitsquare/p2p/P2PService.java +++ b/network/src/main/java/io/bitsquare/p2p/P2PService.java @@ -186,7 +186,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis // We set connectionType to that connection to avoid that is get closed when // we get too many connection attempts. // That is used as protection against eclipse attacks. - connection.setConnectionType(ConnectionMode.DIRECT_MSG); + connection.setConnectionType(ConnectionType.DIRECT_MSG); log.info("Received SealedAndSignedMessage and decrypted it: " + decryptedMsgWithPubKey); decryptedMailListeners.stream().forEach( diff --git a/network/src/main/java/io/bitsquare/p2p/network/Connection.java b/network/src/main/java/io/bitsquare/p2p/network/Connection.java index 4bf0b6527f..0883e834b2 100644 --- a/network/src/main/java/io/bitsquare/p2p/network/Connection.java +++ b/network/src/main/java/io/bitsquare/p2p/network/Connection.java @@ -31,7 +31,7 @@ public class Connection implements MessageListener { private static final Logger log = LoggerFactory.getLogger(Connection.class); private static final int MAX_MSG_SIZE = 5 * 1024 * 1024; // 5 MB of compressed data private static final int SOCKET_TIMEOUT = 30 * 60 * 1000; // 30 min. - private ConnectionMode connectionType; + private ConnectionType connectionType; public static int getMaxMsgSize() { return MAX_MSG_SIZE; @@ -123,7 +123,7 @@ public class Connection implements MessageListener { connectionListener.onPeerAddressAuthenticated(peerAddress, connection); } - public void setConnectionType(ConnectionMode connectionType) { + public void setConnectionType(ConnectionType connectionType) { this.connectionType = connectionType; } @@ -210,7 +210,7 @@ public class Connection implements MessageListener { return stopped; } - public ConnectionMode getConnectionType() { + public ConnectionType getConnectionType() { return connectionType; } diff --git a/network/src/main/java/io/bitsquare/p2p/network/ConnectionMode.java b/network/src/main/java/io/bitsquare/p2p/network/ConnectionMode.java deleted file mode 100644 index 702cd413fe..0000000000 --- a/network/src/main/java/io/bitsquare/p2p/network/ConnectionMode.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.bitsquare.p2p.network; - -public enum ConnectionMode { - PASSIVE, // for connections initiated by other peer - ACTIVE, // for connections initiated by us - DIRECT_MSG, // for connections used for direct messaging - AUTH_REQUEST // for connections used for starting the authentication -} diff --git a/network/src/main/java/io/bitsquare/p2p/peers/AuthenticationHandshake.java b/network/src/main/java/io/bitsquare/p2p/peers/AuthenticationHandshake.java index e4cce6b0e0..e6ea23f897 100644 --- a/network/src/main/java/io/bitsquare/p2p/peers/AuthenticationHandshake.java +++ b/network/src/main/java/io/bitsquare/p2p/peers/AuthenticationHandshake.java @@ -8,7 +8,7 @@ import io.bitsquare.common.UserThread; import io.bitsquare.p2p.Address; import io.bitsquare.p2p.Message; import io.bitsquare.p2p.network.Connection; -import io.bitsquare.p2p.network.ConnectionMode; +import io.bitsquare.p2p.network.ConnectionType; import io.bitsquare.p2p.network.MessageListener; import io.bitsquare.p2p.network.NetworkNode; import io.bitsquare.p2p.peers.messages.auth.*; @@ -72,7 +72,7 @@ public class AuthenticationHandshake implements MessageListener { // We use the active connectionType if we started the authentication request to another peer // That is used for protecting eclipse attacks - connection.setConnectionType(ConnectionMode.ACTIVE); + connection.setConnectionType(ConnectionType.ACTIVE); AuthenticationResponse authenticationResponse = (AuthenticationResponse) message; Address peerAddress = authenticationResponse.address; @@ -180,7 +180,7 @@ public class AuthenticationHandshake implements MessageListener { log.trace("send AuthenticationRequest to " + peerAddress + " succeeded."); connection.setPeerAddress(peerAddress); // We protect that connection from getting closed by maintenance cleanup... - connection.setConnectionType(ConnectionMode.AUTH_REQUEST); + connection.setConnectionType(ConnectionType.AUTH_REQUEST); } @Override @@ -228,7 +228,7 @@ public class AuthenticationHandshake implements MessageListener { connection.setPeerAddress(peerAddress); // We use passive connectionType for connections created from received authentication requests from other peers // That is used for protecting eclipse attacks - connection.setConnectionType(ConnectionMode.PASSIVE); + connection.setConnectionType(ConnectionType.PASSIVE); } @Override diff --git a/network/src/main/java/io/bitsquare/p2p/peers/PeerGroup.java b/network/src/main/java/io/bitsquare/p2p/peers/PeerGroup.java index 3176f10c7b..b136dc59c1 100644 --- a/network/src/main/java/io/bitsquare/p2p/peers/PeerGroup.java +++ b/network/src/main/java/io/bitsquare/p2p/peers/PeerGroup.java @@ -168,7 +168,7 @@ public class PeerGroup implements MessageListener, ConnectionListener { Address peerAddress = message.address; if (!authenticationHandshakes.containsKey(peerAddress)) { // We protect that connection from getting closed by maintenance cleanup... - connection.setConnectionType(ConnectionMode.AUTH_REQUEST); + connection.setConnectionType(ConnectionType.AUTH_REQUEST); AuthenticationHandshake authenticationHandshake = new AuthenticationHandshake(networkNode, PeerGroup.this, getMyAddress()); authenticationHandshakes.put(peerAddress, authenticationHandshake); SettableFuture future = authenticationHandshake.respondToAuthenticationRequest(message, connection); @@ -467,7 +467,7 @@ public class PeerGroup implements MessageListener, ConnectionListener { List authenticatedConnections = allConnections.stream() .filter(e -> e.isAuthenticated()) - .filter(e -> e.getConnectionType() == ConnectionMode.PASSIVE) + .filter(e -> e.getConnectionType() == ConnectionType.PASSIVE) .collect(Collectors.toList()); if (authenticatedConnections.size() == 0) { @@ -476,7 +476,7 @@ public class PeerGroup implements MessageListener, ConnectionListener { if (size > MAX_CONNECTIONS_NORMAL_PRIO) { authenticatedConnections = allConnections.stream() .filter(e -> e.isAuthenticated()) - .filter(e -> e.getConnectionType() == ConnectionMode.PASSIVE || e.getConnectionType() == ConnectionMode.ACTIVE) + .filter(e -> e.getConnectionType() == ConnectionType.PASSIVE || e.getConnectionType() == ConnectionType.ACTIVE) .collect(Collectors.toList()); if (authenticatedConnections.size() == 0) {