mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-02 04:00:42 +00:00
add bridge status for api
This commit is contained in:
parent
b73491cde1
commit
494d59cc93
@ -33,12 +33,12 @@ func (s *BaseController) Prepare() {
|
||||
timestamp := s.GetIntNoErr("timestamp")
|
||||
configKey := beego.AppConfig.String("auth_key")
|
||||
timeNowUnix := time.Now().Unix()
|
||||
if !(md5Key!="" && (math.Abs(float64(timeNowUnix-int64(timestamp))) <= 20) && (crypt.Md5(configKey+strconv.Itoa(timestamp)) == md5Key)) {
|
||||
if !(md5Key != "" && (math.Abs(float64(timeNowUnix-int64(timestamp))) <= 20) && (crypt.Md5(configKey+strconv.Itoa(timestamp)) == md5Key)) {
|
||||
if s.GetSession("auth") != true {
|
||||
s.Redirect(beego.AppConfig.String("web_base_url")+"/login/index", 302)
|
||||
}
|
||||
}else {
|
||||
s.SetSession("isAdmin",true)
|
||||
} else {
|
||||
s.SetSession("isAdmin", true)
|
||||
s.Data["isAdmin"] = true
|
||||
}
|
||||
if s.GetSession("isAdmin") != nil && !s.GetSession("isAdmin").(bool) {
|
||||
@ -141,10 +141,17 @@ func ajax(str string, status int) map[string]interface{} {
|
||||
}
|
||||
|
||||
//ajax table返回
|
||||
func (s *BaseController) AjaxTable(list interface{}, cnt int, recordsTotal int) {
|
||||
func (s *BaseController) AjaxTable(list interface{}, cnt int, recordsTotal int, kwargs map[string]interface{}) {
|
||||
json := make(map[string]interface{})
|
||||
json["rows"] = list
|
||||
json["total"] = recordsTotal
|
||||
if kwargs != nil {
|
||||
for k, v := range kwargs {
|
||||
if v != nil {
|
||||
json[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
s.Data["json"] = json
|
||||
s.ServeJSON()
|
||||
s.StopRun()
|
||||
|
@ -28,7 +28,12 @@ func (s *ClientController) List() {
|
||||
clientId = clientIdSession.(int)
|
||||
}
|
||||
list, cnt := server.GetClientList(start, length, s.getEscapeString("search"), s.getEscapeString("sort"), s.getEscapeString("order"), clientId)
|
||||
s.AjaxTable(list, cnt, cnt)
|
||||
cmd := make(map[string]interface{})
|
||||
ip := s.Ctx.Request.Host
|
||||
cmd["ip"] = common.GetIpByAddr(ip)
|
||||
cmd["bridgeType"] = beego.AppConfig.String("bridge_type")
|
||||
cmd["bridgePort"] = server.Bridge.TunnelPort
|
||||
s.AjaxTable(list, cnt, cnt, cmd)
|
||||
}
|
||||
|
||||
//添加客户端
|
||||
|
@ -82,7 +82,7 @@ func (s *IndexController) GetTunnel() {
|
||||
taskType := s.getEscapeString("type")
|
||||
clientId := s.GetIntNoErr("client_id")
|
||||
list, cnt := server.GetTunnel(start, length, taskType, clientId, s.getEscapeString("search"))
|
||||
s.AjaxTable(list, cnt, cnt)
|
||||
s.AjaxTable(list, cnt, cnt, nil)
|
||||
}
|
||||
|
||||
func (s *IndexController) Add() {
|
||||
@ -215,7 +215,7 @@ func (s *IndexController) HostList() {
|
||||
start, length := s.GetAjaxParams()
|
||||
clientId := s.GetIntNoErr("client_id")
|
||||
list, cnt := file.GetDb().GetHost(start, length, clientId, s.getEscapeString("search"))
|
||||
s.AjaxTable(list, cnt, cnt)
|
||||
s.AjaxTable(list, cnt, cnt, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user