Fix missing user context in packet connections

This commit is contained in:
世界 2023-11-23 23:01:45 +08:00
parent 09515f87e1
commit 077075e9b6
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 4 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package hysteria2
import (
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/auth"
E "github.com/sagernet/sing/common/exceptions"
M "github.com/sagernet/sing/common/metadata"
)
@ -37,7 +38,7 @@ func (s *serverSession[U]) handleUDPMessage(message *udpMessage) {
udpConn, loaded := s.udpConnMap[message.sessionID]
s.udpAccess.RUnlock()
if !loaded || common.Done(udpConn.ctx) {
udpConn = newUDPPacketConn(s.ctx, s.quicConn, func() {
udpConn = newUDPPacketConn(auth.ContextWithUser(s.ctx, s.authUser), s.quicConn, func() {
s.udpAccess.Lock()
delete(s.udpConnMap, message.sessionID)
s.udpAccess.Unlock()

View file

@ -2,6 +2,7 @@ package tuic
import (
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/auth"
E "github.com/sagernet/sing/common/exceptions"
M "github.com/sagernet/sing/common/metadata"
)
@ -55,7 +56,7 @@ func (s *serverSession[U]) handleUDPMessage(message *udpMessage, udpStream bool)
udpConn, loaded := s.udpConnMap[message.sessionID]
s.udpAccess.RUnlock()
if !loaded || common.Done(udpConn.ctx) {
udpConn = newUDPPacketConn(s.ctx, s.quicConn, udpStream, true, func() {
udpConn = newUDPPacketConn(auth.ContextWithUser(s.ctx, s.authUser), s.quicConn, udpStream, true, func() {
s.udpAccess.Lock()
delete(s.udpConnMap, message.sessionID)
s.udpAccess.Unlock()