File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ func (d DerpEndpoints) Convert() *DERPMap {
8888type DerpQueryParams struct {
8989 Status DerpStatus `query:"status" json:"status" enums:"alive,error,all"`
9090 LatencyLimit time.Duration `query:"latency-limit" json:"latency_limit"`
91- BandwidthLimit float64 `query:"bandwidth-limit" json:"bandwidth_limit"`
91+ BandwidthLimit string `query:"bandwidth-limit" json:"bandwidth_limit"`
9292}
9393
9494func (d DerpEndpoints ) Query (params * DerpQueryParams ) DerpEndpoints {
@@ -100,8 +100,14 @@ func (d DerpEndpoints) Query(params *DerpQueryParams) DerpEndpoints {
100100 if params .LatencyLimit != 0 && endpoint .Latency > params .LatencyLimit {
101101 continue
102102 }
103- if params .BandwidthLimit != 0 && endpoint .Bandwidth .Value < params .BandwidthLimit {
104- continue
103+ if params .BandwidthLimit != "" {
104+ bandwidthLimit , err := speedtest .ParseUnit (params .BandwidthLimit , "bps" )
105+ if err != nil {
106+ continue
107+ }
108+ if endpoint .Bandwidth .Value < bandwidthLimit .Value {
109+ continue
110+ }
105111 }
106112 res = append (res , endpoint )
107113 }
You can’t perform that action at this time.
0 commit comments