Skip to content
8 changes: 5 additions & 3 deletions chia/solver/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ def get_connections(self, request_node_type: Optional[NodeType]) -> list[dict[st
return default_get_connections(server=self.server, request_node_type=request_node_type)

async def on_connect(self, connection: WSChiaConnection) -> None:
if not self.config.get("trusted_peers_only", True):
self.log.info(f"trusted peers check disabled, Accepting connection from {connection.get_peer_logging()}")
return
if self.server.is_trusted_peer(connection, self.config.get("trusted_peers", {})):
self.log.info(f"Accepting connection from {connection.get_peer_logging()}")
return
if not self.config.get("trusted_peers_only", True):
self.log.info(
f"trusted peers check disabled, Accepting connection from untrusted {connection.get_peer_logging()}"
)
return
self.log.warning(f"Rejecting untrusted connection from {connection.get_peer_logging()}")
await connection.close()

Expand Down
2 changes: 1 addition & 1 deletion chia/util/initial-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ solver:

# Node IDs of trusted solver peers, only these can connect by default
trusted_peers:
localhost: 9999
0ThisisanexampleNodeID7ff9d60f1c3fa270c213c0ad0cb89c01274634a7c3cb7: Does_not_matter

# If False, accepts connections from all peers (not just trusted_peers)
# If True (default), only accepts localhost and trusted_peers connections
Expand Down
Loading