mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 07:03:23 +08:00
chore: code cleanup
This commit is contained in:
parent
012e448562
commit
81c832ef9e
@ -46,18 +46,13 @@ type proxySetProvider struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pp *proxySetProvider) MarshalJSON() ([]byte, error) {
|
func (pp *proxySetProvider) MarshalJSON() ([]byte, error) {
|
||||||
expectedStatus := "*"
|
|
||||||
if pp.healthCheck.expectedStatus != nil {
|
|
||||||
expectedStatus = pp.healthCheck.expectedStatus.ToString()
|
|
||||||
}
|
|
||||||
|
|
||||||
return json.Marshal(map[string]any{
|
return json.Marshal(map[string]any{
|
||||||
"name": pp.Name(),
|
"name": pp.Name(),
|
||||||
"type": pp.Type().String(),
|
"type": pp.Type().String(),
|
||||||
"vehicleType": pp.VehicleType().String(),
|
"vehicleType": pp.VehicleType().String(),
|
||||||
"proxies": pp.Proxies(),
|
"proxies": pp.Proxies(),
|
||||||
"testUrl": pp.healthCheck.url,
|
"testUrl": pp.healthCheck.url,
|
||||||
"expectedStatus": expectedStatus,
|
"expectedStatus": pp.healthCheck.expectedStatus.String(),
|
||||||
"updatedAt": pp.UpdatedAt,
|
"updatedAt": pp.UpdatedAt,
|
||||||
"subscriptionInfo": pp.subscriptionInfo,
|
"subscriptionInfo": pp.subscriptionInfo,
|
||||||
})
|
})
|
||||||
@ -221,18 +216,13 @@ type compatibleProvider struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cp *compatibleProvider) MarshalJSON() ([]byte, error) {
|
func (cp *compatibleProvider) MarshalJSON() ([]byte, error) {
|
||||||
expectedStatus := "*"
|
|
||||||
if cp.healthCheck.expectedStatus != nil {
|
|
||||||
expectedStatus = cp.healthCheck.expectedStatus.ToString()
|
|
||||||
}
|
|
||||||
|
|
||||||
return json.Marshal(map[string]any{
|
return json.Marshal(map[string]any{
|
||||||
"name": cp.Name(),
|
"name": cp.Name(),
|
||||||
"type": cp.Type().String(),
|
"type": cp.Type().String(),
|
||||||
"vehicleType": cp.VehicleType().String(),
|
"vehicleType": cp.VehicleType().String(),
|
||||||
"proxies": cp.Proxies(),
|
"proxies": cp.Proxies(),
|
||||||
"testUrl": cp.healthCheck.url,
|
"testUrl": cp.healthCheck.url,
|
||||||
"expectedStatus": expectedStatus,
|
"expectedStatus": cp.healthCheck.expectedStatus.String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ func (ranges IntRanges[T]) Check(status T) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ranges IntRanges[T]) ToString() string {
|
func (ranges IntRanges[T]) String() string {
|
||||||
if len(ranges) == 0 {
|
if len(ranges) == 0 {
|
||||||
return "*"
|
return "*"
|
||||||
}
|
}
|
||||||
@ -134,6 +134,10 @@ func (ranges IntRanges[T]) ToString() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ranges IntRanges[T]) Range(f func(t T) bool) {
|
func (ranges IntRanges[T]) Range(f func(t T) bool) {
|
||||||
|
if len(ranges) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, r := range ranges {
|
for _, r := range ranges {
|
||||||
for i := r.Start(); i <= r.End(); i++ {
|
for i := r.Start(); i <= r.End(); i++ {
|
||||||
if !f(i) {
|
if !f(i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user