diff --git a/share/generate_share.go b/share/generate_share.go index d695ab94..d8b91383 100644 --- a/share/generate_share.go +++ b/share/generate_share.go @@ -246,6 +246,11 @@ func streamSettingsQuery(proxy conf.OutboundDetourConfig, link *url.URL) { query = addQuery(query, "down", string(qp.BrutalDown)) } if len(qp.UdpHop.PortList.Range) > 0 { + if jsonData, err := json.Marshal(qp.UdpHop.PortList.Range); err == nil { + query = addQuery(query, "ports", string(jsonData)) + } + } + if qp.UdpHop.Interval.From >= 5 { query = addQuery(query, "ports", qp.UdpHop.PortList.String()) } if qp.UdpHop.Interval.From != 0 || qp.UdpHop.Interval.To != 0 { diff --git a/share/hysteria_mask.go b/share/hysteria_mask.go index 17485d6d..5ff238e3 100644 --- a/share/hysteria_mask.go +++ b/share/hysteria_mask.go @@ -21,11 +21,13 @@ func buildHy2FinalMask(up, down, ports string, hopInterval *int32, obfsType, obf quicParams.BrutalDown = conf.Bandwidth(down) } if ports != "" { + var portList conf.PortList udpHop := conf.UdpHop{} - portListJSON, err := json.Marshal(ports) + err := json.Unmarshal([]byte(ports), &portList) if err != nil { return nil, err } + udpHop.PortList = portList if err := json.Unmarshal(portListJSON, &udpHop.PortList); err != nil { return nil, err }