Skip to content

Commit 9f7e817

Browse files
committed
Button to test notifications
1 parent 5ea9527 commit 9f7e817

6 files changed

Lines changed: 45 additions & 29 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [v0.9.1] - 2023-01-
8+
## [v0.9.1] - 2023-01-16
99
### Added
1010
- Scan host for open ports
11-
- Docker image with embed CSS
1211
- App version on config page
13-
- Check if update available
12+
- Check if update is available
13+
- Button to test notifications
1414

1515
### Changed
1616
- Small fixes

README.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,27 @@
1-
<div align="center">
2-
3-
<a href="https://github.com/aceberg/WatchYourLAN">
4-
<img src="https://raw.githubusercontent.com/aceberg/WatchYourLAN/main/assets/logo.png" width="200" />
5-
</a>
6-
</div>
1+
<h1><a href="https://github.com/aceberg/WatchYourLAN">
2+
<img src="https://raw.githubusercontent.com/aceberg/WatchYourLAN/main/assets/logo.png" width="20" />
3+
</a>WatchYourLAN</h1>
74
<br/>
85

9-
# WatchYourLAN
10-
116
[![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)
127
[![Go Report Card](https://goreportcard.com/badge/github.com/aceberg/WatchYourLAN)](https://goreportcard.com/report/github.com/aceberg/WatchYourLAN)
138
[![Maintainability](https://api.codeclimate.com/v1/badges/46b17f99edc1726b5d7d/maintainability)](https://codeclimate.com/github/aceberg/WatchYourLAN/maintainability)
149
![Docker Image Size (latest semver)](https://img.shields.io/docker/image-size/aceberg/watchyourlan)
1510
![Docker Pulls](https://img.shields.io/docker/pulls/aceberg/watchyourlan)
1611

17-
Lightweight network IP scanner with web GUI
18-
https://github.com/aceberg/WatchYourLAN
12+
Lightweight network IP scanner with web GUI https://github.com/aceberg/WatchYourLAN
13+
14+
- [Quick start](https://github.com/aceberg/WatchYourLAN#quick-start)
15+
- [Config](https://github.com/aceberg/WatchYourLAN#config)
16+
- [Config file](https://github.com/aceberg/WatchYourLAN#config-file)
17+
- [Options](https://github.com/aceberg/WatchYourLAN#options)
18+
- [Thanks](https://github.com/aceberg/WatchYourLAN#thanks)
1919

2020
![Screenshot_v0.6](https://raw.githubusercontent.com/aceberg/WatchYourLAN/main/assets/Screenshot_v0.6.png)
2121

2222
## Quick start
2323

24-
Replace `$YOURTIMEZONE` with correct time zone and `$YOURIFACE` with network interface you want to scan. Network mode must be `host`.
25-
26-
```sh
27-
docker run --name wyl \
28-
-e "IFACE=$YOURIFACE" \
29-
-e "TZ=$YOURTIMEZONE" \
30-
--network="host" \
31-
aceberg/watchyourlan
32-
```
33-
34-
Set `$DOCKERDATAPATH` for container to save data:
24+
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:
3525

3626
```sh
3727
docker run --name wyl \
@@ -71,8 +61,15 @@ GUIPORT="8840"
7161
TIMEOUT="300" # 5 minutes
7262
SHOUTRRR_URL="gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes" # Url to notify
7363
THEME="darkly"
64+
IGNOREIP="no"
7465
```
7566

67+
## Options
68+
69+
| Key | Description | Default |
70+
| -------- | ----------- | ------- |
71+
| -c | Path to config file | /data/config |
72+
7673
## Thanks
7774
- All go packages listed in [dependencies](https://github.com/aceberg/WatchYourLAN/network/dependencies)
7875
- Favicon and logo: [Access point icons created by Freepik - Flaticon](https://www.flaticon.com/free-icons/access-point)

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ services:
1414
GUIPORT: "8840" # optional, default: 8840
1515
TIMEOUT: "120" # optional, time in seconds, default: 60
1616
SHOUTRRR_URL: "" # optional, set url to notify
17-
THEME: "darkly" # optional
17+
THEME: "darkly" # optional
18+
IGNOREIP: "no" # optional

internal/web/config.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/aceberg/WatchYourLAN/internal/conf"
1313
"github.com/aceberg/WatchYourLAN/internal/db"
1414
"github.com/aceberg/WatchYourLAN/internal/models"
15+
"github.com/aceberg/WatchYourLAN/internal/notify"
1516
"github.com/aceberg/WatchYourLAN/internal/scan"
1617
)
1718

@@ -63,6 +64,8 @@ func saveConfigHandler(w http.ResponseWriter, r *http.Request) {
6364

6465
conf.Write(ConfigPath, AppConfig)
6566

67+
log.Println("INFO: writing new config")
68+
6669
QuitScan = make(chan bool)
6770
go scan.Start(AppConfig, QuitScan)
6871

@@ -77,3 +80,13 @@ func clearHandler(w http.ResponseWriter, r *http.Request) {
7780

7881
http.Redirect(w, r, r.Header.Get("Referer"), 302)
7982
}
83+
84+
func testNotifyHandler(w http.ResponseWriter, r *http.Request) {
85+
86+
log.Println("INFO: Test notification send")
87+
88+
msg := "Test notification"
89+
notify.Shoutrrr(msg, AppConfig.ShoutURL)
90+
91+
http.Redirect(w, r, r.Header.Get("Referer"), 302)
92+
}

internal/web/templates/config.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
</tr>
2929
<tr>
3030
<td>Shoutrrr URL</td>
31-
<td><input name="shout" type="text" class="form-control" value="{{ .Config.ShoutURL }}"></td>
31+
<td>
32+
<textarea name="shout" class="form-control" style="width: 100%;" rows="3" wrap="soft">{{ .Config.ShoutURL }}</textarea>
33+
</td>
3234
</tr>
3335
<tr>
3436
<td>Theme</td>
@@ -51,9 +53,11 @@
5153
</tr>
5254
<tr>
5355
<td><button type="submit" class="btn btn-primary">Save</button></td>
54-
<td></td>
55-
</tr>
5656
</form>
57+
<td>
58+
<a href="/test_notify/"><button style="float: right;" class="btn btn-success">Test notification</button></a>
59+
</td>
60+
</tr>
5761
</table>
5862
</div>
5963
<div class="col">
@@ -64,7 +68,7 @@
6468
<div class="alert alert-info" role="alert">
6569
<p>● There can be one or more <b>Interfaces</b>, space separated</p>
6670
<p>● After changing <b>Host</b>, <b>Port</b> or <b>Path to DB</b> you need to restart the app</p>
67-
<p><b>Timeout</b> means time between scans</p>
71+
<p><b>Timeout</b> means time between scans (in seconds)</p>
6872
<p><b>Shoutrrr URL</b> provides notifications to Discord, Email, Gotify, Telegram and other services. <a href="https://containrrr.dev/shoutrrr/v0.5/services/overview/" target="_blank">Link to documentation</a></p>
6973
<p>● If you want to detect unknown hosts by MAC only, set <b>Ignore IP</b> to "yes"</p>
7074
<p>● The <b>Clear table</b> button below will delete all records from table. If you want to delete a single host, click on its MAC and press <b>Delete host</b> button</p>

internal/web/webgui.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func Gui(configPath, bootPath string) {
4949
http.HandleFunc("/save_config/", saveConfigHandler)
5050
http.HandleFunc("/search_hosts/", searchHandler)
5151
http.HandleFunc("/sort_hosts/", sortHandler)
52+
http.HandleFunc("/test_notify/", testNotifyHandler)
5253
http.HandleFunc("/update_host/", updateHandler)
5354
err := http.ListenAndServe(address, nil)
5455
check.IfError(err)

0 commit comments

Comments
 (0)