added input sanitization

This commit is contained in:
marko
2024-10-03 16:19:54 +02:00
parent d928a681f9
commit 97e41eece0
4 changed files with 104 additions and 94 deletions

View File

@@ -7,7 +7,7 @@ import (
"sync"
)
func Run() int {
func PingLocal255() int {
localIP, err := getLocalIP()
if err != nil {
fmt.Println("Error getting local IP:", err)
@@ -15,7 +15,7 @@ func Run() int {
}
network := getNetworkPrefix(localIP)
var wg sync.WaitGroup
deviceCount := 0
mu := &sync.Mutex{}
@@ -56,13 +56,12 @@ func getNetworkPrefix(ip net.IP) string {
return fmt.Sprintf("%d.%d.%d.0", ip[0], ip[1], ip[2])
}
func ping(ip string) bool {
output, err := exec.Command("ping", "-c", "1", "-W", "1", ip).CombinedOutput()
if err != nil {
return false
}
_ = output
return true
}
output, err := exec.Command("ping", "-c", "1", "-W", "1", ip).CombinedOutput()
if err != nil {
return false
}
_ = output
return true
}