Skip to content

Commit

Permalink
README for 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Sep 2, 2024
1 parent 78772e9 commit 180e46a
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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
Expand Down
29 changes: 24 additions & 5 deletions docs/VLAN_ARP_SCAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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"
```
11 changes: 11 additions & 0 deletions internal/web/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package web

import (
"net"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions internal/web/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package web

import (
"net/http"
"strings"

"github.com/gin-gonic/gin"

Expand All @@ -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)
Expand Down
14 changes: 9 additions & 5 deletions internal/web/public/js/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
Expand Down
5 changes: 3 additions & 2 deletions internal/web/templates/config.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ define "config.html" }}
<script src="/fs/public/js/config.js"></script>

<body>
<div class="container-lg">
<div class="row">
Expand Down Expand Up @@ -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:[email protected]: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>
Expand Down

0 comments on commit 180e46a

Please sign in to comment.