48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
|
|
|
package routes
|
|
|
|
import (
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
"github.com/iwind/TeaGo/maps"
|
|
)
|
|
|
|
type InternalAction struct {
|
|
actionutils.ParentAction
|
|
}
|
|
|
|
func (this *InternalAction) Init() {
|
|
this.Nav("", "", "internal")
|
|
}
|
|
|
|
func (this *InternalAction) RunGet(params struct{}) {
|
|
this.Data["ispRoutes"] = dnsconfigs.AllDefaultISPRoutes
|
|
this.Data["chinaProvinceRoutes"] = dnsconfigs.AllDefaultChinaProvinceRoutes
|
|
this.Data["worldRegionRoutes"] = dnsconfigs.AllDefaultWorldRegionRoutes
|
|
|
|
// Agent相关线路
|
|
agentsResp, err := this.RPC().ClientAgentRPC().FindAllClientAgents(this.AdminContext(), &pb.FindAllClientAgentsRequest{})
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
var agentRouteMaps = []maps.Map{}
|
|
var hasEmptyAgents = false
|
|
for _, agent := range agentsResp.ClientAgents {
|
|
agentRouteMaps = append(agentRouteMaps, maps.Map{
|
|
"name": agent.Name,
|
|
"code": "agent:" + agent.Code,
|
|
"countIPs": agent.CountIPs,
|
|
})
|
|
if agent.CountIPs == 0 {
|
|
hasEmptyAgents = true
|
|
}
|
|
}
|
|
this.Data["agentRoutes"] = agentRouteMaps
|
|
this.Data["hasEmptyAgents"] = hasEmptyAgents
|
|
|
|
this.Show()
|
|
}
|