Hysteria inbound: Use transport's authentication when there are no clients (#5942)

This commit is contained in:
LjhAUMEM
2026-04-15 20:13:15 +08:00
committed by GitHub
parent 5c3d639c09
commit ff6126463b
3 changed files with 9 additions and 19 deletions
+4 -15
View File
@@ -82,24 +82,13 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con
inbound := session.InboundFromContext(ctx)
inbound.Name = "hysteria"
inbound.CanSpliceCopy = 3
inbound.User = &protocol.MemoryUser{}
iConn := stat.TryUnwrapStatsConn(conn)
var useremail string
var userlevel uint32
type User interface{ User() *protocol.MemoryUser }
if v, ok := iConn.(User); ok {
if v, ok := iConn.(User); ok && v.User() != nil {
inbound.User = v.User()
if inbound.User != nil {
useremail = inbound.User.Email
userlevel = inbound.User.Level
}
} else {
// get a dummy user
inbound.User = &protocol.MemoryUser{
Email: "",
Level: 0,
}
}
if _, ok := iConn.(*hysteria.InterUdpConn); ok {
@@ -154,7 +143,7 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con
Writer: writer,
})
} else {
sessionPolicy := s.policyManager.ForLevel(userlevel)
sessionPolicy := s.policyManager.ForLevel(inbound.User.Level)
common.Must(conn.SetReadDeadline(time.Now().Add(sessionPolicy.Timeouts.Handshake)))
addr, err := ReadTCPRequest(conn)
@@ -178,7 +167,7 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con
To: dest,
Status: log.AccessAccepted,
Reason: "",
Email: useremail,
Email: inbound.User.Email,
})
errors.LogInfo(ctx, "tunnelling request to ", dest)