Skip to content

Poll for address of Supervisor default interface for mDNS URL #165

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

Merged
merged 2 commits into from
May 21, 2025

Conversation

sairon
Copy link
Member

@sairon sairon commented May 20, 2025

Outstanding comment mentions the hacky way for obtaining the outbound IP address should be replaced by API from home-assistant/supervisor#2115. Poll this API periodically with 5s retry interval in case the IP can't be determined or parsed from the response.

This still ignores IPv6-only deployment of HA, however, in that case the landing page should still be reachable, just not discoverable through mDNS (combined with #164).

Outstanding comment mentions the hacky way for obtaining the outbound IP
address should be replaced by API from home-assistant/supervisor#2115.
Poll this API periodically with 5s retry interval in case the IP can't
be determined or parsed from the response.

This still ignores IPv6-only deployment of HA, however, in that case the
landing page should still be reachable, just not discoverable through
mDNS (combined with #164).
@sairon sairon requested a review from agners May 20, 2025 17:05
supervisorHost := getSupervisorHost()

client := &http.Client{}
req, err := http.NewRequest("GET", "http://"+supervisorHost+"/network/interface/default/info", nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a job for net/url to build the URL? 🤔

mdns.go Outdated
return nil, fmt.Errorf("can't create request to Supervisor: %s", err)
}

req.Header.Add("Authorization", "Bearer "+os.Getenv("SUPERVISOR_TOKEN"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make this a helper function similar to getSupervisorHost()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean something like setSupervisorAuthHeader(req)?

@sairon sairon requested a review from agners May 21, 2025 10:05
@sairon sairon merged commit 18b72a7 into main May 21, 2025
25 checks passed
@sairon sairon deleted the mdns-outbound-ip-from-supervisor branch May 21, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants