Przeglądaj źródła

Hysteria outbound: Fix ContextWithRequireDatagram() (#5558)

Fixes https://github.com/XTLS/Xray-core/pull/5549
LjhAUMEM 6 dni temu
rodzic
commit
a6aca101d6
2 zmienionych plików z 5 dodań i 5 usunięć
  1. 1 4
      proxy/hysteria/client.go
  2. 4 1
      proxy/hysteria/ctx/ctx.go

+ 1 - 4
proxy/hysteria/client.go

@@ -56,10 +56,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
 	ob.CanSpliceCopy = 3
 	target := ob.Target
 
-	if target.Network == net.Network_UDP {
-		hyCtx.ContextWithRequireDatagram(ctx)
-	}
-	conn, err := dialer.Dial(ctx, c.server.Destination)
+	conn, err := dialer.Dial(hyCtx.ContextWithRequireDatagram(ctx, target.Network == net.Network_UDP), c.server.Destination)
 	if err != nil {
 		return errors.New("failed to find an available destination").AtWarning().Base(err)
 	}

+ 4 - 1
proxy/hysteria/ctx/ctx.go

@@ -10,7 +10,10 @@ const (
 	requireDatagram key = iota
 )
 
-func ContextWithRequireDatagram(ctx context.Context) context.Context {
+func ContextWithRequireDatagram(ctx context.Context, udp bool) context.Context {
+	if !udp {
+		return ctx
+	}
 	return context.WithValue(ctx, requireDatagram, struct{}{})
 }