Scrub real LAN addresses, MACs and name from docs and test fixtures
This commit is contained in:
parent
c9738358de
commit
3d0e4bd153
6 changed files with 20 additions and 20 deletions
10
README.md
10
README.md
|
|
@ -67,7 +67,7 @@ Inside an LXC you are root, so that's it. On another Linux machine in native mod
|
||||||
Then connect AdGuard Home in `/opt/network-monitor/.env`:
|
Then connect AdGuard Home in `/opt/network-monitor/.env`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ADGUARD_URL=http://192.168.1.2:3000 # AdGuard Home's web UI address
|
ADGUARD_URL=http://10.9.8.2:3000 # AdGuard Home's web UI address
|
||||||
ADGUARD_USERNAME=admin
|
ADGUARD_USERNAME=admin
|
||||||
ADGUARD_PASSWORD=...
|
ADGUARD_PASSWORD=...
|
||||||
```
|
```
|
||||||
|
|
@ -82,10 +82,10 @@ On the hub, open **Probes → Add probe** and give the probe a name. The hub sho
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Linux host (Docker), an LXC as root (native, detected automatically), or macOS as your user
|
# Linux host (Docker), an LXC as root (native, detected automatically), or macOS as your user
|
||||||
curl -fsSL http://192.168.1.10:8000/install-probe.sh | HUB_URL=http://192.168.1.10:8000 PROBE_TOKEN=... bash
|
curl -fsSL http://10.9.8.10:8000/install-probe.sh | HUB_URL=http://10.9.8.10:8000 PROBE_TOKEN=... bash
|
||||||
|
|
||||||
# Linux, native, not root
|
# Linux, native, not root
|
||||||
curl -fsSL http://192.168.1.10:8000/install-probe.sh | sudo env HUB_URL=http://192.168.1.10:8000 PROBE_TOKEN=... bash
|
curl -fsSL http://10.9.8.10:8000/install-probe.sh | sudo env HUB_URL=http://10.9.8.10:8000 PROBE_TOKEN=... bash
|
||||||
```
|
```
|
||||||
|
|
||||||
The same installer is also at `https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install-probe.sh`.
|
The same installer is also at `https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install-probe.sh`.
|
||||||
|
|
@ -118,10 +118,10 @@ To change the defaults, set these before `bash`:
|
||||||
| `LXC_STORAGE` | `local-lvm`, else `local-zfs`, else the first container storage |
|
| `LXC_STORAGE` | `local-lvm`, else `local-zfs`, else the first container storage |
|
||||||
| `LXC_TEMPLATE_STORAGE` | `local` |
|
| `LXC_TEMPLATE_STORAGE` | `local` |
|
||||||
| `LXC_BRIDGE` | `vmbr0` |
|
| `LXC_BRIDGE` | `vmbr0` |
|
||||||
| `LXC_IP` | `dhcp`; a static address looks like `192.168.68.50/24` together with `LXC_GW=192.168.68.1` |
|
| `LXC_IP` | `dhcp`; a static address looks like `10.9.8.50/24` together with `LXC_GW=10.9.8.1` |
|
||||||
| `LXC_CORES`, `LXC_MEMORY`, `LXC_DISK` | `1`, `512`, `4` (GB) |
|
| `LXC_CORES`, `LXC_MEMORY`, `LXC_DISK` | `1`, `512`, `4` (GB) |
|
||||||
|
|
||||||
For example: `curl -fsSL .../install.sh | LXC_IP=192.168.68.50/24 LXC_GW=192.168.68.1 bash`.
|
For example: `curl -fsSL .../install.sh | LXC_IP=10.9.8.50/24 LXC_GW=10.9.8.1 bash`.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
- **`.local` names:** the installer runs Avahi in the container, so it answers at `<hostname>.local`. The hub's container is `netmon-hub`, so `http://netmon-hub.local`. The hub has the container to itself and listens on port 80, so no port is needed; pass `HOST_PORT` to choose another. Native installs inside an LXC you made yourself work the same way.
|
- **`.local` names:** the installer runs Avahi in the container, so it answers at `<hostname>.local`. The hub's container is `netmon-hub`, so `http://netmon-hub.local`. The hub has the container to itself and listens on port 80, so no port is needed; pass `HOST_PORT` to choose another. Native installs inside an LXC you made yourself work the same way.
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ export function toast(message, kind = 'info') {
|
||||||
|
|
||||||
/** Copies text and toasts `what`; resolves false (and says so) when the browser refuses.
|
/** Copies text and toasts `what`; resolves false (and says so) when the browser refuses.
|
||||||
* navigator.clipboard only exists in secure contexts (https, localhost). On plain http, e.g.
|
* navigator.clipboard only exists in secure contexts (https, localhost). On plain http, e.g.
|
||||||
* http://192.168.1.10 or http://host.local, it falls back to a hidden textarea + execCommand. */
|
* http://10.9.8.10 or http://host.local, it falls back to a hidden textarea + execCommand. */
|
||||||
export async function copyText(text, what = 'Copied') {
|
export async function copyText(text, what = 'Copied') {
|
||||||
let ok = false;
|
let ok = false;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
# HOST_PORT default 8000 (bound to HOST_BIND from .env: 0.0.0.0 so probes can report)
|
# HOST_PORT default 8000 (bound to HOST_BIND from .env: 0.0.0.0 so probes can report)
|
||||||
# Proxmox (lxc mode): LXC_ID (default: next free), LXC_STORAGE (default: local-lvm, local-zfs
|
# Proxmox (lxc mode): LXC_ID (default: next free), LXC_STORAGE (default: local-lvm, local-zfs
|
||||||
# or the first active), LXC_TEMPLATE_STORAGE (local), LXC_BRIDGE (vmbr0), LXC_IP (dhcp,
|
# or the first active), LXC_TEMPLATE_STORAGE (local), LXC_BRIDGE (vmbr0), LXC_IP (dhcp,
|
||||||
# or 192.168.1.50/24 with LXC_GW), LXC_CORES (1), LXC_MEMORY (512), LXC_DISK (4 GB)
|
# or 10.9.8.50/24 with LXC_GW), LXC_CORES (1), LXC_MEMORY (512), LXC_DISK (4 GB)
|
||||||
#
|
#
|
||||||
# install-probe.sh is generated from this file by scripts/build-installers.sh: edit this one.
|
# install-probe.sh is generated from this file by scripts/build-installers.sh: edit this one.
|
||||||
# Everything is inside main(), so a partial download runs nothing. bash 3.2 compatible (macOS).
|
# Everything is inside main(), so a partial download runs nothing. bash 3.2 compatible (macOS).
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ def handler(request: httpx.Request) -> httpx.Response:
|
||||||
})
|
})
|
||||||
if p == "/control/clients":
|
if p == "/control/clients":
|
||||||
return httpx.Response(200, json={
|
return httpx.Response(200, json={
|
||||||
"clients": [{"name": "Neil's laptop", "ids": ["192.168.1.5", "AA:BB:CC:DD:EE:01"]}],
|
"clients": [{"name": "Test laptop", "ids": ["192.168.1.5", "AA:BB:CC:DD:EE:01"]}],
|
||||||
"auto_clients": [{"ip": "192.168.1.50", "name": "tv.lan", "source": "rDNS"}],
|
"auto_clients": [{"ip": "192.168.1.50", "name": "tv.lan", "source": "rDNS"}],
|
||||||
})
|
})
|
||||||
if p == "/control/dhcp/status":
|
if p == "/control/dhcp/status":
|
||||||
|
|
@ -90,7 +90,7 @@ def test_discovery_merges_sources(hub, ag):
|
||||||
asyncio.run(dns.discover_once())
|
asyncio.run(dns.discover_once())
|
||||||
clients = {c["key"]: c for c in hub.get("/api/clients").json()["clients"]}
|
clients = {c["key"]: c for c in hub.get("/api/clients").json()["clients"]}
|
||||||
laptop = clients["aa:bb:cc:dd:ee:01"]
|
laptop = clients["aa:bb:cc:dd:ee:01"]
|
||||||
assert laptop["ip"] == "192.168.1.5" and laptop["hostname"] in ("Neil's laptop", "host-5")
|
assert laptop["ip"] == "192.168.1.5" and laptop["hostname"] in ("Test laptop", "host-5")
|
||||||
assert laptop["online"] and laptop["queries"] == 660 and "adguard" in laptop["sources"]
|
assert laptop["online"] and laptop["queries"] == 660 and "adguard" in laptop["sources"]
|
||||||
assert not laptop["new"] # found on the first day: not flagged as new
|
assert not laptop["new"] # found on the first day: not flagged as new
|
||||||
assert clients["aa:bb:cc:dd:ee:02"]["hostname"] == "plug"
|
assert clients["aa:bb:cc:dd:ee:02"]["hostname"] == "plug"
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ pct() {{ echo "pct $*" >> {log}; case $1 in
|
||||||
config) [ "$2" = 100 ] && echo "tags: web"; [ "$2" = 105 ] && printf 'hostname: netmon-hub\\ntags: netmon-hub\\n'; true ;;
|
config) [ "$2" = 100 ] && echo "tags: web"; [ "$2" = 105 ] && printf 'hostname: netmon-hub\\ntags: netmon-hub\\n'; true ;;
|
||||||
status) echo "status: stopped" ;;
|
status) echo "status: stopped" ;;
|
||||||
push) cp "$3" {pushed} ;;
|
push) cp "$3" {pushed} ;;
|
||||||
exec) shift 3; [ "$1" = hostname ] && echo "192.168.68.50 "; true ;;
|
exec) shift 3; [ "$1" = hostname ] && echo "10.9.8.50 "; true ;;
|
||||||
esac; }}
|
esac; }}
|
||||||
pvesh() {{ echo "pvesh $*" >> {log}; echo 105; }}
|
pvesh() {{ echo "pvesh $*" >> {log}; echo 105; }}
|
||||||
pveam() {{ echo "pveam $*" >> {log}; [ "$1" = available ] && printf "system debian-12-standard_12.7-1_amd64.tar.zst\\nsystem debian-12-standard_12.12-1_amd64.tar.zst\\n"; true; }}
|
pveam() {{ echo "pveam $*" >> {log}; [ "$1" = available ] && printf "system debian-12-standard_12.7-1_amd64.tar.zst\\nsystem debian-12-standard_12.12-1_amd64.tar.zst\\n"; true; }}
|
||||||
|
|
@ -101,7 +101,7 @@ export -f pct pvesh pveam pvesm sleep id
|
||||||
# Native inside, port 80 for the .local name, a locale the container has, one summary.
|
# Native inside, port 80 for the .local name, a locale the container has, one summary.
|
||||||
for part in ("INSTALL_MODE=native", "HOST_PORT=80", "LC_ALL=C.UTF-8", "LANG=C.UTF-8", "NETMON_NESTED=1"):
|
for part in ("INSTALL_MODE=native", "HOST_PORT=80", "LC_ALL=C.UTF-8", "LANG=C.UTF-8", "NETMON_NESTED=1"):
|
||||||
assert part in inner, part
|
assert part in inner, part
|
||||||
assert "http://netmon-hub.local (or http://192.168.68.50)" in r.stdout
|
assert "http://netmon-hub.local (or http://10.9.8.50)" in r.stdout
|
||||||
assert "pct exec 105 -- network-monitor-update" in r.stdout # works because setup.sh links it into /usr/bin
|
assert "pct exec 105 -- network-monitor-update" in r.stdout # works because setup.sh links it into /usr/bin
|
||||||
# The pushed script is a complete installer for the same role.
|
# The pushed script is a complete installer for the same role.
|
||||||
text = pushed.read_text()
|
text = pushed.read_text()
|
||||||
|
|
|
||||||
|
|
@ -113,20 +113,20 @@ def test_macos_parsers():
|
||||||
route = """ route to: default
|
route = """ route to: default
|
||||||
destination: default
|
destination: default
|
||||||
mask: default
|
mask: default
|
||||||
gateway: 192.168.68.1
|
gateway: 10.9.8.1
|
||||||
interface: en0
|
interface: en0
|
||||||
flags: <UP,GATEWAY,DONE,STATIC,PRCLONING,GLOBAL>
|
flags: <UP,GATEWAY,DONE,STATIC,PRCLONING,GLOBAL>
|
||||||
"""
|
"""
|
||||||
assert checks.parse_route_get(route) == "192.168.68.1"
|
assert checks.parse_route_get(route) == "10.9.8.1"
|
||||||
assert checks.parse_route_get("route: writing to routing socket: not in table\n") is None
|
assert checks.parse_route_get("route: writing to routing socket: not in table\n") is None
|
||||||
arp = """? (192.168.68.1) at 0:ef:15:97:fc:1e on en0 ifscope [ethernet]
|
arp = """? (10.9.8.1) at 0:02:aa:bb:1c:3d on en0 ifscope [ethernet]
|
||||||
? (192.168.68.20) at e0:51:d8:1c:5f:96 on en0 ifscope [ethernet]
|
? (10.9.8.20) at 2:51:d8:1c:5f:96 on en0 ifscope [ethernet]
|
||||||
? (192.168.68.77) at (incomplete) on en0 ifscope [ethernet]
|
? (10.9.8.77) at (incomplete) on en0 ifscope [ethernet]
|
||||||
? (192.168.68.255) at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]
|
? (10.9.8.255) at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]
|
||||||
? (192.168.64.2) at 2a:1:3:4:5:6 on bridge100 ifscope [bridge]
|
? (10.9.7.2) at 2a:1:3:4:5:6 on bridge100 ifscope [bridge]
|
||||||
? (224.0.0.251) at 1:0:5e:0:0:fb on en0 ifscope permanent [ethernet]
|
? (224.0.0.251) at 1:0:5e:0:0:fb on en0 ifscope permanent [ethernet]
|
||||||
"""
|
"""
|
||||||
assert checks.parse_arp_an(arp) == [
|
assert checks.parse_arp_an(arp) == [
|
||||||
{"ip": "192.168.68.1", "mac": "00:ef:15:97:fc:1e"},
|
{"ip": "10.9.8.1", "mac": "00:02:aa:bb:1c:3d"},
|
||||||
{"ip": "192.168.68.20", "mac": "e0:51:d8:1c:5f:96"},
|
{"ip": "10.9.8.20", "mac": "02:51:d8:1c:5f:96"},
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue