Refactor code for improved readability and maintainability; add utility functions for score calculation and archive processing
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user