diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d681dde..4d87451 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ # These are supported funding model platforms -custom: ['https://boosty.to/aceberg/donate', 'https://aceberg.github.io/MyDocs/sponsor'] +custom: ['https://boosty.to/aceberg/donate', 'https://github.com/aceberg#donate'] diff --git a/.github/workflows/dev-docker-io.yml b/.github/workflows/dev-docker-io.yml index 52ba050..89c62d1 100644 --- a/.github/workflows/dev-docker-io.yml +++ b/.github/workflows/dev-docker-io.yml @@ -14,10 +14,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build and Push Docker Image to docker.io - uses: mr-smithers-excellent/docker-build-push@v5 + uses: mr-smithers-excellent/docker-build-push@v6 with: image: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} tags: ${{ env.TAGS }} diff --git a/.github/workflows/main-docker-all.yml b/.github/workflows/main-docker-all.yml index 426cc9e..50c5407 100644 --- a/.github/workflows/main-docker-all.yml +++ b/.github/workflows/main-docker-all.yml @@ -17,41 +17,41 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get version tag from env file - uses: c-py/action-dotenv-to-setenv@v2 + uses: c-py/action-dotenv-to-setenv@v5 with: env-file: .version - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to GHCR - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: | - ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest + ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:v2 ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} - ghcr.io/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest + ghcr.io/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:v2 ghcr.io/${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} \ No newline at end of file diff --git a/.github/workflows/readme-docker.yml b/.github/workflows/readme-docker.yml index 9847bf6..0444fc0 100644 --- a/.github/workflows/readme-docker.yml +++ b/.github/workflows/readme-docker.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Sync README.md to DockerHub uses: ms-jpq/sync-dockerhub-readme@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 976b8f1..1c860a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Change Log All notable changes to this project will be documented in this file. -## [v2.0.0] - 2024-08- +## [v2.0.0] - 2024-08-30 +### Added +- API +- Arguments for `arp-scan` option +- `InfluxDB` export +- `PostgreSQL` or `SQLite` DB options +- Names from DNS + ### Changed +- Better UI with JS +- Switched to `gin` web framework +- Reworked DB schema and config variables diff --git a/README.md b/README.md index 538b2f0..65d70d0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,10 @@ Lightweight network IP scanner with web GUI > [!WARNING] -> This README is about version 2.0, which is going to be released soon. There will be BREAKING CHANGES! Version 1.0 can be found in this brunch: [v1](https://github.com/aceberg/WatchYourLAN/tree/v1) +> This README is about version 2.0. Version 1.0 can be found in this brunch: [v1](https://github.com/aceberg/WatchYourLAN/tree/v1) + +> [!BREAKING CHANGES] +> Version 2.0 is not compatible with v1.0. For now v2.0 docker images will be released under `v2` tag. It will be tagged `latest` in a few weeks (probably, in October), to give everyone enough time for a smooth migration. ![Screenshot_1](https://raw.githubusercontent.com/aceberg/WatchYourLAN/main/assets/Screenshot_1.png) @@ -28,7 +31,7 @@ docker run --name wyl \ -e "TZ=$YOURTIMEZONE" \ --network="host" \ -v $DOCKERDATAPATH/wyl:/data/WatchYourLAN \ - aceberg/watchyourlan + aceberg/watchyourlan:v2 ``` Web GUI should be at http://localhost:8840 @@ -38,11 +41,42 @@ Web GUI should be at http://localhost:8840
Expand -Configuration can be done through config file or environment variables +Configuration can be done through config file, GUI or environment variables +### Basic config | Variable | Description | Default | | -------- | ----------- | ------- | +| TZ | Set your timezone for correct time | | +| HOST | Listen address | 0.0.0.0 | +| PORT | Port for web GUI | 8840 | +| THEME | Any theme name from https://bootswatch.com in lowcase or [additional](https://github.com/aceberg/aceberg-bootswatch-fork) | sand | | COLOR | Background color: light or dark | dark | +| NODEPATH | Path to local node modules | | +| SHOUTRRR_URL | Link to any notification service supported by [Shoutrrr](https://github.com/containrrr/shoutrrr) (gotify, email, telegram and others) or [Generic Webhook](https://github.com/containrrr/shoutrrr/blob/main/docs/services/generic.md) | | + +### 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 | | +| 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`) | | +| 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 | +| USE_DB | Either `sqlite` or `postgres` | sqlite | +| PG_CONNECT | Address to connect to PostgreSQL. (Example: `postgres://username:password@192.168.0.1:5432/dbname?sslmode=disable`). Full list of URL parameters [here](https://pkg.go.dev/github.com/lib/pq#hdr-Connection_String_Parameters) | | + +### InfluxDB2 config +This config matches Grafana's config for InfluxDB data source + +| Variable | Description | Default | Example | +| -------- | ----------- | ------- | ------- | +| INFLUX_ENABLE | Enable export to InfluxDB2 | false | true | +| INFLUX_SKIP_TLS | Skip TLS Verify | false | true | +| INFLUX_ADDR | Address:port of InfluxDB2 server | | https://192.168.2.3:8086/ | +| INFLUX_BUCKET | InfluxDB2 bucket | | test | +| INFLUX_ORG | InfluxDB2 org | | home | +| INFLUX_TOKEN | Secret token, generated by InfluxDB2 | | |
@@ -51,6 +85,30 @@ Configuration can be done through config file or environment variables
Expand +Config file name is `config_v2.yaml`. Example: + +```yaml +arp_args: "" +color: dark +hist_in_db: false +host: 0.0.0.0 +ifaces: enp4s0 +influx_addr: "" +influx_bucket: "" +influx_enable: false +influx_org: "" +influx_skip_tls: false +influx_token: "" +log_level: info +nodepath: "" +pg_connect: "" +port: "8840" +shoutrrr_url: "gotify://192.168.0.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes" +theme: sand +timeout: 60 +trim_hist: 48 +use_db: sqlite +```
@@ -61,8 +119,8 @@ Configuration can be done through config file or environment variables | Key | Description | Default | | -------- | ----------- | ------- | -| -c | Path to config file | /data/config.yaml | -| -n | Path to node modules (see below) | "" | +| -d | Path to config dir | /data/WatchYourLAN | +| -n | Path to node modules (see below) | | @@ -79,11 +137,11 @@ docker run --name node-bootstrap \ ``` ```sh docker run --name wyl \ - -e "IFACE=$YOURIFACE" \ + -e "IFACES=$YOURIFACE" \ -e "TZ=$YOURTIMEZONE" \ --network="host" \ - -v $DOCKERDATAPATH/wyl:/data \ - aceberg/watchyourlan -n "http://$YOUR_IP:8850" + -v $DOCKERDATAPATH/wyl:/data/WatchYourLAN \ + aceberg/watchyourlan:v2 -n "http://$YOUR_IP:8850" ``` Or use [docker-compose](docker-compose-local.yml) diff --git a/configs/watchyourlan.service b/configs/watchyourlan.service index eb6ce84..868e90a 100644 --- a/configs/watchyourlan.service +++ b/configs/watchyourlan.service @@ -5,7 +5,7 @@ After=network-online.target Wants=network-online.target [Service] -ExecStart=/usr/bin/watchyourlan -c /etc/watchyourlan/config.yaml +ExecStart=/usr/bin/watchyourlan -d /etc/watchyourlan/ Restart=on-failure [Install] diff --git a/docker-compose-local.yml b/docker-compose-local.yml index b7ce8cd..f4602c4 100644 --- a/docker-compose-local.yml +++ b/docker-compose-local.yml @@ -6,21 +6,20 @@ services: ports: - 8850:8850 wyl: - image: aceberg/watchyourlan + image: aceberg/watchyourlan:v2 network_mode: "host" restart: unless-stopped command: "-n http://YOUR_IP:8850" # put your server IP or DNS name here depends_on: - node-bootstrap volumes: - - ~/.dockerdata/wyl:/data + - ~/.dockerdata/wyl:/data/WatchYourLAN environment: TZ: Asia/Novosibirsk # required: needs your TZ for correct time - IFACE: "enp4s0" # required: 1 or more interface - DBPATH: "/data/db.sqlite" # optional, default: /data/db.sqlite - GUIIP: "0.0.0.0" # optional, default: localhost - GUIPORT: "8840" # optional, default: 8840 - TIMEOUT: "120" # optional, time in seconds, default: 60 + IFACES: "enp4s0 wlxf4ec3892dd51" # required: 1 or more interface + HOST: "0.0.0.0" # optional, default: 0.0.0.0 + PORT: "8840" # optional, default: 8840 + TIMEOUT: "120" # optional, time in seconds, default: 120 SHOUTRRR_URL: "" # optional, set url to notify - THEME: "darkly" # optional - IGNOREIP: "no" # optional \ No newline at end of file + THEME: "sand" # optional + COLOR: "dark" # optional \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 35d15f8..b9d0753 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,17 @@ version: "3" services: wyl: - image: aceberg/watchyourlan + image: aceberg/watchyourlan:v2 network_mode: "host" restart: unless-stopped volumes: - ~/.dockerdata/wyl:/data/WatchYourLAN environment: TZ: Asia/Novosibirsk # required: needs your TZ for correct time - IFACE: "virbr-bw wlxf4ec3892dd51" # required: 1 or more interface - DBPATH: "/data/db.sqlite" # optional, default: /data/db.sqlite - GUIIP: "0.0.0.0" # optional, default: localhost - GUIPORT: "8840" # optional, default: 8840 - TIMEOUT: "120" # optional, time in seconds, default: 60 + IFACES: "enp4s0 wlxf4ec3892dd51" # required: 1 or more interface + HOST: "0.0.0.0" # optional, default: 0.0.0.0 + PORT: "8840" # optional, default: 8840 + TIMEOUT: "120" # optional, time in seconds, default: 120 SHOUTRRR_URL: "" # optional, set url to notify - THEME: "darkly" # optional - IGNOREIP: "no" # optional \ No newline at end of file + THEME: "sand" # optional + COLOR: "dark" # optional \ No newline at end of file diff --git a/internal/web/public/box.svg b/internal/web/public/box.svg new file mode 100644 index 0000000..a9d9224 --- /dev/null +++ b/internal/web/public/box.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/internal/web/public/css/index.css b/internal/web/public/css/index.css index 25657a1..0660a2d 100644 --- a/internal/web/public/css/index.css +++ b/internal/web/public/css/index.css @@ -1,3 +1,4 @@ +/* Sort button */ .my-btn { height: 100%; background-color: #00000000; @@ -8,6 +9,22 @@ background-color: #0000001a; } +/* History box */ +.my-box-on::before, .my-box-off::before { + content: url(/fs/public/box.svg); + border-left: thin solid black; +} +.my-box-on { + background-color: var(--bs-success); +} +.my-box-off { + background-color: var(--bs-gray-500); +} +.my-box-on:hover, .my-box-off:hover { + background-color: #0000001a; +} + + .hidden { display: none; } \ No newline at end of file diff --git a/internal/web/public/js/hist-html.js b/internal/web/public/js/hist-html.js index 9844014..c0d7313 100644 --- a/internal/web/public/js/hist-html.js +++ b/internal/web/public/js/hist-html.js @@ -5,16 +5,13 @@ function getHistHTML(hist) { for (let h of hist) { if (h.Now != 0) { - col = `fill:var(--bs-success);stroke:var(--bs-primary);`; + col = `my-box-on`; } else { - col = `fill:var(--bs-gray-500);stroke:var(--bs-primary);`; + col = `my-box-off`; } title = `title="Date: ${h.Date}\nIface: ${h.Iface}\nIP: ${h.IP}\nKnown: ${h.Known}"`; - html = html + ` - - Sorry, your browser does not support inline SVG. - `; + html = html + ``; } return html; }