mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-05 14:13:30 +03:00
[test]core 1.8
This commit is contained in:
parent
cec14db4a8
commit
5d510eb5aa
2 changed files with 21 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
|
@ -77,6 +78,12 @@ type FallbackFilter struct {
|
|||
Domain []string `yaml:"domain"`
|
||||
}
|
||||
|
||||
var (
|
||||
GroupsList = list.New()
|
||||
ProxiesList = list.New()
|
||||
ParsingProxiesCallback func(groupsList *list.List, proxiesList *list.List)
|
||||
)
|
||||
|
||||
// Profile config
|
||||
type Profile struct {
|
||||
StoreSelected bool `yaml:"store-selected"`
|
||||
|
@ -276,6 +283,8 @@ func parseProxies(cfg *RawConfig) (proxies map[string]C.Proxy, providersMap map[
|
|||
proxies = make(map[string]C.Proxy)
|
||||
providersMap = make(map[string]providerTypes.ProxyProvider)
|
||||
proxyList := []string{}
|
||||
_proxiesList := list.New()
|
||||
_groupsList := list.New()
|
||||
proxiesConfig := cfg.Proxy
|
||||
groupsConfig := cfg.ProxyGroup
|
||||
providersConfig := cfg.ProxyProvider
|
||||
|
@ -296,6 +305,7 @@ func parseProxies(cfg *RawConfig) (proxies map[string]C.Proxy, providersMap map[
|
|||
}
|
||||
proxies[proxy.Name()] = proxy
|
||||
proxyList = append(proxyList, proxy.Name())
|
||||
_proxiesList.PushBack(mapping)
|
||||
}
|
||||
|
||||
// keep the original order of ProxyGroups in config file
|
||||
|
@ -305,6 +315,7 @@ func parseProxies(cfg *RawConfig) (proxies map[string]C.Proxy, providersMap map[
|
|||
return nil, nil, fmt.Errorf("proxy group %d: missing name", idx)
|
||||
}
|
||||
proxyList = append(proxyList, groupName)
|
||||
_groupsList.PushBack(mapping)
|
||||
}
|
||||
|
||||
// check if any loop exists and sort the ProxyGroups
|
||||
|
@ -375,6 +386,12 @@ func parseProxies(cfg *RawConfig) (proxies map[string]C.Proxy, providersMap map[
|
|||
[]providerTypes.ProxyProvider{pd},
|
||||
)
|
||||
proxies["GLOBAL"] = adapter.NewProxy(global)
|
||||
ProxiesList = _proxiesList
|
||||
GroupsList = _groupsList
|
||||
if ParsingProxiesCallback != nil {
|
||||
// refresh tray menu
|
||||
go ParsingProxiesCallback(GroupsList, ProxiesList)
|
||||
}
|
||||
return proxies, providersMap, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@ import (
|
|||
"github.com/go-chi/render"
|
||||
)
|
||||
|
||||
var (
|
||||
SwitchProxiesCallback func(sGroup string, sProxy string)
|
||||
)
|
||||
|
||||
func proxyRouter() http.Handler {
|
||||
r := chi.NewRouter()
|
||||
r.Get("/", getProxies)
|
||||
|
|
Loading…
Add table
Reference in a new issue