diff --git a/inbound/naive.go b/inbound/naive.go index d823ae02..101cc332 100644 --- a/inbound/naive.go +++ b/inbound/naive.go @@ -90,6 +90,9 @@ func (n *Naive) Start() error { n.httpServer = &http.Server{ Handler: n, TLSConfig: tlsConfig, + BaseContext: func(listener net.Listener) context.Context { + return n.ctx + }, } go func() { var sErr error diff --git a/transport/v2raygrpclite/server.go b/transport/v2raygrpclite/server.go index b9a1a0ce..86d7391b 100644 --- a/transport/v2raygrpclite/server.go +++ b/transport/v2raygrpclite/server.go @@ -51,6 +51,9 @@ func NewServer(ctx context.Context, options option.V2RayGRPCOptions, tlsConfig t } server.httpServer = &http.Server{ Handler: server, + BaseContext: func(net.Listener) context.Context { + return ctx + }, } server.h2cHandler = h2c.NewHandler(server, server.h2Server) return server, nil diff --git a/transport/v2rayhttp/server.go b/transport/v2rayhttp/server.go index 304836ec..962f0ab1 100644 --- a/transport/v2rayhttp/server.go +++ b/transport/v2rayhttp/server.go @@ -70,6 +70,9 @@ func NewServer(ctx context.Context, options option.V2RayHTTPOptions, tlsConfig t Handler: server, ReadHeaderTimeout: C.TCPTimeout, MaxHeaderBytes: http.DefaultMaxHeaderBytes, + BaseContext: func(net.Listener) context.Context { + return ctx + }, } server.h2cHandler = h2c.NewHandler(server, server.h2Server) return server, nil diff --git a/transport/v2raywebsocket/server.go b/transport/v2raywebsocket/server.go index b669bdd1..00eaaa11 100644 --- a/transport/v2raywebsocket/server.go +++ b/transport/v2raywebsocket/server.go @@ -53,6 +53,9 @@ func NewServer(ctx context.Context, options option.V2RayWebsocketOptions, tlsCon Handler: server, ReadHeaderTimeout: C.TCPTimeout, MaxHeaderBytes: http.DefaultMaxHeaderBytes, + BaseContext: func(net.Listener) context.Context { + return ctx + }, } return server, nil }