mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +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 set connectionType to that connection to avoid that is get closed when
|
||||||
// we get too many connection attempts.
|
// we get too many connection attempts.
|
||||||
// That is used as protection against eclipse attacks.
|
// 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);
|
log.info("Received SealedAndSignedMessage and decrypted it: " + decryptedMsgWithPubKey);
|
||||||
decryptedMailListeners.stream().forEach(
|
decryptedMailListeners.stream().forEach(
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class Connection implements MessageListener {
|
||||||
private static final Logger log = LoggerFactory.getLogger(Connection.class);
|
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 MAX_MSG_SIZE = 5 * 1024 * 1024; // 5 MB of compressed data
|
||||||
private static final int SOCKET_TIMEOUT = 30 * 60 * 1000; // 30 min.
|
private static final int SOCKET_TIMEOUT = 30 * 60 * 1000; // 30 min.
|
||||||
private ConnectionType connectionType;
|
private ConnectionPriority connectionPriority;
|
||||||
|
|
||||||
public static int getMaxMsgSize() {
|
public static int getMaxMsgSize() {
|
||||||
return MAX_MSG_SIZE;
|
return MAX_MSG_SIZE;
|
||||||
|
@ -123,8 +123,8 @@ public class Connection implements MessageListener {
|
||||||
connectionListener.onPeerAddressAuthenticated(peerAddress, connection);
|
connectionListener.onPeerAddressAuthenticated(peerAddress, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConnectionType(ConnectionType connectionType) {
|
public void setConnectionPriority(ConnectionPriority connectionPriority) {
|
||||||
this.connectionType = connectionType;
|
this.connectionPriority = connectionPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called form various threads
|
// Called form various threads
|
||||||
|
@ -210,8 +210,8 @@ public class Connection implements MessageListener {
|
||||||
return stopped;
|
return stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectionType getConnectionType() {
|
public ConnectionPriority getConnectionPriority() {
|
||||||
return connectionType;
|
return connectionPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -332,7 +332,7 @@ public class Connection implements MessageListener {
|
||||||
", isAuthenticated=" + isAuthenticated +
|
", isAuthenticated=" + isAuthenticated +
|
||||||
", stopped=" + stopped +
|
", stopped=" + stopped +
|
||||||
", stopped=" + stopped +
|
", stopped=" + stopped +
|
||||||
", connectionType=" + connectionType +
|
", connectionType=" + connectionPriority +
|
||||||
", useCompression=" + useCompression +
|
", 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.Address;
|
||||||
import io.bitsquare.p2p.Message;
|
import io.bitsquare.p2p.Message;
|
||||||
import io.bitsquare.p2p.network.Connection;
|
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.MessageListener;
|
||||||
import io.bitsquare.p2p.network.NetworkNode;
|
import io.bitsquare.p2p.network.NetworkNode;
|
||||||
import io.bitsquare.p2p.peers.messages.auth.*;
|
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
|
// We use the active connectionType if we started the authentication request to another peer
|
||||||
// That is used for protecting eclipse attacks
|
// That is used for protecting eclipse attacks
|
||||||
connection.setConnectionType(ConnectionType.ACTIVE);
|
connection.setConnectionPriority(ConnectionPriority.ACTIVE);
|
||||||
|
|
||||||
AuthenticationResponse authenticationResponse = (AuthenticationResponse) message;
|
AuthenticationResponse authenticationResponse = (AuthenticationResponse) message;
|
||||||
Address peerAddress = authenticationResponse.address;
|
Address peerAddress = authenticationResponse.address;
|
||||||
|
@ -180,7 +180,7 @@ public class AuthenticationHandshake implements MessageListener {
|
||||||
log.trace("send AuthenticationRequest to " + peerAddress + " succeeded.");
|
log.trace("send AuthenticationRequest to " + peerAddress + " succeeded.");
|
||||||
connection.setPeerAddress(peerAddress);
|
connection.setPeerAddress(peerAddress);
|
||||||
// We protect that connection from getting closed by maintenance cleanup...
|
// We protect that connection from getting closed by maintenance cleanup...
|
||||||
connection.setConnectionType(ConnectionType.AUTH_REQUEST);
|
connection.setConnectionPriority(ConnectionPriority.AUTH_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -228,7 +228,7 @@ public class AuthenticationHandshake implements MessageListener {
|
||||||
connection.setPeerAddress(peerAddress);
|
connection.setPeerAddress(peerAddress);
|
||||||
// We use passive connectionType for connections created from received authentication requests from other peers
|
// We use passive connectionType for connections created from received authentication requests from other peers
|
||||||
// That is used for protecting eclipse attacks
|
// That is used for protecting eclipse attacks
|
||||||
connection.setConnectionType(ConnectionType.PASSIVE);
|
connection.setConnectionPriority(ConnectionPriority.PASSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class PeerGroup implements MessageListener, ConnectionListener {
|
||||||
Address peerAddress = message.address;
|
Address peerAddress = message.address;
|
||||||
if (!authenticationHandshakes.containsKey(peerAddress)) {
|
if (!authenticationHandshakes.containsKey(peerAddress)) {
|
||||||
// We protect that connection from getting closed by maintenance cleanup...
|
// 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());
|
AuthenticationHandshake authenticationHandshake = new AuthenticationHandshake(networkNode, PeerGroup.this, getMyAddress());
|
||||||
authenticationHandshakes.put(peerAddress, authenticationHandshake);
|
authenticationHandshakes.put(peerAddress, authenticationHandshake);
|
||||||
SettableFuture<Connection> future = authenticationHandshake.respondToAuthenticationRequest(message, connection);
|
SettableFuture<Connection> future = authenticationHandshake.respondToAuthenticationRequest(message, connection);
|
||||||
|
@ -467,7 +467,7 @@ public class PeerGroup implements MessageListener, ConnectionListener {
|
||||||
|
|
||||||
List<Connection> authenticatedConnections = allConnections.stream()
|
List<Connection> authenticatedConnections = allConnections.stream()
|
||||||
.filter(e -> e.isAuthenticated())
|
.filter(e -> e.isAuthenticated())
|
||||||
.filter(e -> e.getConnectionType() == ConnectionType.PASSIVE)
|
.filter(e -> e.getConnectionPriority() == ConnectionPriority.PASSIVE)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (authenticatedConnections.size() == 0) {
|
if (authenticatedConnections.size() == 0) {
|
||||||
|
@ -476,7 +476,7 @@ public class PeerGroup implements MessageListener, ConnectionListener {
|
||||||
if (size > MAX_CONNECTIONS_NORMAL_PRIO) {
|
if (size > MAX_CONNECTIONS_NORMAL_PRIO) {
|
||||||
authenticatedConnections = allConnections.stream()
|
authenticatedConnections = allConnections.stream()
|
||||||
.filter(e -> e.isAuthenticated())
|
.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());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (authenticatedConnections.size() == 0) {
|
if (authenticatedConnections.size() == 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue