瀏覽代碼

allow partial override in freedom

Darien Raymond 7 年之前
父節點
當前提交
b9db4514e2
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      proxy/freedom/freedom.go

+ 5 - 4
proxy/freedom/freedom.go

@@ -70,10 +70,11 @@ func (h *Handler) Process(ctx context.Context, link *core.Link, dialer proxy.Dia
 	destination, _ := proxy.TargetFromContext(ctx)
 	if h.config.DestinationOverride != nil {
 		server := h.config.DestinationOverride.Server
-		destination = net.Destination{
-			Network: destination.Network,
-			Address: server.Address.AsAddress(),
-			Port:    net.Port(server.Port),
+		if server.Address != nil {
+			destination.Address = server.Address.AsAddress()
+		}
+		if server.Port != 0 {
+			destination.Port = net.Port(server.Port)
 		}
 	}
 	newError("opening connection to ", destination).WriteToLog(session.ExportIDToError(ctx))