From dda15b0821652b33b1c34292187821f4f187cc80 Mon Sep 17 00:00:00 2001 From: link Date: Thu, 25 May 2023 12:14:32 +0800 Subject: [PATCH] Add zertier (#1124) Signed-off-by: link --- route/init.go | 5 +++++ route/v1.go | 2 +- route/v1/zerotier.go | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/route/init.go b/route/init.go index 3e3c640..697d9ad 100644 --- a/route/init.go +++ b/route/init.go @@ -24,6 +24,7 @@ import ( "github.com/IceWhaleTech/CasaOS/pkg/samba" "github.com/IceWhaleTech/CasaOS/pkg/utils/encryption" "github.com/IceWhaleTech/CasaOS/pkg/utils/file" + v1 "github.com/IceWhaleTech/CasaOS/route/v1" "github.com/IceWhaleTech/CasaOS/service" "go.uber.org/zap" ) @@ -31,6 +32,7 @@ import ( func InitFunction() { go InitNetworkMount() go InitInfo() + go InitZerotier() } func InitInfo() { @@ -98,3 +100,6 @@ func InitNetworkMount() { logger.Error("mount storage err", zap.Any("err", err)) } } +func InitZerotier() { + v1.CheckNetwork() +} diff --git a/route/v1.go b/route/v1.go index 12be472..a5648d9 100644 --- a/route/v1.go +++ b/route/v1.go @@ -40,7 +40,7 @@ func InitV1Router() *gin.Engine { }) r.GET("/v1/recover/:type", v1.GetRecoverStorage) v1Group := r.Group("/v1") - r.Any("/v1/test", v1.CheckNetwork) + // r.Any("/v1/test", v1.CheckNetwork) v1Group.Use(jwt.ExceptLocalhost(func() (*ecdsa.PublicKey, error) { return external.GetPublicKey(config.CommonInfo.RuntimePath) })) { diff --git a/route/v1/zerotier.go b/route/v1/zerotier.go index ce336e3..0def71f 100644 --- a/route/v1/zerotier.go +++ b/route/v1/zerotier.go @@ -75,7 +75,8 @@ func copyHeaders(destination, source http.Header) { } } -func CheckNetwork(c *gin.Context) { +func CheckNetwork() { + //先获取所有已创建的网络 respBody, err := httper.ZTGet("/controller/network") if err != nil {