Skip to content

Commit

Permalink
✨ Adds support for adding client friendly names
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck committed May 10, 2019
1 parent 0cf0da6 commit d500305
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions adguard/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions adguard/rootfs/etc/cont-init.d/hosts.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d500305

Please sign in to comment.