Update zt

This commit is contained in:
LinkLeong 2023-05-26 10:43:43 +01:00
parent a645a7bb22
commit 5044874281

View File

@ -13,7 +13,7 @@ import (
) )
func (s *CasaOS) SetZerotierNetworkStatus(ctx echo.Context, networkId string) error { func (s *CasaOS) SetZerotierNetworkStatus(ctx echo.Context, networkId string) error {
ip := `,"via":"10.147.20.256"` ip := `,"via":"10.147.19.0"`
status := ctx.Request().PostFormValue("status") status := ctx.Request().PostFormValue("status")
if status == "online" { if status == "online" {
ip = `` ip = ``
@ -30,11 +30,12 @@ func (s *CasaOS) SetZerotierNetworkStatus(ctx echo.Context, networkId string) er
fmt.Println(err) fmt.Println(err)
return ctx.JSON(http.StatusInternalServerError, codegen.BaseResponse{Message: utils.Ptr(err.Error())}) return ctx.JSON(http.StatusInternalServerError, codegen.BaseResponse{Message: utils.Ptr(err.Error())})
} }
fmt.Println(string(res))
info := codegen.GetZTInfoOK{} info := codegen.GetZTInfoOK{}
via := gjson.GetBytes(res, "routes.0.via").Str via := gjson.GetBytes(res, "routes.0.via").Str
info.Id = utils.Ptr(gjson.GetBytes(res, "id").Str) info.Id = utils.Ptr(gjson.GetBytes(res, "id").Str)
info.Name = utils.Ptr(gjson.GetBytes(res, "name").Str) info.Name = utils.Ptr(gjson.GetBytes(res, "name").Str)
if len(via) != 0 { if len(via) == 0 {
info.Status = utils.Ptr("online") info.Status = utils.Ptr("online")
} else { } else {
info.Status = utils.Ptr("offline") info.Status = utils.Ptr("offline")