Refactor code for improved readability and maintainability; add utility functions for score calculation and archive processing

This commit is contained in:
ProtoTess
2026-01-16 05:55:37 +00:00
parent c701115620
commit 268330840c
10 changed files with 208 additions and 146 deletions
+7 -4
View File
@@ -11,14 +11,13 @@ import (
"github.com/0x524a/onvif-go/discovery"
)
const defaultDiscoveryTimeout = 10 * time.Second
func main() {
iface := flag.String("interface", "", "Network interface to use (e.g., en0, en11)")
timeout := flag.Duration("timeout", 10*time.Second, "Discovery timeout")
timeout := flag.Duration("timeout", defaultDiscoveryTimeout, "Discovery timeout")
flag.Parse()
ctx, cancel := context.WithTimeout(context.Background(), *timeout)
defer cancel()
opts := &discovery.DiscoverOptions{
NetworkInterface: *iface,
}
@@ -29,9 +28,13 @@ func main() {
}
fmt.Println("...")
ctx, cancel := context.WithTimeout(context.Background(), *timeout)
defer cancel()
devices, err := discovery.DiscoverWithOptions(ctx, *timeout, opts)
if err != nil {
fmt.Fprintf(os.Stderr, "Discovery error: %v\n", err)
cancel()
os.Exit(1)
}