pass in unresolved name for use as servername in ws_connect #20349
+4
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Taking a look at old issue [#17923] - aiohttp has supported passing
server_hostnameinto ws_connect for a few releases.This PR will always pass in
server_hostnameeven if it's an IP address, which may be harmless but I'm not sure and might need some adjustment to only pass in things that look like FQDNs.I'm not clear on how to test this, but it should work, but only for those hosts listed using FQDNs in the config. Note that P2P node discovery only deals in IPs, so this cannot work in that case.
This uses the so-called ugly way from the bug but I choose this as it keeps everything else the same.
Note
Add optional server_hostname to outbound ws connections and pass unresolved host as SNI/Host header when dialing configured peers.
ChiaServer.start_client(...)addsserver_hostname: str | Noneparam.aiohttpby settingserver_hostnameandheaders={"Host": server_hostname}inws_connectwhen provided.Service._connect_peers_task_handler: pass the original unresolved hostname (unresolved.host) tostart_client(..., server_hostname=...)for configured peers.Written by Cursor Bugbot for commit f9a0190. This will update automatically on new commits. Configure here.