nektro / mantle

📒 Easy and effective communication for any team or community.
Other
34 stars 4 forks source link

Runtime error on user-join #63

Closed PolygonError closed 4 years ago

PolygonError commented 4 years ago

User joined and mantle crashed immediately with the following image go version: go version go1.14 linux/amd64 go env:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ircd/.cache/go-build"
GOENV="/home/ircd/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ircd/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build341260966=/tmp/go-build -gno-record-gcc-switches"
nektro commented 4 years ago

Is this behavior consistent if you try logging in multiple times/refreshing the page on /chat/ ?

PolygonError commented 4 years ago

Is this behavior consistent if you try logging in multiple times/refreshing the page on /chat/ ?

Yes, refreshing /chat/ causes a consistent runtime error.

nektro commented 4 years ago

https://github.com/nektro/mantle/blob/master/pkg/ws/ws.go#L23

conn, _ := reqUpgrader.Upgrade(w, r, nil)

its crashing because for some reason the websocket request upgrader is failing and the resulting conn value is null. but i wasnt handling this error yet so it stores the value anyway. then shortly after when it goes to send the broadcast message that your user is now connected, the connection value is still null and trying to read a property off of null is what causes the panic

PolygonError commented 4 years ago

Yep, caused by Apache reverse proxy not passing web socket data correctly. Cheers.