public key bug and multiuser enhancement and server ip support and config file of client optimization

This commit is contained in:
刘河
2019-03-26 23:34:55 +08:00
parent 00a4a33c5f
commit 42a73fa392
22 changed files with 155 additions and 70 deletions

View File

@@ -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 {

View File

@@ -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)
}

View File

@@ -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 {