aceberg / WatchYourLAN

Lightweight network IP scanner with web GUI
https://hub.docker.com/r/aceberg/watchyourlan
MIT License
1.24k stars 55 forks source link

Bug/crash attempting to sort by 'known' #70

Closed andrewlow closed 6 months ago

andrewlow commented 6 months ago

When running in a docker container

docker run --name wyl \
    -e "IFACE=$YOURIFACE" \
    -e "TZ=$YOURTIMEZONE" \
    --network="host" \
    -v $DOCKERDATAPATH/wyl:/data \
    aceberg/watchyourlan -n "http://$YOUR_IP:8850"

And $YOUR_IP is 192.168.0.140 ..

Visiting the dashboard http://192.168.0.140:8840/line/?state=on

Clicking on either of the up/down arrows under the 'Known' column will trigger a crash

image

2024/01/05 10:39:46 http: panic serving 192.168.0.221:59606: reflect: call of reflect.Value.Uint on int Value
goroutine 546 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go/src/net/http/server.go:1868 +0xb9
panic({0xa7fea0?, 0xc0000ab848?})
        /usr/local/go/src/runtime/panic.go:920 +0x270
reflect.Value.Uint(...)
        /usr/local/go/src/reflect/value.go:2692
github.com/aceberg/WatchYourLAN/internal/web.sortByField({0xb0dbf5, 0x4}, {0xb0e37c, 0x5})
        /src/internal/web/sort.go:94 +0x792
github.com/aceberg/WatchYourLAN/internal/web.sortHandler({0xc180e0, 0xc00006c0e0}, 0xc0000ea500)
        /src/internal/web/sort.go:73 +0x30a
net/http.HandlerFunc.ServeHTTP(0x105ca80?, {0xc180e0?, 0xc00006c0e0?}, 0x4d87a5?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/aceberg/WatchYourLAN/internal/web.Gui.Auth.func16({0xc180e0?, 0xc00006c0e0?}, 0x6cc8ed?)
        /src/internal/auth/auth.go:13 +0x21d
net/http.HandlerFunc.ServeHTTP(0x10?, {0xc180e0?, 0xc00006c0e0?}, 0xc00029ae6c?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
net/http.(*ServeMux).ServeHTTP(0x410585?, {0xc180e0, 0xc00006c0e0}, 0xc0000ea500)
        /usr/local/go/src/net/http/server.go:2514 +0x142
net/http.serverHandler.ServeHTTP({0xc16bd8?}, {0xc180e0?, 0xc00006c0e0?}, 0x6?)
        /usr/local/go/src/net/http/server.go:2938 +0x8e
net/http.(*conn).serve(0xc0000ce090, {0xc19010, 0xc000158600})
        /usr/local/go/src/net/http/server.go:2009 +0x5f4
created by net/http.(*Server).Serve in goroutine 1
        /usr/local/go/src/net/http/server.go:3086 +0x5cb
2024/01/05 10:39:46 http: panic serving 192.168.0.221:59636: reflect: call of reflect.Value.Uint on int Value
goroutine 578 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go/src/net/http/server.go:1868 +0xb9
panic({0xa7fea0?, 0xc0000ab8a8?})
        /usr/local/go/src/runtime/panic.go:920 +0x270
reflect.Value.Uint(...)
        /usr/local/go/src/reflect/value.go:2692
github.com/aceberg/WatchYourLAN/internal/web.sortByField({0xb0dbf5, 0x4}, {0xb0e37c, 0x5})
        /src/internal/web/sort.go:94 +0x792
github.com/aceberg/WatchYourLAN/internal/web.sortHandler({0xc180e0, 0xc00006c1c0}, 0xc0000ea600)
        /src/internal/web/sort.go:73 +0x30a
net/http.HandlerFunc.ServeHTTP(0x105ca80?, {0xc180e0?, 0xc00006c1c0?}, 0x5109a4?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/aceberg/WatchYourLAN/internal/web.Gui.Auth.func16({0xc180e0?, 0xc00006c1c0?}, 0x6cc8ed?)
        /src/internal/auth/auth.go:13 +0x21d
net/http.HandlerFunc.ServeHTTP(0x10?, {0xc180e0?, 0xc00006c1c0?}, 0xc00029aeec?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
net/http.(*ServeMux).ServeHTTP(0x410585?, {0xc180e0, 0xc00006c1c0}, 0xc0000ea600)
        /usr/local/go/src/net/http/server.go:2514 +0x142
net/http.serverHandler.ServeHTTP({0xc16bd8?}, {0xc180e0?, 0xc00006c1c0?}, 0x6?)
        /usr/local/go/src/net/http/server.go:2938 +0x8e
net/http.(*conn).serve(0xc0000cea20, {0xc19010, 0xc000158600})
        /usr/local/go/src/net/http/server.go:2009 +0x5f4
created by net/http.(*Server).Serve in goroutine 1
        /usr/local/go/src/net/http/server.go:3086 +0x5cb
aceberg commented 6 months ago

Thanks for letting me know! Fixed.