From c21595a937a9c8bbcc58cc18303d27685798cbf2 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 16 Sep 2022 21:54:37 -0400 Subject: [PATCH] Fix an issue with ss2022 generics --- proxy/shadowsocks_2022/inbound_multi.go | 6 ++++-- proxy/shadowsocks_2022/inbound_relay.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index cbc27e41..8b130e60 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -119,7 +119,8 @@ func (i *MultiUserInbound) Process(ctx context.Context, network net.Network, con func (i *MultiUserInbound) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error { inbound := session.InboundFromContext(ctx) - user, _ := A.UserFromContext[User](ctx) + userInt, _ := A.UserFromContext[int](ctx) + user := i.users[userInt] inbound.User = &protocol.MemoryUser{ Email: user.Email, Level: uint32(user.Level), @@ -146,7 +147,8 @@ func (i *MultiUserInbound) NewConnection(ctx context.Context, conn net.Conn, met func (i *MultiUserInbound) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata M.Metadata) error { inbound := session.InboundFromContext(ctx) - user, _ := A.UserFromContext[User](ctx) + userInt, _ := A.UserFromContext[int](ctx) + user := i.users[userInt] inbound.User = &protocol.MemoryUser{ Email: user.Email, Level: uint32(user.Level), diff --git a/proxy/shadowsocks_2022/inbound_relay.go b/proxy/shadowsocks_2022/inbound_relay.go index 000fe9f3..3e0043ee 100644 --- a/proxy/shadowsocks_2022/inbound_relay.go +++ b/proxy/shadowsocks_2022/inbound_relay.go @@ -120,7 +120,8 @@ func (i *RelayInbound) Process(ctx context.Context, network net.Network, connect func (i *RelayInbound) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error { inbound := session.InboundFromContext(ctx) - user, _ := A.UserFromContext[User](ctx) + userInt, _ := A.UserFromContext[int](ctx) + user := i.destinations[userInt] inbound.User = &protocol.MemoryUser{ Email: user.Email, Level: uint32(user.Level), @@ -147,7 +148,8 @@ func (i *RelayInbound) NewConnection(ctx context.Context, conn net.Conn, metadat func (i *RelayInbound) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata M.Metadata) error { inbound := session.InboundFromContext(ctx) - user, _ := A.UserFromContext[User](ctx) + userInt, _ := A.UserFromContext[int](ctx) + user := i.destinations[userInt] inbound.User = &protocol.MemoryUser{ Email: user.Email, Level: uint32(user.Level),