-
Notifications
You must be signed in to change notification settings - Fork 391
Fix hostname support #864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hostname support #864
Changes from 1 commit
03f214e
dfa61b5
557d0ca
d69829c
576e57e
afeb7ff
7a6a887
7b3d38b
85d0752
2e8976c
2908b04
a106bb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,7 +90,8 @@ def _get_status( | |
| _LOGGER.debug("Resolved service %s to %s", service, host) | ||
| break | ||
|
|
||
| headers = {"content-type": "application/json"} | ||
| # unsetting the host header, as requests with a domain would be blocked otherwise | ||
| headers = {"host": "", "content-type": "application/json"} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this end up setting it to an empty string. I am not sure that is such a good idea. "A Host header field must be sent in all HTTP/1.1 request messages. A 400 Bad Request status code may be sent to any HTTP/1.1 request message that lacks or contains more than one Host header field." So it likely need to be set to the IP address of the request.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would still like an example showing where this is a problem and how this PR fixes it.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect just setting a manual dns (ie not mdns) hostname for a chromecast instead of an IP would cause it.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just realized that it might only be possible with the changes for ipv6 that was posted that does a getaddrinfo lookup.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My usecase is indeed to have a custom DNS name for a cast device, as I can't use mDNS in my setup, since the cast devices are in a different L2/L3 network than Home Assistant. I do agree with setting the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned here: home-assistant/core#135024 (comment) Adding the IP of the chromecast in the host header fixes the issue
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the PR to do something inbetween; if the HTTP get fails with FORBIDDEN, we retry with an empty The reason I suggest this simplified approach is to avoid doing the name resolution via |
||
|
|
||
| if secure: | ||
| url = FORMAT_BASE_URL_HTTPS.format(host) + path | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please better explain what this is intended to fix, I can't reproduce any case where this is blocked myself.
Maybe paste some examples using
curlto craft the working and non-working requests?Are you sure the problem you see is not caused by an issue in your network configuration?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When requesting the
/setup/eureka_infoendpoint using a hostname (instead of a plain IP), the request is blocked. I can reproduce this both with an Nvidia Shield and a Google Home Mini. I doubt my network influences this, as the devices are on the same L2 and L3 network and can communicate directly. Here are some simple curl commands for reproduction:Working
Blocked