mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
chore: disallow some restful api for CMFA
Some checks are pending
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
Some checks are pending
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
This commit is contained in:
parent
fc9d5cfee9
commit
a330fa1506
|
@ -24,9 +24,11 @@ import (
|
||||||
func configRouter() http.Handler {
|
func configRouter() http.Handler {
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
r.Get("/", getConfigs)
|
r.Get("/", getConfigs)
|
||||||
r.Put("/", updateConfigs)
|
if !embedMode { // disallow update/patch configs in embed mode
|
||||||
r.Post("/geo", updateGeoDatabases)
|
r.Put("/", updateConfigs)
|
||||||
r.Patch("/", patchConfigs)
|
r.Post("/geo", updateGeoDatabases)
|
||||||
|
r.Patch("/", patchConfigs)
|
||||||
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/metacubex/mihomo/tunnel"
|
"github.com/metacubex/mihomo/tunnel"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GroupRouter() http.Handler {
|
func groupRouter() http.Handler {
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
r.Get("/", getGroups)
|
r.Get("/", getGroups)
|
||||||
|
|
||||||
|
|
7
hub/route/patch_android.go
Normal file
7
hub/route/patch_android.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
//go:build android && cmfa
|
||||||
|
|
||||||
|
package route
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
SetEmbedMode(true) // set embed mode default
|
||||||
|
}
|
|
@ -36,8 +36,14 @@ var (
|
||||||
tlsServer *http.Server
|
tlsServer *http.Server
|
||||||
unixServer *http.Server
|
unixServer *http.Server
|
||||||
pipeServer *http.Server
|
pipeServer *http.Server
|
||||||
|
|
||||||
|
embedMode = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func SetEmbedMode(embed bool) {
|
||||||
|
embedMode = embed
|
||||||
|
}
|
||||||
|
|
||||||
type Traffic struct {
|
type Traffic struct {
|
||||||
Up int64 `json:"up"`
|
Up int64 `json:"up"`
|
||||||
Down int64 `json:"down"`
|
Down int64 `json:"down"`
|
||||||
|
@ -114,15 +120,17 @@ func router(isDebug bool, secret string, dohServer string, cors Cors) *chi.Mux {
|
||||||
r.Get("/version", version)
|
r.Get("/version", version)
|
||||||
r.Mount("/configs", configRouter())
|
r.Mount("/configs", configRouter())
|
||||||
r.Mount("/proxies", proxyRouter())
|
r.Mount("/proxies", proxyRouter())
|
||||||
r.Mount("/group", GroupRouter())
|
r.Mount("/group", groupRouter())
|
||||||
r.Mount("/rules", ruleRouter())
|
r.Mount("/rules", ruleRouter())
|
||||||
r.Mount("/connections", connectionRouter())
|
r.Mount("/connections", connectionRouter())
|
||||||
r.Mount("/providers/proxies", proxyProviderRouter())
|
r.Mount("/providers/proxies", proxyProviderRouter())
|
||||||
r.Mount("/providers/rules", ruleProviderRouter())
|
r.Mount("/providers/rules", ruleProviderRouter())
|
||||||
r.Mount("/cache", cacheRouter())
|
r.Mount("/cache", cacheRouter())
|
||||||
r.Mount("/dns", dnsRouter())
|
r.Mount("/dns", dnsRouter())
|
||||||
r.Mount("/restart", restartRouter())
|
if !embedMode { // disallow restart and upgrade in embed mode
|
||||||
r.Mount("/upgrade", upgradeRouter())
|
r.Mount("/restart", restartRouter())
|
||||||
|
r.Mount("/upgrade", upgradeRouter())
|
||||||
|
}
|
||||||
addExternalRouters(r)
|
addExternalRouters(r)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user