mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
很多修改
This commit is contained in:
@@ -33,7 +33,7 @@ func (s *ClientController) Add() {
|
||||
Id: server.CsvDb.GetClientId(),
|
||||
Status: true,
|
||||
Remark: s.GetString("Remark"),
|
||||
Cnf: &utils.ServerConfig{
|
||||
Cnf: &utils.Config{
|
||||
U: s.GetString("u"),
|
||||
P: s.GetString("p"),
|
||||
Compress: s.GetString("compress"),
|
||||
|
@@ -57,11 +57,11 @@ func (s *IndexController) All() {
|
||||
s.display("index/list")
|
||||
}
|
||||
|
||||
func (s *IndexController) GetServerConfig() {
|
||||
func (s *IndexController) GetTunnel() {
|
||||
start, length := s.GetAjaxParams()
|
||||
taskType := s.GetString("type")
|
||||
clientId := s.GetIntNoErr("client_id")
|
||||
list, cnt := server.GetServerConfig(start, length, taskType, clientId)
|
||||
list, cnt := server.GetTunnel(start, length, taskType, clientId)
|
||||
s.AjaxTable(list, cnt, cnt)
|
||||
}
|
||||
|
||||
@@ -72,22 +72,26 @@ func (s *IndexController) Add() {
|
||||
s.SetInfo("新增")
|
||||
s.display()
|
||||
} else {
|
||||
t := &utils.ServerConfig{
|
||||
TcpPort: s.GetIntNoErr("port"),
|
||||
Mode: s.GetString("type"),
|
||||
Target: s.GetString("target"),
|
||||
U: s.GetString("u"),
|
||||
P: s.GetString("p"),
|
||||
Compress: s.GetString("compress"),
|
||||
Crypt: s.GetBoolNoErr("crypt"),
|
||||
Mux: s.GetBoolNoErr("mux"),
|
||||
IsRun: 0,
|
||||
t := &utils.Tunnel{
|
||||
TcpPort: s.GetIntNoErr("port"),
|
||||
Mode: s.GetString("type"),
|
||||
Target: s.GetString("target"),
|
||||
Config: &utils.Config{
|
||||
U: s.GetString("u"),
|
||||
P: s.GetString("p"),
|
||||
Compress: s.GetString("compress"),
|
||||
Crypt: s.GetBoolNoErr("crypt"),
|
||||
Mux: s.GetBoolNoErr("mux"),
|
||||
},
|
||||
Id: server.CsvDb.GetTaskId(),
|
||||
ClientId: s.GetIntNoErr("client_id"),
|
||||
UseClientCnf: s.GetBoolNoErr("use_client"),
|
||||
Start: 1,
|
||||
Status: true,
|
||||
Remark: s.GetString("remark"),
|
||||
}
|
||||
var err error
|
||||
if t.Client, err = server.CsvDb.GetClient(s.GetIntNoErr("client_id")); err != nil {
|
||||
s.AjaxErr(err.Error())
|
||||
}
|
||||
server.CsvDb.NewTask(t)
|
||||
if err := server.AddTask(t); err != nil {
|
||||
s.AjaxErr(err.Error())
|
||||
@@ -115,12 +119,12 @@ func (s *IndexController) Edit() {
|
||||
t.Mode = s.GetString("type")
|
||||
t.Target = s.GetString("target")
|
||||
t.Id = id
|
||||
t.ClientId = s.GetIntNoErr("client_id")
|
||||
t.U = s.GetString("u")
|
||||
t.P = s.GetString("p")
|
||||
t.Compress = s.GetString("compress")
|
||||
t.Crypt = s.GetBoolNoErr("crypt")
|
||||
t.Mux = s.GetBoolNoErr("mux")
|
||||
t.Client.Id = s.GetIntNoErr("client_id")
|
||||
t.Config.U = s.GetString("u")
|
||||
t.Config.P = s.GetString("p")
|
||||
t.Config.Compress = s.GetString("compress")
|
||||
t.Config.Crypt = s.GetBoolNoErr("crypt")
|
||||
t.Config.Mux = s.GetBoolNoErr("mux")
|
||||
t.UseClientCnf = s.GetBoolNoErr("use_client")
|
||||
t.Remark = s.GetString("remark")
|
||||
server.CsvDb.UpdateTask(t)
|
||||
@@ -162,7 +166,7 @@ func (s *IndexController) HostList() {
|
||||
} else {
|
||||
start, length := s.GetAjaxParams()
|
||||
clientId := s.GetIntNoErr("client_id")
|
||||
list, cnt := server.CsvDb.GetHostList(start, length, clientId)
|
||||
list, cnt := server.CsvDb.GetHost(start, length, clientId)
|
||||
s.AjaxTable(list, cnt, cnt)
|
||||
}
|
||||
}
|
||||
@@ -182,8 +186,10 @@ func (s *IndexController) AddHost() {
|
||||
s.SetInfo("新增")
|
||||
s.display("index/hadd")
|
||||
} else {
|
||||
h := &utils.HostList{
|
||||
ClientId: s.GetIntNoErr("client_id"),
|
||||
h := &utils.Host{
|
||||
Client: &utils.Client{
|
||||
Id: s.GetIntNoErr("client_id"),
|
||||
},
|
||||
Host: s.GetString("host"),
|
||||
Target: s.GetString("target"),
|
||||
HeaderChange: s.GetString("header"),
|
||||
@@ -199,7 +205,7 @@ func (s *IndexController) EditHost() {
|
||||
host := s.GetString("host")
|
||||
if s.Ctx.Request.Method == "GET" {
|
||||
s.Data["menu"] = "host"
|
||||
if h, _, err := server.GetKeyByHost(host); err != nil {
|
||||
if h, err := server.GetInfoByHost(host); err != nil {
|
||||
s.error()
|
||||
} else {
|
||||
s.Data["h"] = h
|
||||
@@ -207,10 +213,10 @@ func (s *IndexController) EditHost() {
|
||||
s.SetInfo("修改")
|
||||
s.display("index/hedit")
|
||||
} else {
|
||||
if h, _, err := server.GetKeyByHost(host); err != nil {
|
||||
if h, err := server.GetInfoByHost(host); err != nil {
|
||||
s.error()
|
||||
} else {
|
||||
h.ClientId = s.GetIntNoErr("client_id")
|
||||
h.Client.Id = s.GetIntNoErr("client_id")
|
||||
h.Host = s.GetString("nhost")
|
||||
h.Target = s.GetString("target")
|
||||
h.HeaderChange = s.GetString("header")
|
||||
|
@@ -31,7 +31,7 @@
|
||||
</div>
|
||||
<div class="form-group" id="client_id">
|
||||
<label class="control-label">客户端ID</label>
|
||||
<input class="form-control" value="{{.t.ClientId}}" type="text" name="client_id"
|
||||
<input class="form-control" value="{{.t.Client.Id}}" type="text" name="client_id"
|
||||
placeholder="客户端id">
|
||||
</div>
|
||||
<div class="form-group" id="use_client">
|
||||
@@ -44,32 +44,32 @@
|
||||
<div class="form-group" id="compress">
|
||||
<label class="control-label">数据压缩方式(所有模式均支持)</label>
|
||||
<select class="form-control" name="compress">
|
||||
<option {{if eq "" .t.Compress}}selected{{end}} value="">不压缩</option>
|
||||
<option {{if eq "snappy" .t.Compress}}selected{{end}} value="snappy">snappy压缩</option>
|
||||
<option {{if eq "" .t.Config.Compress}}selected{{end}} value="">不压缩</option>
|
||||
<option {{if eq "snappy" .t.Config.Compress}}selected{{end}} value="snappy">snappy压缩</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="crypt">
|
||||
<label class="control-label">是否加密传输(所有模式均支持)</label>
|
||||
<select class="form-control" name="crypt">
|
||||
<option {{if eq false .t.Crypt}}selected{{end}} value="0">不加密</option>
|
||||
<option {{if eq true .t.Crypt}}selected{{end}} value="1">加密</option>
|
||||
<option {{if eq false .t.Config.Crypt}}selected{{end}} value="0">不加密</option>
|
||||
<option {{if eq true .t.Config.Crypt}}selected{{end}} value="1">加密</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="mux">
|
||||
<label class="control-label">是否启用TCP复用(所有模式均支持)</label>
|
||||
<select class="form-control" name="mux">
|
||||
<option {{if eq false .t.Mux}}selected{{end}} value="0">不启用</option>
|
||||
<option {{if eq true .t.Mux}}selected{{end}} value="1">启用</option>
|
||||
<option {{if eq false .t.Config.Mux}}selected{{end}} value="0">不启用</option>
|
||||
<option {{if eq true .t.Config.Mux}}selected{{end}} value="1">启用</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="u">
|
||||
<label class="control-label">验证用户名(仅socks5,web穿透支持)</label>
|
||||
<input class="form-control" value="{{.t.U}}" type="text" name="u"
|
||||
<input class="form-control" value="{{.t.Config.U}}" type="text" name="u"
|
||||
placeholder="不填则无需验证">
|
||||
</div>
|
||||
<div class="form-group" id="p">
|
||||
<label class="control-label">验证密码(仅socks5,web穿透支持)</label>
|
||||
<input class="form-control" value="{{.t.P}}" type="text" name="p"
|
||||
<input class="form-control" value="{{.t.Config.P}}" type="text" name="p"
|
||||
placeholder="不填则无需验证">
|
||||
</div>
|
||||
</form>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">客户端id</label>
|
||||
<input class="form-control" value="{{.h.ClientId}}" type="text" name="client_id"
|
||||
<input class="form-control" value="{{.h.Client.Id}}" type="text" name="client_id"
|
||||
placeholder="客户端id">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@@ -10,6 +10,11 @@
|
||||
<th>host</th>
|
||||
<th>内网目标</th>
|
||||
<th>host改写</th>
|
||||
<th>压缩方式</th>
|
||||
<th>加密</th>
|
||||
<th>多路复用</th>
|
||||
<th>用户名</th>
|
||||
<th>密码</th>
|
||||
<th>出口流量</th>
|
||||
<th>入口流量</th>
|
||||
<th>操作</th>
|
||||
@@ -68,13 +73,18 @@
|
||||
},
|
||||
dom: '<"top"fl><"toolbar">rt<"bottom"ip><"clear">',
|
||||
columns: [ //这个是显示到界面上的个数据 格式为 {data:'显示的字段名'}
|
||||
{data: 'ClientId'},
|
||||
{data: 'Remark'},
|
||||
{data: 'Remark'},
|
||||
{data: 'Host'},
|
||||
{data: 'Target'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'Target'},
|
||||
],
|
||||
bFilter: false,
|
||||
@@ -88,6 +98,12 @@
|
||||
+ ' </div>'
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: 1,
|
||||
render: function (data, type, row, meta) {
|
||||
return row.Client.Id
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -2,
|
||||
render: function (data, type, row, meta) {
|
||||
@@ -99,6 +115,46 @@
|
||||
render: function (data, type, row, meta) {
|
||||
return change(row.Flow.ExportFlow)
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -4,
|
||||
render: function (data, type, row, meta) {
|
||||
return row.Client.Cnf.P
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -5,
|
||||
render: function (data, type, row, meta) {
|
||||
return row.Client.Cnf.U
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -6,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.Client.Cnf.Mux == "0") {
|
||||
return "不启用"
|
||||
} else {
|
||||
return "启用"
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
{
|
||||
targets: -7,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.Client.Cnf.Crypt == "0") {
|
||||
return "不加密"
|
||||
} else {
|
||||
return "加密"
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
{
|
||||
targets: -8,
|
||||
render: function (data, type, row, meta) {
|
||||
return row.Client.Cnf.Compress
|
||||
}
|
||||
}
|
||||
],
|
||||
buttons: []
|
||||
|
@@ -102,7 +102,7 @@
|
||||
autoWidth: false,
|
||||
ordering: false,
|
||||
ajax: {
|
||||
url: '/index/getserverconfig?type={{.type}}' + "&client_id=" +{{.client_id}},
|
||||
url: '/index/gettunnel?type={{.type}}' + "&client_id=" +{{.client_id}},
|
||||
type: 'POST'
|
||||
},
|
||||
dom: '<"top"fl><"toolbar">rt<"bottom"ip><"clear">',
|
||||
@@ -118,7 +118,7 @@
|
||||
{data: 'U'},
|
||||
{data: 'P'},
|
||||
{data: 'ClientStatus'},
|
||||
{data: 'IsRun'},
|
||||
{data: 'Status'},
|
||||
{data: 'ExportFlow'},
|
||||
{data: 'InletFlow'},
|
||||
{data: "Id"}
|
||||
@@ -127,7 +127,7 @@
|
||||
columnDefs: [{
|
||||
targets: -1,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.IsRun == 1) {
|
||||
if (row.Status == 1) {
|
||||
btn = "<button onclick=\"stop('" + row.Id + "')\" class=\"btn btn-secondary btn-sm\" type=\"button\">关闭</button>"
|
||||
} else {
|
||||
btn = "<button onclick=\"start('" + row.Id + "')\" class=\"btn btn-success btn-sm\" type=\"button\">打开</button>"
|
||||
@@ -137,11 +137,43 @@
|
||||
'<button onclick="del(\'' + row.Id + '\')" type="button" class="btn btn-danger btn-sm">删除</button>' +
|
||||
btn_edit + btn + ' </div>'
|
||||
}
|
||||
}, {
|
||||
targets: 2,
|
||||
render: function (data, type, row, meta) {
|
||||
return row.Client.Id
|
||||
}
|
||||
}, {
|
||||
targets: 5,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
return row.Client.Cnf.Compress
|
||||
} else {
|
||||
return row.Config.Compress
|
||||
}
|
||||
}
|
||||
}, {
|
||||
targets: 8,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
return row.Client.Cnf.U
|
||||
} else {
|
||||
return row.Config.U
|
||||
}
|
||||
}
|
||||
}, {
|
||||
targets: 9,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
return row.Client.Cnf.P
|
||||
} else {
|
||||
return row.Config.P
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -4,
|
||||
render: function (data, type, row, meta) {
|
||||
if (data == 0) {
|
||||
if (data == false) {
|
||||
return "<span class=\"badge badge-pill badge-secondary\">暂停</span>"
|
||||
} else {
|
||||
return "<span class=\"badge badge-pill badge-success\">正常</span>"
|
||||
@@ -151,7 +183,12 @@
|
||||
{
|
||||
targets: -9,
|
||||
render: function (data, type, row, meta) {
|
||||
if (data == "0") {
|
||||
if (row.UseClientCnf == true) {
|
||||
crypt = row.Client.Cnf.Crypt
|
||||
} else {
|
||||
crypt = row.Config.Crypt
|
||||
}
|
||||
if (crypt == "0") {
|
||||
return "不加密"
|
||||
} else {
|
||||
return "加密"
|
||||
@@ -161,7 +198,12 @@
|
||||
{
|
||||
targets: -8,
|
||||
render: function (data, type, row, meta) {
|
||||
if (data == "0") {
|
||||
if (row.UseClientCnf == true) {
|
||||
mux = row.Client.Cnf.Mux
|
||||
} else {
|
||||
mux = row.Config.Mux
|
||||
}
|
||||
if (mux == "0") {
|
||||
return "不启用"
|
||||
} else {
|
||||
return "启用"
|
||||
@@ -171,7 +213,7 @@
|
||||
{
|
||||
targets: -5,
|
||||
render: function (data, type, row, meta) {
|
||||
if (data == 0) {
|
||||
if (row.Client.IsConnect == false) {
|
||||
return "<span class=\"badge badge-pill badge-secondary\">离线</span>"
|
||||
} else {
|
||||
return "<span class=\"badge badge-pill badge-success\">在线</span>"
|
||||
|
Reference in New Issue
Block a user