From 616b0d122efeab8704b7e964c36d9e939104b55f Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Sun, 28 Feb 2021 20:42:32 +0000 Subject: [PATCH] Fix for context with empty content --- app/proxyman/outbound/handler.go | 2 +- common/session/context.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 66477c2d4..46c564630 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -196,7 +196,7 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn } } - if h.senderSettings.ProxySettings.HasTag() && h.senderSettings.ProxySettings.TransportLayerProxy { + if h.senderSettings != nil && h.senderSettings.ProxySettings != nil && h.senderSettings.ProxySettings.HasTag() && h.senderSettings.ProxySettings.TransportLayerProxy { tag := h.senderSettings.ProxySettings.Tag newError("transport layer proxying to ", tag, " for dest ", dest).AtDebug().WriteToLog(session.ExportIDToError(ctx)) session.SetTransportLayerProxyTagToContext(ctx, tag) diff --git a/common/session/context.go b/common/session/context.go index 116c52a90..8fdb01fa6 100644 --- a/common/session/context.go +++ b/common/session/context.go @@ -86,6 +86,9 @@ func SockoptFromContext(ctx context.Context) *Sockopt { } func GetTransportLayerProxyTagFromContext(ctx context.Context) string { + if ContentFromContext(ctx) == nil { + return "" + } return ContentFromContext(ctx).Attribute("transportLayerOutgoingTag") } @@ -94,6 +97,9 @@ func SetTransportLayerProxyTagToContext(ctx context.Context, tag string) { } func GetForcedOutboundTagFromContext(ctx context.Context) string { + if ContentFromContext(ctx) == nil { + return "" + } return ContentFromContext(ctx).Attribute("forcedOutboundTag") }