parent
0acd987313
commit
64a4b17a8f
9 changed files with 52 additions and 23 deletions
|
|
@ -2,6 +2,10 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [v1.0.4] - 2023-10-12
|
||||||
|
### Added
|
||||||
|
- Configurable `timeout` for `arp-scan` [#65](https://github.com/aceberg/WatchYourLAN/issues/65)
|
||||||
|
|
||||||
## [v1.0.3] - 2023-10-08
|
## [v1.0.3] - 2023-10-08
|
||||||
### Fixed
|
### Fixed
|
||||||
- Github Action workflow for binary release
|
- Github Action workflow for binary release
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ Configuration can be done through config file or environment variables
|
||||||
|
|
||||||
| Variable | Description | Default |
|
| Variable | Description | Default |
|
||||||
| -------- | ----------- | ------- |
|
| -------- | ----------- | ------- |
|
||||||
|
| ARP_TIMEOUT | Per host timeout for <b>arp-scan</b> (in milliseconds) | 500 |
|
||||||
| AUTH | Enable Session-Cookie authentication | false |
|
| AUTH | Enable Session-Cookie authentication | false |
|
||||||
| AUTH_EXPIRE | Session expiration time. A number and suffix: **m, h, d** or **M**. | 7d |
|
| AUTH_EXPIRE | Session expiration time. A number and suffix: **m, h, d** or **M**. | 7d |
|
||||||
| AUTH_USER | Username | "" |
|
| AUTH_USER | Username | "" |
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,12 @@ func Get(path string) (config models.Conf, authConf auth.Conf) {
|
||||||
viper.SetDefault("COLOR", "light")
|
viper.SetDefault("COLOR", "light")
|
||||||
viper.SetDefault("IGNOREIP", "no")
|
viper.SetDefault("IGNOREIP", "no")
|
||||||
viper.SetDefault("LOGLEVEL", "verbose")
|
viper.SetDefault("LOGLEVEL", "verbose")
|
||||||
|
viper.SetDefault("HISTORY_DAYS", "30")
|
||||||
|
viper.SetDefault("ARP_TIMEOUT", "500")
|
||||||
|
|
||||||
viper.SetDefault("AUTH_USER", "")
|
viper.SetDefault("AUTH_USER", "")
|
||||||
viper.SetDefault("AUTH_PASSWORD", "")
|
viper.SetDefault("AUTH_PASSWORD", "")
|
||||||
viper.SetDefault("AUTH_EXPIRE", "7d")
|
viper.SetDefault("AUTH_EXPIRE", "7d")
|
||||||
viper.SetDefault("HISTORY_DAYS", "30")
|
|
||||||
|
|
||||||
viper.SetConfigFile(path)
|
viper.SetConfigFile(path)
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
|
|
@ -44,6 +46,8 @@ func Get(path string) (config models.Conf, authConf auth.Conf) {
|
||||||
config.IgnoreIP = viper.Get("IGNOREIP").(string)
|
config.IgnoreIP = viper.Get("IGNOREIP").(string)
|
||||||
config.LogLevel = viper.Get("LOGLEVEL").(string)
|
config.LogLevel = viper.Get("LOGLEVEL").(string)
|
||||||
config.HistDays = viper.Get("HISTORY_DAYS").(string)
|
config.HistDays = viper.Get("HISTORY_DAYS").(string)
|
||||||
|
config.ArpTimeout = viper.Get("ARP_TIMEOUT").(string)
|
||||||
|
|
||||||
authConf.Auth = viper.GetBool("AUTH")
|
authConf.Auth = viper.GetBool("AUTH")
|
||||||
authConf.User, _ = viper.Get("AUTH_USER").(string)
|
authConf.User, _ = viper.Get("AUTH_USER").(string)
|
||||||
authConf.Password, _ = viper.Get("AUTH_PASSWORD").(string)
|
authConf.Password, _ = viper.Get("AUTH_PASSWORD").(string)
|
||||||
|
|
@ -72,6 +76,7 @@ func Write(path string, config models.Conf, authConf auth.Conf) {
|
||||||
viper.Set("IGNOREIP", config.IgnoreIP)
|
viper.Set("IGNOREIP", config.IgnoreIP)
|
||||||
viper.Set("LOGLEVEL", config.LogLevel)
|
viper.Set("LOGLEVEL", config.LogLevel)
|
||||||
viper.Set("HISTORY_DAYS", config.HistDays)
|
viper.Set("HISTORY_DAYS", config.HistDays)
|
||||||
|
viper.Set("ARP_TIMEOUT", config.ArpTimeout)
|
||||||
|
|
||||||
viper.Set("auth", authConf.Auth)
|
viper.Set("auth", authConf.Auth)
|
||||||
viper.Set("auth_user", authConf.User)
|
viper.Set("auth_user", authConf.User)
|
||||||
|
|
|
||||||
|
|
@ -6,20 +6,21 @@ import (
|
||||||
|
|
||||||
// Conf - app config
|
// Conf - app config
|
||||||
type Conf struct {
|
type Conf struct {
|
||||||
Iface string
|
Iface string
|
||||||
DbPath string
|
DbPath string
|
||||||
GuiIP string
|
GuiIP string
|
||||||
GuiPort string
|
GuiPort string
|
||||||
Timeout int
|
Timeout int
|
||||||
ShoutURL string
|
ShoutURL string
|
||||||
Theme string
|
Theme string
|
||||||
Color string
|
Color string
|
||||||
IgnoreIP string
|
IgnoreIP string
|
||||||
LogLevel string
|
LogLevel string
|
||||||
NodePath string
|
NodePath string
|
||||||
Icon string
|
Icon string
|
||||||
Auth bool
|
Auth bool
|
||||||
HistDays string
|
HistDays string
|
||||||
|
ArpTimeout string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Host - one host
|
// Host - one host
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func scanIface(iface string) string {
|
func scanIface(iface string) string {
|
||||||
cmd, err := exec.Command("arp-scan", "-glNx", "-I", iface).Output()
|
cmd, err := exec.Command("arp-scan", "-glNx", "-t", appConfig.ArpTimeout, "-I", iface).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return string("")
|
return string("")
|
||||||
}
|
}
|
||||||
|
|
@ -40,15 +40,15 @@ func parseOutput(text string) []models.Host {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan all interfaces
|
// Scan all interfaces
|
||||||
func arpScan(allIfaces string, logLevel string) []models.Host {
|
func arpScan() []models.Host {
|
||||||
var text string
|
var text string
|
||||||
var foundHosts = []models.Host{}
|
var foundHosts = []models.Host{}
|
||||||
|
|
||||||
perString := strings.Split(allIfaces, " ")
|
perString := strings.Split(appConfig.Iface, " ")
|
||||||
|
|
||||||
for _, iface := range perString {
|
for _, iface := range perString {
|
||||||
text = scanIface(iface)
|
text = scanIface(iface)
|
||||||
if logLevel != "short" {
|
if appConfig.LogLevel != "short" {
|
||||||
log.Println("INFO: scanning interface", iface)
|
log.Println("INFO: scanning interface", iface)
|
||||||
log.Println("INFO: found IPs:", text)
|
log.Println("INFO: found IPs:", text)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ func Start(config models.Conf, quit chan bool) {
|
||||||
plusDate := lastDate.Add(time.Duration(appConfig.Timeout) * time.Second)
|
plusDate := lastDate.Add(time.Duration(appConfig.Timeout) * time.Second)
|
||||||
|
|
||||||
if nowDate.After(plusDate) {
|
if nowDate.After(plusDate) {
|
||||||
structHosts = arpScan(appConfig.Iface, appConfig.LogLevel) // arpscan.go
|
structHosts = arpScan() // arpscan.go
|
||||||
dbHosts = db.Select(appConfig.DbPath)
|
dbHosts = db.Select(appConfig.DbPath)
|
||||||
|
|
||||||
toMap()
|
toMap()
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ func saveConfigHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
AppConfig.IgnoreIP = r.FormValue("ignoreip")
|
AppConfig.IgnoreIP = r.FormValue("ignoreip")
|
||||||
AppConfig.LogLevel = r.FormValue("loglevel")
|
AppConfig.LogLevel = r.FormValue("loglevel")
|
||||||
AppConfig.HistDays = r.FormValue("history")
|
AppConfig.HistDays = r.FormValue("history")
|
||||||
|
AppConfig.ArpTimeout = r.FormValue("arp_timeout")
|
||||||
|
|
||||||
timeout := r.FormValue("timeout")
|
timeout := r.FormValue("timeout")
|
||||||
AppConfig.Timeout, err = strconv.Atoi(timeout)
|
AppConfig.Timeout, err = strconv.Atoi(timeout)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Timeout (seconds)</td>
|
<td>Timeout (seconds)</td>
|
||||||
<td><input name="timeout" type="text" class="form-control" value="{{ .Config.Timeout }}"></td>
|
<td><input name="timeout" type="number" class="form-control" value="{{ .Config.Timeout }}"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Shoutrrr URL</td>
|
<td>Shoutrrr URL</td>
|
||||||
|
|
@ -71,7 +71,23 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Keep history (days)</td>
|
<td>Keep history (days)</td>
|
||||||
<td><input name="history" type="text" class="form-control" value="{{ .Config.HistDays }}"></td>
|
<td><input name="history" type="number" class="form-control" value="{{ .Config.HistDays }}"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Arp Timeout</td>
|
||||||
|
<td>
|
||||||
|
<select name="arp_timeout" class="form-select">
|
||||||
|
<option selected value="{{ .Config.ArpTimeout }}">{{ .Config.ArpTimeout }}</option>
|
||||||
|
<option value="100">100</option>
|
||||||
|
<option value="250">250</option>
|
||||||
|
<option value="500">500</option>
|
||||||
|
<option value="1000">1000</option>
|
||||||
|
<option value="1500">1500</option>
|
||||||
|
<option value="2000">2000</option>
|
||||||
|
<option value="3000">3000</option>
|
||||||
|
<option value="5000">5000</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><button type="submit" class="btn btn-primary">Save</button></td>
|
<td><button type="submit" class="btn btn-primary">Save</button></td>
|
||||||
|
|
@ -92,6 +108,7 @@
|
||||||
<p>● If you want to detect unknown hosts by MAC only, set <b>Ignore IP</b> to "yes"</p>
|
<p>● If you want to detect unknown hosts by MAC only, set <b>Ignore IP</b> to "yes"</p>
|
||||||
<p>● <b>Log Level</b> defines how much log output you want to see</p>
|
<p>● <b>Log Level</b> defines how much log output you want to see</p>
|
||||||
<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>
|
<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>
|
||||||
|
<p>● <b>Arp Timeout</b> per host timeout for <b>arp-scan</b> (in milliseconds). Default: 500</p>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<form action="/clear/" method="post">
|
<form action="/clear/" method="post">
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
VERSION=1.0.3
|
VERSION=1.0.4
|
||||||
Loading…
Reference in a new issue