mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-07-29 08:52:51 -04:00
feat: add ping privileged env UPSNAP_PING_PRIVILEGED #207
This commit is contained in:
@@ -2,8 +2,10 @@ package networking
|
||||
|
||||
import (
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
@@ -21,7 +23,11 @@ func PingDevice(device *models.Record) bool {
|
||||
}
|
||||
pinger.Count = 1
|
||||
pinger.Timeout = 500 * time.Millisecond
|
||||
pinger.SetPrivileged(true)
|
||||
privileged, err := strconv.ParseBool(os.Getenv("UPSNAP_PING_PRIVILEGED"))
|
||||
if err != nil {
|
||||
privileged = true
|
||||
}
|
||||
pinger.SetPrivileged(privileged)
|
||||
err = pinger.Run()
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
|
||||
@@ -14,6 +14,7 @@ services:
|
||||
# - UPSNAP_INTERVAL=@every 10s # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
|
||||
# - UPSNAP_SCAN_TIMEOUT=500ms # Scan timeout is nmap's --host-timeout value to wait for devices (https://nmap.org/book/man-performance.html)
|
||||
# - UPSNAP_PING_PRIVILEGED=true # Set to false if you don't have root user permissions
|
||||
# - UPSNAP_WEBSITE_TITLE=Custom name # Custom website title
|
||||
# # dns is used for name resolution during network scan
|
||||
# dns:
|
||||
|
||||
Reference in New Issue
Block a user