mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: return more information for the api
This commit is contained in:
parent
7e3e38d054
commit
ffcd672ebf
|
@ -21,6 +21,8 @@ type Fallback struct {
|
|||
testUrl string
|
||||
selected string
|
||||
expectedStatus string
|
||||
Hidden bool
|
||||
Icon string
|
||||
}
|
||||
|
||||
func (f *Fallback) Now() string {
|
||||
|
@ -90,6 +92,8 @@ func (f *Fallback) MarshalJSON() ([]byte, error) {
|
|||
"testUrl": f.testUrl,
|
||||
"expectedStatus": f.expectedStatus,
|
||||
"fixed": f.selected,
|
||||
"hidden": f.Hidden,
|
||||
"icon": f.Icon,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -165,5 +169,7 @@ func NewFallback(option *GroupCommonOption, providers []provider.ProxyProvider)
|
|||
disableUDP: option.DisableUDP,
|
||||
testUrl: option.URL,
|
||||
expectedStatus: option.ExpectedStatus,
|
||||
Hidden: option.Hidden,
|
||||
Icon: option.Icon,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ type LoadBalance struct {
|
|||
strategyFn strategyFn
|
||||
testUrl string
|
||||
expectedStatus string
|
||||
Hidden bool
|
||||
Icon string
|
||||
}
|
||||
|
||||
var errStrategy = errors.New("unsupported strategy")
|
||||
|
@ -236,6 +238,8 @@ func (lb *LoadBalance) MarshalJSON() ([]byte, error) {
|
|||
"all": all,
|
||||
"testUrl": lb.testUrl,
|
||||
"expectedStatus": lb.expectedStatus,
|
||||
"hidden": lb.Hidden,
|
||||
"icon": lb.Icon,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -268,5 +272,7 @@ func NewLoadBalance(option *GroupCommonOption, providers []provider.ProxyProvide
|
|||
disableUDP: option.DisableUDP,
|
||||
testUrl: option.URL,
|
||||
expectedStatus: option.ExpectedStatus,
|
||||
Hidden: option.Hidden,
|
||||
Icon: option.Icon,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ type GroupCommonOption struct {
|
|||
IncludeAll bool `group:"include-all,omitempty"`
|
||||
IncludeAllProxies bool `group:"include-all-proxies,omitempty"`
|
||||
IncludeAllProviders bool `group:"include-all-providers,omitempty"`
|
||||
Hidden bool `group:"hidden,omitempty"`
|
||||
Icon string `group:"icon,omitempty"`
|
||||
}
|
||||
|
||||
func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, providersMap map[string]types.ProxyProvider, AllProxies []string, AllProviders []string) (C.ProxyAdapter, error) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package outboundgroup
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/metacubex/mihomo/adapter/outbound"
|
||||
"github.com/metacubex/mihomo/component/dialer"
|
||||
"github.com/metacubex/mihomo/component/proxydialer"
|
||||
|
@ -12,6 +13,8 @@ import (
|
|||
|
||||
type Relay struct {
|
||||
*GroupBase
|
||||
Hidden bool
|
||||
Icon string
|
||||
}
|
||||
|
||||
// DialContext implements C.ProxyAdapter
|
||||
|
@ -106,8 +109,10 @@ func (r *Relay) MarshalJSON() ([]byte, error) {
|
|||
all = append(all, proxy.Name())
|
||||
}
|
||||
return json.Marshal(map[string]any{
|
||||
"type": r.Type().String(),
|
||||
"all": all,
|
||||
"type": r.Type().String(),
|
||||
"all": all,
|
||||
"hidden": r.Hidden,
|
||||
"icon": r.Icon,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -157,5 +162,7 @@ func NewRelay(option *GroupCommonOption, providers []provider.ProxyProvider) *Re
|
|||
"",
|
||||
providers,
|
||||
}),
|
||||
Hidden: option.Hidden,
|
||||
Icon: option.Icon,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ type Selector struct {
|
|||
*GroupBase
|
||||
disableUDP bool
|
||||
selected string
|
||||
Hidden bool
|
||||
Icon string
|
||||
}
|
||||
|
||||
// DialContext implements C.ProxyAdapter
|
||||
|
@ -57,9 +59,11 @@ func (s *Selector) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
return json.Marshal(map[string]any{
|
||||
"type": s.Type().String(),
|
||||
"now": s.Now(),
|
||||
"all": all,
|
||||
"type": s.Type().String(),
|
||||
"now": s.Now(),
|
||||
"all": all,
|
||||
"hidden": s.Hidden,
|
||||
"icon": s.Icon,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -114,5 +118,7 @@ func NewSelector(option *GroupCommonOption, providers []provider.ProxyProvider)
|
|||
}),
|
||||
selected: "COMPATIBLE",
|
||||
disableUDP: option.DisableUDP,
|
||||
Hidden: option.Hidden,
|
||||
Icon: option.Icon,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ type URLTest struct {
|
|||
expectedStatus string
|
||||
tolerance uint16
|
||||
disableUDP bool
|
||||
Hidden bool
|
||||
Icon string
|
||||
fastNode C.Proxy
|
||||
fastSingle *singledo.Single[C.Proxy]
|
||||
}
|
||||
|
@ -174,6 +176,8 @@ func (u *URLTest) MarshalJSON() ([]byte, error) {
|
|||
"testUrl": u.testUrl,
|
||||
"expectedStatus": u.expectedStatus,
|
||||
"fixed": u.selected,
|
||||
"hidden": u.Hidden,
|
||||
"icon": u.Icon,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -237,6 +241,8 @@ func NewURLTest(option *GroupCommonOption, providers []provider.ProxyProvider, o
|
|||
disableUDP: option.DisableUDP,
|
||||
testUrl: option.URL,
|
||||
expectedStatus: option.ExpectedStatus,
|
||||
Hidden: option.Hidden,
|
||||
Icon: option.Icon,
|
||||
}
|
||||
|
||||
for _, option := range options {
|
||||
|
|
Loading…
Reference in New Issue
Block a user