Browse Source

Fix for context with empty content

Shelikhoo 4 years ago
parent
commit
616b0d122e
2 changed files with 7 additions and 1 deletions
  1. 1 1
      app/proxyman/outbound/handler.go
  2. 6 0
      common/session/context.go

+ 1 - 1
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
 		tag := h.senderSettings.ProxySettings.Tag
 		newError("transport layer proxying to ", tag, " for dest ", dest).AtDebug().WriteToLog(session.ExportIDToError(ctx))
 		newError("transport layer proxying to ", tag, " for dest ", dest).AtDebug().WriteToLog(session.ExportIDToError(ctx))
 		session.SetTransportLayerProxyTagToContext(ctx, tag)
 		session.SetTransportLayerProxyTagToContext(ctx, tag)

+ 6 - 0
common/session/context.go

@@ -86,6 +86,9 @@ func SockoptFromContext(ctx context.Context) *Sockopt {
 }
 }
 
 
 func GetTransportLayerProxyTagFromContext(ctx context.Context) string {
 func GetTransportLayerProxyTagFromContext(ctx context.Context) string {
+	if ContentFromContext(ctx) == nil {
+		return ""
+	}
 	return ContentFromContext(ctx).Attribute("transportLayerOutgoingTag")
 	return ContentFromContext(ctx).Attribute("transportLayerOutgoingTag")
 }
 }
 
 
@@ -94,6 +97,9 @@ func SetTransportLayerProxyTagToContext(ctx context.Context, tag string) {
 }
 }
 
 
 func GetForcedOutboundTagFromContext(ctx context.Context) string {
 func GetForcedOutboundTagFromContext(ctx context.Context) string {
+	if ContentFromContext(ctx) == nil {
+		return ""
+	}
 	return ContentFromContext(ctx).Attribute("forcedOutboundTag")
 	return ContentFromContext(ctx).Attribute("forcedOutboundTag")
 }
 }