From c0ab2afcf4cdd9069bb06e942420cf42a81a3228 Mon Sep 17 00:00:00 2001 From: mountain Date: Fri, 15 Aug 2025 13:23:04 +0900 Subject: [PATCH] =?UTF-8?q?revoke=EB=90=9C=20=EC=84=B8=EC=85=98=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- session/common.go | 4 ---- session/impl_redis.go | 9 +++++++++ wshandler/wshandler.go | 10 ++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/session/common.go b/session/common.go index 72864fb..f06ae54 100644 --- a/session/common.go +++ b/session/common.go @@ -74,10 +74,6 @@ func make_storagekey(acc primitive.ObjectID) storagekey { return storagekey(acc.Hex() + hex.EncodeToString(bs[2:])) } -func AccountToSessionKey(acc primitive.ObjectID) string { - return string(make_storagekey(acc)) -} - func storagekey_to_publickey(sk storagekey) publickey { bs, _ := hex.DecodeString(string(sk)) diff --git a/session/impl_redis.go b/session/impl_redis.go index ad6aa49..edb1e64 100644 --- a/session/impl_redis.go +++ b/session/impl_redis.go @@ -257,6 +257,15 @@ func (c *consumer_redis) Query(pk string) (Authorization, error) { defer c.lock.Unlock() sk := publickey_to_storagekey(publickey(pk)) + + if _, deleted := c.stages[0].deleted[sk]; deleted { + return Authorization{}, nil + } + + if _, deleted := c.stages[1].deleted[sk]; deleted { + return Authorization{}, nil + } + si, err := c.query_internal(sk) if err != nil { logger.Println("session consumer query :", pk, err) diff --git a/wshandler/wshandler.go b/wshandler/wshandler.go index 1893831..263eaab 100644 --- a/wshandler/wshandler.go +++ b/wshandler/wshandler.go @@ -591,14 +591,8 @@ func (ws *WebsocketHandler) mainLoop(ctx context.Context) { } else if ws.sessionConsumer.IsRevoked(c.sender.Accid) { c.Conn.MakeWriter().WriteControl(websocket.CloseMessage, unauthdata, time.Time{}) } else { - sk := session.AccountToSessionKey(c.sender.Accid) - auth, _ := ws.sessionConsumer.Query(sk) - if auth.Account != c.sender.Accid { - c.Conn.MakeWriter().WriteControl(websocket.CloseMessage, unauthdata, time.Time{}) - } else { - entireConns[c.sender.Accid.Hex()] = c - go ws.ClientConnected(c) - } + entireConns[c.sender.Accid.Hex()] = c + go ws.ClientConnected(c) } case accid := <-ws.forceCloseChan: