mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
public key bug and multiuser enhancement and server ip support and config file of client optimization
This commit is contained in:
@@ -140,7 +140,16 @@ func (s *BaseController) SetType(name string) {
|
||||
|
||||
func (s *BaseController) CheckUserAuth() {
|
||||
if s.controllerName == "client" {
|
||||
s.StopRun()
|
||||
if s.actionName == "add" {
|
||||
s.StopRun()
|
||||
return
|
||||
}
|
||||
if id := s.GetIntNoErr("id"); id != 0 {
|
||||
if id != s.GetSession("clientId").(int) {
|
||||
s.StopRun()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if s.controllerName == "index" {
|
||||
if id := s.GetIntNoErr("id"); id != 0 {
|
||||
|
@@ -19,7 +19,14 @@ func (s *ClientController) List() {
|
||||
return
|
||||
}
|
||||
start, length := s.GetAjaxParams()
|
||||
list, cnt := server.GetClientList(start, length, s.GetString("search"))
|
||||
clientIdSession := s.GetSession("clientId")
|
||||
var clientId int
|
||||
if clientIdSession == nil {
|
||||
clientId = 0
|
||||
} else {
|
||||
clientId = clientIdSession.(int)
|
||||
}
|
||||
list, cnt := server.GetClientList(start, length, s.GetString("search"), clientId)
|
||||
s.AjaxTable(list, cnt, cnt)
|
||||
}
|
||||
|
||||
|
@@ -91,6 +91,7 @@ func (s *IndexController) Add() {
|
||||
} else {
|
||||
t := &file.Tunnel{
|
||||
Port: s.GetIntNoErr("port"),
|
||||
ServerIp: s.GetString("server_ip"),
|
||||
Mode: s.GetString("type"),
|
||||
Target: s.GetString("target"),
|
||||
Id: int(file.GetCsvDb().GetTaskId()),
|
||||
@@ -144,7 +145,12 @@ func (s *IndexController) Edit() {
|
||||
if t, err := file.GetCsvDb().GetTask(id); err != nil {
|
||||
s.error()
|
||||
} else {
|
||||
t.Port = s.GetIntNoErr("port")
|
||||
var portChange bool
|
||||
if s.GetIntNoErr("port") != t.Port {
|
||||
portChange = true
|
||||
t.Port = s.GetIntNoErr("port")
|
||||
}
|
||||
t.ServerIp = s.GetString("server_ip")
|
||||
t.Mode = s.GetString("type")
|
||||
t.Target = s.GetString("target")
|
||||
t.Password = s.GetString("password")
|
||||
@@ -152,7 +158,7 @@ func (s *IndexController) Edit() {
|
||||
t.LocalPath = s.GetString("local_path")
|
||||
t.StripPre = s.GetString("strip_pre")
|
||||
t.Remark = s.GetString("remark")
|
||||
if !tool.TestServerPort(t.Port, t.Mode) {
|
||||
if portChange && !tool.TestServerPort(t.Port, t.Mode) {
|
||||
s.AjaxErr("The port cannot be opened because it may has been occupied or is no longer allowed.")
|
||||
}
|
||||
if t.Client, err = file.GetCsvDb().GetClient(s.GetIntNoErr("client_id")); err != nil {
|
||||
|
@@ -15,15 +15,18 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="table-responsive">
|
||||
<div id="toolbar">
|
||||
<a href="/client/add" class="btn btn-primary dim" type="button" langtag="info-new">新增</a>
|
||||
</div>
|
||||
<table id="taskList_table" class="table-striped table-hover"
|
||||
data-mobile-responsive="true"></table>
|
||||
<div class="content">
|
||||
{{if eq true .isAdmin}}
|
||||
|
||||
<div class="table-responsive">
|
||||
<div id="toolbar">
|
||||
<a href="/client/add" class="btn btn-primary dim" type="button" langtag="info-new">新增</a>
|
||||
</div>
|
||||
<table id="taskList_table" class="table-striped table-hover"
|
||||
data-mobile-responsive="true"></table>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="ibox-content">
|
||||
|
||||
<table id="table"></table>
|
||||
@@ -225,11 +228,12 @@
|
||||
sortable: true,//启用排序
|
||||
formatter: function (value, row, index) {
|
||||
btn_group = '<div class="btn-group">'
|
||||
btn = `<button onclick="del(` + row.Id + `)" class="btn-danger"><i class="fa fa-trash"></i></button><button onclick="edit(` + row.Id + `)" class="btn-primary"><i class="fa fa-edit"></i></button></div>`
|
||||
btn = ` {{if eq true .isAdmin}}<button onclick="del(` + row.Id + `)" class="btn-danger"><i class="fa fa-trash"></i></button>{{end}}<button onclick="edit(` + row.Id + `)" class="btn-primary"><i class="fa fa-edit"></i></button></div>`
|
||||
|
||||
if (row.Status) {
|
||||
return btn_group + `<button onclick="stop(` + row.Id + `)" class="btn-warning"><i class="fa fa-close"></i></button>` + btn
|
||||
return btn_group {{if eq true .isAdmin}}+ `<button onclick="stop(` + row.Id + `)" class="btn-warning"><i class="fa fa-close"></i></button>` {{end}}+ btn
|
||||
} else {
|
||||
return btn_group + `<button onclick="start(` + row.Id + `)" class="btn-warning"><i class="fa fa-check"></i></button>` + btn
|
||||
return btn_group {{if eq true .isAdmin}}+ `<button onclick="start(` + row.Id + `)" class="btn-warning"><i class="fa fa-check"></i></button>` {{end}}+ btn
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@@ -28,6 +28,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="server_ip">
|
||||
<label class="col-sm-2 control-label" langtag="info-server-ip">服务端ip</label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" type="text" value="0.0.0.0" name="server_ip"
|
||||
placeholder="such as 0.0.0.0">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="port">
|
||||
<label class="col-sm-2 control-label" langtag="info-server-port">服务端端口</label>
|
||||
<div class="col-sm-10">
|
||||
|
@@ -28,7 +28,13 @@
|
||||
placeholder="empty means to be unrestricted">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="server_ip">
|
||||
<label class="col-sm-2 control-label" langtag="info-server-ip">服务端ip</label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" type="text" value="{{.t.ServerIp}}" name="server_ip"
|
||||
placeholder="such as 0.0.0.0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="port">
|
||||
<label class="col-sm-2 control-label" langtag="info-server-port">服务端端口</label>
|
||||
<div class="col-sm-10">
|
||||
|
@@ -38,7 +38,13 @@
|
||||
{{/*<img alt="image" class="img-circle" src="/static/img/profile_small.jpg"/>*/}}
|
||||
</span>
|
||||
<a href="#">
|
||||
<span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">admin</strong>
|
||||
<span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">
|
||||
{{if eq true .isAdmin}}
|
||||
admin
|
||||
{{else}}
|
||||
user
|
||||
{{end}}
|
||||
</strong>
|
||||
</span> <span class="text-muted text-xs block">system </span> </span>
|
||||
</a>
|
||||
</div>
|
||||
@@ -46,7 +52,6 @@
|
||||
NPS
|
||||
</div>
|
||||
</li>
|
||||
{{if eq true .isAdmin}}
|
||||
<li class="{{if eq "index" .menu}}active{{end}}">
|
||||
<a href="/"><i class="fa fa-dashboard"></i> <span langtag="menu-dashboard"
|
||||
class="nav-label">仪表盘</span></a>
|
||||
@@ -55,7 +60,6 @@
|
||||
<a href="/client/list"><i class="fa fa-clipboard"></i> <span langtag="menu-client"
|
||||
class="nav-label">客户端</span></a>
|
||||
</li>
|
||||
{{end}}
|
||||
<li class="{{if eq "host" .menu}}active{{end}}">
|
||||
<a href="/index/hostlist"><i class="fa fa-paperclip"></i> <span langtag="menu-host"
|
||||
class="nav-label">域名解析</span></a>
|
||||
|
Reference in New Issue
Block a user