From 2a6cad2f9bc829a1f621d6e204a8c6b4330e1cc4 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 15 Feb 2019 00:46:19 +0100 Subject: [PATCH] fix inbound user in dekodemo door and http --- proxy/dokodemo/dokodemo.go | 7 +++++++ proxy/http/server.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index d4302e39c..227585051 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -13,6 +13,7 @@ import ( "v2ray.com/core/common" "v2ray.com/core/common/buf" "v2ray.com/core/common/net" + "v2ray.com/core/common/protocol" "v2ray.com/core/common/session" "v2ray.com/core/common/signal" "v2ray.com/core/common/task" @@ -99,6 +100,12 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in return newError("unable to get destination") } + if inbound := session.InboundFromContext(ctx); inbound != nil { + inbound.User = &protocol.MemoryUser{ + Level: d.config.UserLevel, + } + } + plcy := d.policy() ctx, cancel := context.WithCancel(ctx) timer := signal.CancelAfterInactivity(ctx, cancel, plcy.Timeouts.ConnectionIdle) diff --git a/proxy/http/server.go b/proxy/http/server.go index ba3262bbe..1cedd9baa 100755 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -17,6 +17,7 @@ import ( "v2ray.com/core/common/errors" "v2ray.com/core/common/log" "v2ray.com/core/common/net" + "v2ray.com/core/common/protocol" http_proto "v2ray.com/core/common/protocol/http" "v2ray.com/core/common/session" "v2ray.com/core/common/signal" @@ -84,6 +85,12 @@ type readerOnly struct { } func (s *Server) Process(ctx context.Context, network net.Network, conn internet.Connection, dispatcher routing.Dispatcher) error { + if inbound := session.InboundFromContext(ctx); inbound != nil { + inbound.User = &protocol.MemoryUser{ + Level: s.config.UserLevel, + } + } + reader := bufio.NewReaderSize(readerOnly{conn}, buf.Size) Start: