README for 2.0.1

This commit is contained in:
aceberg 2024-09-02 21:03:03 +07:00
parent 78772e9238
commit 180e46a934
7 changed files with 53 additions and 17 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
## [v2.0.1] - 2024-09-01
### Added
- Vlans and docker0 support [#47](https://github.com/aceberg/WatchYourLAN/issues/47). Thanks [thehijacker](https://github.com/thehijacker) for help with this issue!
- Remember `sort` field
- InfluxDB error handling

View file

@ -73,9 +73,10 @@ Configuration can be done through config file, GUI or environment variables
### Scan settings
| Variable | Description | Default |
| -------- | ----------- | ------- |
| IFACES | Interfaces to scan. Could be one or more, separated by space. Currently `docker0` is not supported, as `arp-scan` wouldn't work with it correctly | |
| IFACES | Interfaces to scan. Could be one or more, separated by space. See [docs/VLAN_ARP_SCAN.md](https://github.com/aceberg/WatchYourLAN/blob/main/docs/VLAN_ARP_SCAN.md). | |
| TIMEOUT | Time between scans (seconds) | 120 |
| ARP_ARGS | Arguments for `arp-scan`. See `man arp-scan` for more. Enable `debug` log level to see resulting command. (Example: `-r 1`) | |
| ARP_ARGS | Arguments for `arp-scan`. Enable `debug` log level to see resulting command. (Example: `-r 1`). See [docs/VLAN_ARP_SCAN.md](https://github.com/aceberg/WatchYourLAN/blob/main/docs/VLAN_ARP_SCAN.md). | |
| ARP_STRS ARP_STRS_JOINED | See [docs/VLAN_ARP_SCAN.md](https://github.com/aceberg/WatchYourLAN/blob/main/docs/VLAN_ARP_SCAN.md). | |
| LOG_LEVEL | Log level: `debug`, `info`, `warn` or `error` | info |
| TRIM_HIST | Remove history after (hours) | 48 |
| HIST_IN_DB | Store History in DB - if `false`, the History will be stored only in memory and will be lost on app restart. Though, it will keep the app DB smaller (and InfluxDB is recommended for long term History storage) | false |
@ -168,7 +169,7 @@ Or use [docker-compose](docker-compose-local.yml)
<details>
<summary>Expand</summary>
Moved to [docs/API.md](./docs/API.md)
Moved to [docs/API.md](https://github.com/aceberg/WatchYourLAN/blob/main/docs/API.md)
</details>
## Thanks

View file

@ -2,7 +2,7 @@
### 1. IFACES
`IFACES` is a required variable for WYL to work. It can be set through GUI, config file or environment variables.
`IFACES` is a required variable for WYL to work. It can be set through `GUI`, config file or environment variables.
`IFACES` is a list of network interfaces to scan, space separated. For example
```sh
IFACES: "enp4s0 wlxf4ec3892dd51"
@ -14,7 +14,7 @@ arp-scan -glNx -I $ONE_IFACE
```
### 2. ARP_ARGS
Setting `ARP_ARGS` is optional. It can be set through GUI, config file or environment variables.
Setting `ARP_ARGS` is optional. It can be set through `GUI`, config file or environment variables.
`ARP_ARGS` is additional arguments for `arp-scan`, that will be applied for **every** one of `IFACES`. For example:
```sh
ARP_ARGS: "-r 1"
@ -25,10 +25,10 @@ arp-scan -glNx -r 1 -I $ONE_IFACE
See `man arp-scan` for all arguments available.
### 3. ARP_STRS
### 3. ARP_STRS for VLANs, docker0 and other complicated scans
If `ARP_STRS` is set, it will initiate a completely separate from `IFACES` scan.
> [!WARNING]
> `ARP_STRS` can be set only through GUI or config file. For environment (docker-compose) see `ARP_STRS_JOINED`.
> `ARP_STRS` can be set only through `GUI` or config file. For environment (docker-compose) see `ARP_STRS_JOINED`.
`ARP_STRS` is a list of strings. `arp-scan` will run for each of them:
```sh
@ -40,8 +40,27 @@ arp-scan -gNx 10.0.107.0/24 -Q 107 -I eth0
```
Where `-Q` is a `vlan` id. **Warning:** the last element of string (`eth0` in this example) will be set as `Interface` for found hosts, so it is recommended to put interface at the end.
Setting `ARP_STRS` from config file:
```yaml
arp_strs:
- -gNx 172.17.0.1/24 -I docker0
- -glNx -I virbr0
```
From `GUI` put one string in `Arp Strings` input field, click `Save`, then another empty string will appear.
### 4. ARP_STRS_JOINED
`ARP_STRS_JOINED` is a way to set `ARP_STRS` from ENV. It's a list of strings, comma separated, without spaces before or after comma.
```sh
ARP_STRS_JOINED: "-glNx -I enp1s0,-glNx -I enp1s0"
ARP_STRS_JOINED: "-gNx 172.17.0.1/24 -I docker0,-gNx 10.0.107.0/24 -Q 107 -I eth0"
```
### 5. Examples
vlan id 107
```sh
ARP_STRS_JOINED: "-gNx 10.0.107.0/24 -Q 107 -I eth0"
```
docker0
```sh
ARP_STRS_JOINED: "-gNx 172.17.0.1/24 -I docker0"
```

View file

@ -2,6 +2,7 @@ package web
import (
"net"
"slices"
"strconv"
"strings"
@ -45,3 +46,13 @@ func getHostsByMAC(mac string, hosts []models.Host) (foundHosts []models.Host) {
return foundHosts
}
func getAllIfaces(hosts []models.Host) (ifaces []string) {
for _, host := range hosts {
if !slices.Contains(ifaces, host.Iface) {
ifaces = append(ifaces, host.Iface)
}
}
return ifaces
}

View file

@ -2,7 +2,6 @@ package web
import (
"net/http"
"strings"
"github.com/gin-gonic/gin"
@ -12,7 +11,7 @@ import (
func indexHandler(c *gin.Context) {
var guiData models.GuiData
guiData.Config = appConfig
guiData.Themes = strings.Split(appConfig.Ifaces, " ")
guiData.Themes = getAllIfaces(allHosts)
c.HTML(http.StatusOK, "header.html", guiData)
c.HTML(http.StatusOK, "index.html", guiData)

View file

@ -26,13 +26,17 @@ async function loadHistory() {
for (let a of addrsArray) {
url = '/api/history/'+a.Mac;
hist = await (await fetch(url)).json();
hist = sortHistByDate(hist);
if (show > 0) {
hist = hist.slice(0, show);
if (hist != null) {
hist = sortHistByDate(hist);
if (show > 0) {
hist = hist.slice(0, show);
}
td = getHistHTML(hist); // hist-html.js
}
td = getHistHTML(hist); // hist-html.js
i = i + 1;
tr = `

View file

@ -1,5 +1,5 @@
{{ define "config.html" }}
<script src="/fs/public/js/config.js"></script>
<body>
<div class="container-lg">
<div class="row">
@ -191,7 +191,8 @@
<p><b>Shoutrrr URL</b> provides notifications to Discord, Email, Gotify, Telegram and other services. <a href="https://containrrr.dev/shoutrrr/v0.8/" target="_blank">Link to documentation</a></p>
<p><b>Interfaces</b> - one or more, space separated</p>
<p><b>Timeout (seconds)</b> - time between scans</p>
<p><b>Args for arp-scan</b> - pass your own arguments to <code>arp-scan</code>. See <code>man arp-scan</code> for more. Enable <b>debug</b> log level to see resulting command. (Example: <code>-r 1</code>)</p>
<p><b>Args for arp-scan</b> - pass your own arguments to <code>arp-scan</code>. Enable <b>debug</b> log level to see resulting command. (Example: <code>-r 1</code>). See <a href="https://github.com/aceberg/WatchYourLAN/blob/main/docs/VLAN_ARP_SCAN.md" target="_blank">docs</a> for more.</p>
<p><b>Arp Strings</b> - can setup scans for <code>vlans</code>, <code>docker0</code> and etcetera. See <a href="https://github.com/aceberg/WatchYourLAN/blob/main/docs/VLAN_ARP_SCAN.md" target="_blank">docs</a> for more.</p>
<p><b>Trim History</b> - remove history after (hours)</p>
<p><b>Store History in DB</b> - if off, the History will be stored only in memory and will be lost on app restart. Though, it will keep the app DB smaller and InfluxDB is recommended for long term History storage</p>
<p><b>PG Connect URL</b> - address to connect to PostgreSQL DB. (Example: <code>postgres://username:password@192.168.0.1:5432/dbname?sslmode=disable</code>). Full list of URL parameters <a href="https://pkg.go.dev/github.com/lib/pq#hdr-Connection_String_Parameters" target="_blank">here</a></p>