server: Don't pass the host to `WSChiaConnection` (#14152)

Use the one from the connection data like we do it with the port. The
result there is slightly different since its resolved so `localhost`
becomes an IP in `peer_info` but i anyway will open a PR soon to
transition from `str` to `IPAddress` in there.
This commit is contained in:
dustinface 2023-05-10 03:58:20 +07:00 committed by GitHub
parent 2983b99590
commit b90d91d46b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 7 deletions

View File

@ -329,7 +329,6 @@ class ChiaServer:
log=self.log,
is_outbound=False,
received_message_callback=self.received_message_callback,
peer_host=request.remote,
close_callback=self.connection_closed,
peer_id=peer_id,
inbound_rate_limit_percent=self._inbound_rate_limit_percent,
@ -474,7 +473,6 @@ class ChiaServer:
log=self.log,
is_outbound=True,
received_message_callback=self.received_message_callback,
peer_host=target_node.host,
close_callback=self.connection_closed,
peer_id=peer_id,
inbound_rate_limit_percent=self._inbound_rate_limit_percent,

View File

@ -128,7 +128,6 @@ class WSChiaConnection:
log: logging.Logger,
is_outbound: bool,
received_message_callback: Optional[ConnectionCallback],
peer_host: str,
close_callback: Optional[ConnectionClosedCallbackProtocol],
peer_id: bytes32,
inbound_rate_limit_percent: int,
@ -140,7 +139,7 @@ class WSChiaConnection:
peername = ws._writer.transport.get_extra_info("peername")
if peername is None:
raise ValueError(f"Was not able to get peername from {peer_host}")
raise ValueError(f"Was not able to get peername for {peer_id}")
if is_outbound:
request_nonce = uint16(0)
@ -156,7 +155,7 @@ class WSChiaConnection:
local_port=server_port,
local_capabilities_for_handshake=local_capabilities_for_handshake,
local_capabilities=known_active_capabilities(local_capabilities_for_handshake),
peer_info=PeerInfo(peer_host, peername[1]),
peer_info=PeerInfo(peername[0], peername[1]),
peer_node_id=peer_id,
log=log,
close_callback=close_callback,

View File

@ -62,7 +62,6 @@ async def add_dummy_connection(
log,
True,
server.received_message_callback,
self_hostname,
None,
peer_id,
100,

View File

@ -28,7 +28,6 @@ async def establish_connection(server: ChiaServer, self_hostname: str, ssl_conte
server.log,
True,
server.received_message_callback,
self_hostname,
None,
bytes32(b"\x00" * 32),
100,