From 8e1adfae9aae3cbd61c41244db77c8cabd597176 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 22 Dec 2024 14:43:02 +0800 Subject: [PATCH] :bug: Fix user info not found panic --- pkg/internal/http/ws/ws.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/internal/http/ws/ws.go b/pkg/internal/http/ws/ws.go index a11dab3..d5ddd75 100644 --- a/pkg/internal/http/ws/ws.go +++ b/pkg/internal/http/ws/ws.go @@ -3,6 +3,7 @@ package ws import ( "context" "fmt" + "git.solsynth.dev/hypernet/nexus/pkg/internal/directory" "git.solsynth.dev/hypernet/nexus/pkg/nex" "git.solsynth.dev/hypernet/nexus/pkg/nex/sec" @@ -14,7 +15,11 @@ import ( ) func Listen(c *websocket.Conn) { - user := c.Locals("nex_user").(sec.UserInfo) + user, ok := c.Locals("nex_user").(sec.UserInfo) + if !ok { + c.Close() + return + } // Push connection clientId := ClientRegister(user, c)