parent
0acd987313
commit
64a4b17a8f
9 changed files with 52 additions and 23 deletions
|
|
@ -2,6 +2,10 @@
|
|||
# Change Log
|
||||
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
|
||||
### Fixed
|
||||
- Github Action workflow for binary release
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ Configuration can be done through config file or environment variables
|
|||
|
||||
| Variable | Description | Default |
|
||||
| -------- | ----------- | ------- |
|
||||
| ARP_TIMEOUT | Per host timeout for <b>arp-scan</b> (in milliseconds) | 500 |
|
||||
| AUTH | Enable Session-Cookie authentication | false |
|
||||
| AUTH_EXPIRE | Session expiration time. A number and suffix: **m, h, d** or **M**. | 7d |
|
||||
| AUTH_USER | Username | "" |
|
||||
|
|
|
|||
|
|
@ -21,10 +21,12 @@ func Get(path string) (config models.Conf, authConf auth.Conf) {
|
|||
viper.SetDefault("COLOR", "light")
|
||||
viper.SetDefault("IGNOREIP", "no")
|
||||
viper.SetDefault("LOGLEVEL", "verbose")
|
||||
viper.SetDefault("HISTORY_DAYS", "30")
|
||||
viper.SetDefault("ARP_TIMEOUT", "500")
|
||||
|
||||
viper.SetDefault("AUTH_USER", "")
|
||||
viper.SetDefault("AUTH_PASSWORD", "")
|
||||
viper.SetDefault("AUTH_EXPIRE", "7d")
|
||||
viper.SetDefault("HISTORY_DAYS", "30")
|
||||
|
||||
viper.SetConfigFile(path)
|
||||
viper.SetConfigType("yaml")
|
||||
|
|
@ -44,6 +46,8 @@ func Get(path string) (config models.Conf, authConf auth.Conf) {
|
|||
config.IgnoreIP = viper.Get("IGNOREIP").(string)
|
||||
config.LogLevel = viper.Get("LOGLEVEL").(string)
|
||||
config.HistDays = viper.Get("HISTORY_DAYS").(string)
|
||||
config.ArpTimeout = viper.Get("ARP_TIMEOUT").(string)
|
||||
|
||||
authConf.Auth = viper.GetBool("AUTH")
|
||||
authConf.User, _ = viper.Get("AUTH_USER").(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("LOGLEVEL", config.LogLevel)
|
||||
viper.Set("HISTORY_DAYS", config.HistDays)
|
||||
viper.Set("ARP_TIMEOUT", config.ArpTimeout)
|
||||
|
||||
viper.Set("auth", authConf.Auth)
|
||||
viper.Set("auth_user", authConf.User)
|
||||
|
|
|
|||
|
|
@ -6,20 +6,21 @@ import (
|
|||
|
||||
// Conf - app config
|
||||
type Conf struct {
|
||||
Iface string
|
||||
DbPath string
|
||||
GuiIP string
|
||||
GuiPort string
|
||||
Timeout int
|
||||
ShoutURL string
|
||||
Theme string
|
||||
Color string
|
||||
IgnoreIP string
|
||||
LogLevel string
|
||||
NodePath string
|
||||
Icon string
|
||||
Auth bool
|
||||
HistDays string
|
||||
Iface string
|
||||
DbPath string
|
||||
GuiIP string
|
||||
GuiPort string
|
||||
Timeout int
|
||||
ShoutURL string
|
||||
Theme string
|
||||
Color string
|
||||
IgnoreIP string
|
||||
LogLevel string
|
||||
NodePath string
|
||||
Icon string
|
||||
Auth bool
|
||||
HistDays string
|
||||
ArpTimeout string
|
||||
}
|
||||
|
||||
// Host - one host
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
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 {
|
||||
return string("")
|
||||
}
|
||||
|
|
@ -40,15 +40,15 @@ func parseOutput(text string) []models.Host {
|
|||
}
|
||||
|
||||
// Scan all interfaces
|
||||
func arpScan(allIfaces string, logLevel string) []models.Host {
|
||||
func arpScan() []models.Host {
|
||||
var text string
|
||||
var foundHosts = []models.Host{}
|
||||
|
||||
perString := strings.Split(allIfaces, " ")
|
||||
perString := strings.Split(appConfig.Iface, " ")
|
||||
|
||||
for _, iface := range perString {
|
||||
text = scanIface(iface)
|
||||
if logLevel != "short" {
|
||||
if appConfig.LogLevel != "short" {
|
||||
log.Println("INFO: scanning interface", iface)
|
||||
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)
|
||||
|
||||
if nowDate.After(plusDate) {
|
||||
structHosts = arpScan(appConfig.Iface, appConfig.LogLevel) // arpscan.go
|
||||
structHosts = arpScan() // arpscan.go
|
||||
dbHosts = db.Select(appConfig.DbPath)
|
||||
|
||||
toMap()
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ func saveConfigHandler(w http.ResponseWriter, r *http.Request) {
|
|||
AppConfig.IgnoreIP = r.FormValue("ignoreip")
|
||||
AppConfig.LogLevel = r.FormValue("loglevel")
|
||||
AppConfig.HistDays = r.FormValue("history")
|
||||
AppConfig.ArpTimeout = r.FormValue("arp_timeout")
|
||||
|
||||
timeout := r.FormValue("timeout")
|
||||
AppConfig.Timeout, err = strconv.Atoi(timeout)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
<td>Shoutrrr URL</td>
|
||||
|
|
@ -71,7 +71,23 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
<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>● <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>● <b>Arp Timeout</b> per host timeout for <b>arp-scan</b> (in milliseconds). Default: 500</p>
|
||||
</div>
|
||||
<br>
|
||||
<form action="/clear/" method="post">
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
VERSION=1.0.3
|
||||
VERSION=1.0.4
|
||||
Loading…
Reference in a new issue