Fix mDNS webserver port and expose prometheus service (#1389)
* Expose right webserver port using mDNS. 80 is the default value but can be changed in the config file. Add a new define for the port. Signed-off-by: Richard Weinberger <richard@nod.at> * Expose prometheus service via mDNS That way prometheus auto discovery features can find us. Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
committed by
GitHub
parent
be16d10b7d
commit
765e641d08
@@ -43,6 +43,10 @@ bool network_is_connected() {
|
||||
bool mdns_setup;
|
||||
#endif
|
||||
|
||||
#ifndef WEBSERVER_PORT
|
||||
static const uint8_t WEBSERVER_PORT = 80;
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
void network_setup_mdns(IPAddress address, int interface) {
|
||||
// Latest arduino framework breaks mDNS for AP interface
|
||||
@@ -65,12 +69,15 @@ void network_setup_mdns(IPAddress address, int interface) {
|
||||
MDNS.addServiceTxt("esphomelib", "tcp", "mac", get_mac_address().c_str());
|
||||
} else {
|
||||
#endif
|
||||
// Publish "http" service if not using native API.
|
||||
// Publish "http" service if not using native API nor the webserver component
|
||||
// This is just to have *some* mDNS service so that .local resolution works
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
MDNS.addService("http", "tcp", WEBSERVER_PORT);
|
||||
MDNS.addServiceTxt("http", "tcp", "version", ESPHOME_VERSION);
|
||||
#ifdef USE_API
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_PROMETHEUS
|
||||
MDNS.addService("prometheus-http", "tcp", WEBSERVER_PORT);
|
||||
#endif
|
||||
}
|
||||
void network_tick_mdns() {
|
||||
|
||||
Reference in New Issue
Block a user