diff --git a/README.md b/README.md index 34510af..5d15167 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,20 @@ Example add-on configuration: ```json { "log_level": "info", + "hosts": [ + { + "name": "Desktop", + "ip": "192.168.1.5" + }, + { + "name": "Router", + "ip": "192.168.1.1" + }, + { + "name": "Mom", + "ip": "192.168.1.47" + } + ], "ssl": true, "certfile": "fullchain.pem", "keyfile": "privkey.pem" @@ -86,6 +100,14 @@ more severe level, e.g., `debug` also shows `info` messages. By default, the `log_level` is set to `info`, which is the recommended setting unless you are troubleshooting. +### Option: `hosts` + +This option allows you to create client friendly names in the interface of +AdGuard Home. It is much more useful to see "Desktop PC" compared to just +the `192.168.5.34` IP-address from the AdGuard Home Admin panel. + +See the example above this chapter for a more visual representation. + ### Option: `ssl` Enables/Disables SSL (HTTPS) on the add-on. Set it `true` to enable it, diff --git a/adguard/config.json b/adguard/config.json index 9d86c43..c83215d 100755 --- a/adguard/config.json +++ b/adguard/config.json @@ -34,12 +34,19 @@ "ssl" ], "options": { + "hosts": [], "ssl": true, "certfile": "fullchain.pem", "keyfile": "privkey.pem" }, "schema": { "log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)?", + "hosts": [ + { + "name": "str", + "ip": "match(((^\\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\\s*$)|(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$)))" + } + ], "ssl": "bool", "certfile": "str", "keyfile": "str", diff --git a/adguard/rootfs/etc/cont-init.d/hosts.sh b/adguard/rootfs/etc/cont-init.d/hosts.sh new file mode 100644 index 0000000..cd85a47 --- /dev/null +++ b/adguard/rootfs/etc/cont-init.d/hosts.sh @@ -0,0 +1,14 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Community Hass.io Add-ons: AdGuard Home +# Adds client friendly names for IP addresses +# ============================================================================== +declare name +declare ip + +for host in $(bashio::config 'hosts|keys'); do + name=$(bashio::config "hosts[${host}].name") + ip=$(bashio::config "hosts[${host}].ip") + bashio::log.debug "Adding host: ${ip} matches ${name}" + echo "${ip} ${name}" >> /etc/hosts +done