-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
A helper class that could resolve from "hosts", mDNS and finally DNS #5648
base: dev
Are you sure you want to change the base?
Conversation
d083b66
to
739e866
Compare
7f1cd4e
to
f1b5f50
Compare
756d15f
to
4ddfe98
Compare
std::vector<network::IPAddress> resolved; | ||
mdns_result_t *results = nullptr; | ||
mdns_ip_addr_t *a = nullptr; | ||
esp_err_t err = mdns_query_ptr(("_" + servicename).c_str(), "_tcp", 3000, 20, &results); |
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.
Why query for PTR here?
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.
I think the goal here is to look for a A/AAAA record?
Maybe
mdns_query(servicename, NULL, NULL, MDNS_TYPE_ANY, 20, &results);
or maybe MDNS_TYPE_A
, MDNS_TYPE_AAAA
?
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.
Good catch!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #5648 +/- ##
==========================================
+ Coverage 53.70% 53.91% +0.20%
==========================================
Files 50 50
Lines 9408 9625 +217
Branches 1654 1698 +44
==========================================
+ Hits 5053 5189 +136
- Misses 4056 4112 +56
- Partials 299 324 +25 ☔ View full report in Codecov by Sentry. |
Co-authored-by: J. Nick Koston <nick@koston.org>
7a81bc9
to
f438012
Compare
What does this implement/fix?
There are currently no way to have anything similar to an /etc/hosts-file. This adds that (would solve esphome/feature-requests#2008), but also a common way to resolve names by mDNS and regular DNS. The mDNS support is intentional simplified to search for a service with the "hostname" asked for.
Could be breaking for external components
Todo:
/etc/hosts
-like filesTypes of changes
Related issue or feature (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Test Environment
Example entry for
config.yaml
:# Example config.yaml
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: