From 9f7e8177ec2d0504fbe1aee6759b962417415056 Mon Sep 17 00:00:00 2001 From: aceberg <1502200+aceberg@users.noreply.github.com> Date: Mon, 16 Jan 2023 19:55:15 +0700 Subject: [PATCH] Button to test notifications --- CHANGELOG.md | 6 ++--- README.md | 39 ++++++++++++++---------------- docker-compose.yml | 3 ++- internal/web/config.go | 13 ++++++++++ internal/web/templates/config.html | 12 ++++++--- internal/web/webgui.go | 1 + 6 files changed, 45 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9bdc98..b3a0f2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [v0.9.1] - 2023-01- +## [v0.9.1] - 2023-01-16 ### Added - Scan host for open ports -- Docker image with embed CSS - App version on config page -- Check if update available +- Check if update is available +- Button to test notifications ### Changed - Small fixes diff --git a/README.md b/README.md index 2949ca2..ab6d914 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,27 @@ -
- - - - -
+

+ +WatchYourLAN


-# WatchYourLAN - [![Docker](https://github.com/aceberg/WatchYourLAN/actions/workflows/main-docker-all.yml/badge.svg)](https://github.com/aceberg/WatchYourLAN/actions/workflows/main-docker-all.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/aceberg/WatchYourLAN)](https://goreportcard.com/report/github.com/aceberg/WatchYourLAN) [![Maintainability](https://api.codeclimate.com/v1/badges/46b17f99edc1726b5d7d/maintainability)](https://codeclimate.com/github/aceberg/WatchYourLAN/maintainability) ![Docker Image Size (latest semver)](https://img.shields.io/docker/image-size/aceberg/watchyourlan) ![Docker Pulls](https://img.shields.io/docker/pulls/aceberg/watchyourlan) -Lightweight network IP scanner with web GUI -https://github.com/aceberg/WatchYourLAN +Lightweight network IP scanner with web GUI https://github.com/aceberg/WatchYourLAN + +- [Quick start](https://github.com/aceberg/WatchYourLAN#quick-start) +- [Config](https://github.com/aceberg/WatchYourLAN#config) +- [Config file](https://github.com/aceberg/WatchYourLAN#config-file) +- [Options](https://github.com/aceberg/WatchYourLAN#options) +- [Thanks](https://github.com/aceberg/WatchYourLAN#thanks) ![Screenshot_v0.6](https://raw.githubusercontent.com/aceberg/WatchYourLAN/main/assets/Screenshot_v0.6.png) ## Quick start -Replace `$YOURTIMEZONE` with correct time zone and `$YOURIFACE` with network interface you want to scan. Network mode must be `host`. - -```sh -docker run --name wyl \ - -e "IFACE=$YOURIFACE" \ - -e "TZ=$YOURTIMEZONE" \ - --network="host" \ - aceberg/watchyourlan -``` - -Set `$DOCKERDATAPATH` for container to save data: +Replace `$YOURTIMEZONE` with correct time zone and `$YOURIFACE` with network interface you want to scan. Network mode must be `host`. Set `$DOCKERDATAPATH` for container to save data: ```sh docker run --name wyl \ @@ -71,8 +61,15 @@ GUIPORT="8840" TIMEOUT="300" # 5 minutes SHOUTRRR_URL="gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes" # Url to notify THEME="darkly" +IGNOREIP="no" ``` +## Options + +| Key | Description | Default | +| -------- | ----------- | ------- | +| -c | Path to config file | /data/config | + ## Thanks - All go packages listed in [dependencies](https://github.com/aceberg/WatchYourLAN/network/dependencies) - Favicon and logo: [Access point icons created by Freepik - Flaticon](https://www.flaticon.com/free-icons/access-point) diff --git a/docker-compose.yml b/docker-compose.yml index 58f1493..b975e58 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,4 +14,5 @@ services: GUIPORT: "8840" # optional, default: 8840 TIMEOUT: "120" # optional, time in seconds, default: 60 SHOUTRRR_URL: "" # optional, set url to notify - THEME: "darkly" # optional \ No newline at end of file + THEME: "darkly" # optional + IGNOREIP: "no" # optional \ No newline at end of file diff --git a/internal/web/config.go b/internal/web/config.go index 165ba46..935bb04 100644 --- a/internal/web/config.go +++ b/internal/web/config.go @@ -12,6 +12,7 @@ import ( "github.com/aceberg/WatchYourLAN/internal/conf" "github.com/aceberg/WatchYourLAN/internal/db" "github.com/aceberg/WatchYourLAN/internal/models" + "github.com/aceberg/WatchYourLAN/internal/notify" "github.com/aceberg/WatchYourLAN/internal/scan" ) @@ -63,6 +64,8 @@ func saveConfigHandler(w http.ResponseWriter, r *http.Request) { conf.Write(ConfigPath, AppConfig) + log.Println("INFO: writing new config") + QuitScan = make(chan bool) go scan.Start(AppConfig, QuitScan) @@ -77,3 +80,13 @@ func clearHandler(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, r.Header.Get("Referer"), 302) } + +func testNotifyHandler(w http.ResponseWriter, r *http.Request) { + + log.Println("INFO: Test notification send") + + msg := "Test notification" + notify.Shoutrrr(msg, AppConfig.ShoutURL) + + http.Redirect(w, r, r.Header.Get("Referer"), 302) +} diff --git a/internal/web/templates/config.html b/internal/web/templates/config.html index 3090971..66d30af 100644 --- a/internal/web/templates/config.html +++ b/internal/web/templates/config.html @@ -28,7 +28,9 @@ Shoutrrr URL - + + + Theme @@ -51,9 +53,11 @@ - - + + + +
@@ -64,7 +68,7 @@