-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optional preshared key and sensor rest api
- Loading branch information
Showing
7 changed files
with
77 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
## What’s changed | ||
## What’s changed in Wireguard Client Add-on v0.1.6 | ||
|
||
## 💣 Breaking changes | ||
## 🚀 Improvements | ||
|
||
- Add the PostUp and PostDown custom parameters | ||
- 💣 Breaking changes: add these lines to your current configuration: | ||
- Optional `pre_shared_key` parameter | ||
- Simple Rest API in order to expose Wireguard status in `sensor` configuration | ||
|
||
`post_up: iptables -t nat -A POSTROUTING -o wg0 -j MASQUERADE` | ||
## 🛠 Fixs | ||
|
||
`post_down: iptables -t nat -D POSTROUTING -o wg0 -j MASQUERADE` | ||
|
||
## 🧰 Maintenance | ||
|
||
- Update add-on configuration for Supervisor 2021.2 | ||
- `interface.address` is not hardcoded to its `/24` mask ~> if mask not specified then `/24`will be applied otherwise it is possible to assign `10.6.0.0/32` | ||
|
||
## ⬆️ Dependency updates | ||
|
||
- Upgrade add-on base image to 9.1.2 | ||
- Upgrade add-on base image to 9.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"build_from": { | ||
"aarch64": "ghcr.io/hassio-addons/base/aarch64:9.1.7", | ||
"amd64": "ghcr.io/hassio-addons/base/amd64:9.1.7", | ||
"armhf": "ghcr.io/hassio-addons/base/armhf:9.1.7", | ||
"armv7": "ghcr.io/hassio-addons/base/armv7:9.1.7", | ||
"i386": "ghcr.io/hassio-addons/base/i386:9.1.7" | ||
"aarch64": "ghcr.io/hassio-addons/base/aarch64:9.2.0", | ||
"amd64": "ghcr.io/hassio-addons/base/amd64:9.2.0", | ||
"armhf": "ghcr.io/hassio-addons/base/armhf:9.2.0", | ||
"armv7": "ghcr.io/hassio-addons/base/armv7:9.2.0", | ||
"i386": "ghcr.io/hassio-addons/base/i386:9.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/with-contenv bashio | ||
# ============================================================================== | ||
# Home Assistant Third Party Add-on: WireGuard Client | ||
# Provides status of WireGuard broker. | ||
# ============================================================================== | ||
declare -a peers | ||
declare endpoint | ||
declare json | ||
declare latest_handshake | ||
declare line | ||
declare name | ||
declare peer | ||
declare public_key | ||
declare transfer_rx | ||
declare transfer_tx | ||
|
||
while true; do | ||
# Get information from wg | ||
peers=() | ||
while IFS=$'\t' read -r -a line; do | ||
if [[ "${#line[@]}" -gt 6 ]]; then | ||
endpoint="${line[3]}" | ||
latest_handshake="${line[5]}" | ||
public_key="${line[1]}" | ||
transfer_rx="${line[6]}" | ||
transfer_tx="${line[7]}" | ||
|
||
peer=$(bashio::var.json \ | ||
'endpoint' "${endpoint}" \ | ||
'latest_handshake' "^${latest_handshake}" \ | ||
'transfer_rx' "^${transfer_rx}" \ | ||
'transfer_tx' "^${transfer_tx}") | ||
|
||
filename=$(sha1sum <<< "${public_key}" | awk '{ print $1 }') | ||
if bashio::fs.file_exists "/var/lib/wireguard/${filename}"; then | ||
name=$(<"/var/lib/wireguard/${filename}") | ||
peers+=("${name}") | ||
peers+=("^${peer}") | ||
fi | ||
fi | ||
done <<< "$(wg show all dump)" | ||
|
||
# Build final json content | ||
json="{}" | ||
if [[ "${#peers[@]}" -ne 0 ]]; then | ||
json=$(bashio::var.json "${peers[@]}") | ||
fi | ||
|
||
echo -e "HTTP/1.1 200 OK\r\nContent-type: application/json\r\n\r\n${json}" \ | ||
| nc -l -p 80 > /dev/null | ||
done |