Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions proxy/hysteria/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 4 additions & 1 deletion proxy/hysteria/ctx/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{})
}

Expand Down