mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
rename
This commit is contained in:
parent
a35b7250df
commit
89ca80364c
5 changed files with 22 additions and 14 deletions
|
@ -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(ConnectionType.DIRECT_MSG);
|
||||
connection.setConnectionPriority(ConnectionPriority.DIRECT_MSG);
|
||||
|
||||
log.info("Received SealedAndSignedMessage and decrypted it: " + decryptedMsgWithPubKey);
|
||||
decryptedMailListeners.stream().forEach(
|
||||
|
|
|
@ -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 ConnectionType connectionType;
|
||||
private ConnectionPriority connectionPriority;
|
||||
|
||||
public static int getMaxMsgSize() {
|
||||
return MAX_MSG_SIZE;
|
||||
|
@ -123,8 +123,8 @@ public class Connection implements MessageListener {
|
|||
connectionListener.onPeerAddressAuthenticated(peerAddress, connection);
|
||||
}
|
||||
|
||||
public void setConnectionType(ConnectionType connectionType) {
|
||||
this.connectionType = connectionType;
|
||||
public void setConnectionPriority(ConnectionPriority connectionPriority) {
|
||||
this.connectionPriority = connectionPriority;
|
||||
}
|
||||
|
||||
// Called form various threads
|
||||
|
@ -210,8 +210,8 @@ public class Connection implements MessageListener {
|
|||
return stopped;
|
||||
}
|
||||
|
||||
public ConnectionType getConnectionType() {
|
||||
return connectionType;
|
||||
public ConnectionPriority getConnectionPriority() {
|
||||
return connectionPriority;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -332,7 +332,7 @@ public class Connection implements MessageListener {
|
|||
", isAuthenticated=" + isAuthenticated +
|
||||
", stopped=" + stopped +
|
||||
", stopped=" + stopped +
|
||||
", connectionType=" + connectionType +
|
||||
", connectionType=" + connectionPriority +
|
||||
", useCompression=" + useCompression +
|
||||
'}';
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package io.bitsquare.p2p.network;
|
||||
|
||||
public enum ConnectionPriority {
|
||||
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
|
||||
}
|
|
@ -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.ConnectionType;
|
||||
import io.bitsquare.p2p.network.ConnectionPriority;
|
||||
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(ConnectionType.ACTIVE);
|
||||
connection.setConnectionPriority(ConnectionPriority.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(ConnectionType.AUTH_REQUEST);
|
||||
connection.setConnectionPriority(ConnectionPriority.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(ConnectionType.PASSIVE);
|
||||
connection.setConnectionPriority(ConnectionPriority.PASSIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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(ConnectionType.AUTH_REQUEST);
|
||||
connection.setConnectionPriority(ConnectionPriority.AUTH_REQUEST);
|
||||
AuthenticationHandshake authenticationHandshake = new AuthenticationHandshake(networkNode, PeerGroup.this, getMyAddress());
|
||||
authenticationHandshakes.put(peerAddress, authenticationHandshake);
|
||||
SettableFuture<Connection> future = authenticationHandshake.respondToAuthenticationRequest(message, connection);
|
||||
|
@ -467,7 +467,7 @@ public class PeerGroup implements MessageListener, ConnectionListener {
|
|||
|
||||
List<Connection> authenticatedConnections = allConnections.stream()
|
||||
.filter(e -> e.isAuthenticated())
|
||||
.filter(e -> e.getConnectionType() == ConnectionType.PASSIVE)
|
||||
.filter(e -> e.getConnectionPriority() == ConnectionPriority.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() == ConnectionType.PASSIVE || e.getConnectionType() == ConnectionType.ACTIVE)
|
||||
.filter(e -> e.getConnectionPriority() == ConnectionPriority.PASSIVE || e.getConnectionPriority() == ConnectionPriority.ACTIVE)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (authenticatedConnections.size() == 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue