This commit is contained in:
刘河
2019-04-10 20:54:51 +08:00
parent 16c97a3c36
commit 60c8b0c7bf
5 changed files with 71 additions and 65 deletions

View File

@@ -68,7 +68,7 @@ func (s *IndexController) Host() {
func (s *IndexController) All() {
s.Data["menu"] = "client"
clientId := s.GetString("client_id")
clientId := s.getEscapeString("client_id")
s.Data["client_id"] = clientId
s.SetInfo("client id:" + clientId)
s.display("index/list")
@@ -76,30 +76,30 @@ func (s *IndexController) All() {
func (s *IndexController) GetTunnel() {
start, length := s.GetAjaxParams()
taskType := s.GetString("type")
taskType := s.getEscapeString("type")
clientId := s.GetIntNoErr("client_id")
list, cnt := server.GetTunnel(start, length, taskType, clientId, s.GetString("search"))
list, cnt := server.GetTunnel(start, length, taskType, clientId, s.getEscapeString("search"))
s.AjaxTable(list, cnt, cnt)
}
func (s *IndexController) Add() {
if s.Ctx.Request.Method == "GET" {
s.Data["type"] = s.GetString("type")
s.Data["client_id"] = s.GetString("client_id")
s.Data["type"] = s.getEscapeString("type")
s.Data["client_id"] = s.getEscapeString("client_id")
s.SetInfo("add tunnel")
s.display()
} else {
t := &file.Tunnel{
Port: s.GetIntNoErr("port"),
ServerIp: s.GetString("server_ip"),
Mode: s.GetString("type"),
Target: &file.Target{TargetStr: s.GetString("target"), LocalProxy: s.GetBoolNoErr("local_proxy")},
ServerIp: s.getEscapeString("server_ip"),
Mode: s.getEscapeString("type"),
Target: &file.Target{TargetStr: s.getEscapeString("target"), LocalProxy: s.GetBoolNoErr("local_proxy")},
Id: int(file.GetDb().JsonDb.GetTaskId()),
Status: true,
Remark: s.GetString("remark"),
Password: s.GetString("password"),
LocalPath: s.GetString("local_path"),
StripPre: s.GetString("strip_pre"),
Remark: s.getEscapeString("remark"),
Password: s.getEscapeString("password"),
LocalPath: s.getEscapeString("local_path"),
StripPre: s.getEscapeString("strip_pre"),
Flow: &file.Flow{},
}
if !tool.TestServerPort(t.Port, t.Mode) {
@@ -161,14 +161,14 @@ func (s *IndexController) Edit() {
}
t.Port = s.GetIntNoErr("port")
}
t.ServerIp = s.GetString("server_ip")
t.Mode = s.GetString("type")
t.Target = &file.Target{TargetStr: s.GetString("target")}
t.Password = s.GetString("password")
t.ServerIp = s.getEscapeString("server_ip")
t.Mode = s.getEscapeString("type")
t.Target = &file.Target{TargetStr: s.getEscapeString("target")}
t.Password = s.getEscapeString("password")
t.Id = id
t.LocalPath = s.GetString("local_path")
t.StripPre = s.GetString("strip_pre")
t.Remark = s.GetString("remark")
t.LocalPath = s.getEscapeString("local_path")
t.StripPre = s.getEscapeString("strip_pre")
t.Remark = s.getEscapeString("remark")
t.Target.LocalProxy = s.GetBoolNoErr("local_proxy")
file.GetDb().UpdateTask(t)
server.StopServer(t.Id)
@@ -204,14 +204,14 @@ func (s *IndexController) Start() {
func (s *IndexController) HostList() {
if s.Ctx.Request.Method == "GET" {
s.Data["client_id"] = s.GetString("client_id")
s.Data["client_id"] = s.getEscapeString("client_id")
s.Data["menu"] = "host"
s.SetInfo("host list")
s.display("index/hlist")
} else {
start, length := s.GetAjaxParams()
clientId := s.GetIntNoErr("client_id")
list, cnt := file.GetDb().GetHost(start, length, clientId, s.GetString("search"))
list, cnt := file.GetDb().GetHost(start, length, clientId, s.getEscapeString("search"))
s.AjaxTable(list, cnt, cnt)
}
}
@@ -240,23 +240,23 @@ func (s *IndexController) DelHost() {
func (s *IndexController) AddHost() {
if s.Ctx.Request.Method == "GET" {
s.Data["client_id"] = s.GetString("client_id")
s.Data["client_id"] = s.getEscapeString("client_id")
s.Data["menu"] = "host"
s.SetInfo("add host")
s.display("index/hadd")
} else {
h := &file.Host{
Id: int(file.GetDb().JsonDb.GetHostId()),
Host: s.GetString("host"),
Target: &file.Target{TargetStr: s.GetString("target"), LocalProxy: s.GetBoolNoErr("local_proxy")},
HeaderChange: s.GetString("header"),
HostChange: s.GetString("hostchange"),
Remark: s.GetString("remark"),
Location: s.GetString("location"),
Host: s.getEscapeString("host"),
Target: &file.Target{TargetStr: s.getEscapeString("target"), LocalProxy: s.GetBoolNoErr("local_proxy")},
HeaderChange: s.getEscapeString("header"),
HostChange: s.getEscapeString("hostchange"),
Remark: s.getEscapeString("remark"),
Location: s.getEscapeString("location"),
Flow: &file.Flow{},
Scheme: s.GetString("scheme"),
KeyFilePath: s.GetString("key_file_path"),
CertFilePath: s.GetString("cert_file_path"),
Scheme: s.getEscapeString("scheme"),
KeyFilePath: s.getEscapeString("key_file_path"),
CertFilePath: s.getEscapeString("cert_file_path"),
}
var err error
if h.Client, err = file.GetDb().GetClient(s.GetIntNoErr("client_id")); err != nil {
@@ -284,11 +284,11 @@ func (s *IndexController) EditHost() {
if h, err := file.GetDb().GetHostById(id); err != nil {
s.error()
} else {
if h.Host != s.GetString("host") {
if h.Host != s.getEscapeString("host") {
tmpHost := new(file.Host)
tmpHost.Host = s.GetString("host")
tmpHost.Location = s.GetString("location")
tmpHost.Scheme = s.GetString("scheme")
tmpHost.Host = s.getEscapeString("host")
tmpHost.Location = s.getEscapeString("location")
tmpHost.Scheme = s.getEscapeString("scheme")
if file.GetDb().IsHostExist(tmpHost) {
s.AjaxErr("host has exist")
return
@@ -299,15 +299,15 @@ func (s *IndexController) EditHost() {
} else {
h.Client = client
}
h.Host = s.GetString("host")
h.Target = &file.Target{TargetStr: s.GetString("target")}
h.HeaderChange = s.GetString("header")
h.HostChange = s.GetString("hostchange")
h.Remark = s.GetString("remark")
h.Location = s.GetString("location")
h.Scheme = s.GetString("scheme")
h.KeyFilePath = s.GetString("key_file_path")
h.CertFilePath = s.GetString("cert_file_path")
h.Host = s.getEscapeString("host")
h.Target = &file.Target{TargetStr: s.getEscapeString("target")}
h.HeaderChange = s.getEscapeString("header")
h.HostChange = s.getEscapeString("hostchange")
h.Remark = s.getEscapeString("remark")
h.Location = s.getEscapeString("location")
h.Scheme = s.getEscapeString("scheme")
h.KeyFilePath = s.getEscapeString("key_file_path")
h.CertFilePath = s.getEscapeString("cert_file_path")
h.Target.LocalProxy = s.GetBoolNoErr("local_proxy")
file.GetDb().JsonDb.StoreHostToJsonFile()
}