mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
客户端配置,端口白名单等
This commit is contained in:
@@ -73,17 +73,10 @@ func (s *IndexController) Add() {
|
||||
s.display()
|
||||
} else {
|
||||
t := &file.Tunnel{
|
||||
TcpPort: s.GetIntNoErr("port"),
|
||||
Port: s.GetIntNoErr("port"),
|
||||
Mode: s.GetString("type"),
|
||||
Target: s.GetString("target"),
|
||||
Config: &file.Config{
|
||||
U: s.GetString("u"),
|
||||
P: s.GetString("p"),
|
||||
Compress: s.GetString("compress"),
|
||||
Crypt: s.GetBoolNoErr("crypt"),
|
||||
},
|
||||
Id: file.GetCsvDb().GetTaskId(),
|
||||
UseClientCnf: s.GetBoolNoErr("use_client"),
|
||||
Status: true,
|
||||
Remark: s.GetString("remark"),
|
||||
Flow: &file.Flow{},
|
||||
@@ -126,16 +119,11 @@ func (s *IndexController) Edit() {
|
||||
if t, err := file.GetCsvDb().GetTask(id); err != nil {
|
||||
s.error()
|
||||
} else {
|
||||
t.TcpPort = s.GetIntNoErr("port")
|
||||
t.Port = s.GetIntNoErr("port")
|
||||
t.Mode = s.GetString("type")
|
||||
t.Target = s.GetString("target")
|
||||
t.Id = id
|
||||
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.UseClientCnf = s.GetBoolNoErr("use_client")
|
||||
t.Remark = s.GetString("remark")
|
||||
if t.Client, err = file.GetCsvDb().GetClient(s.GetIntNoErr("client_id")); err != nil {
|
||||
s.AjaxErr("修改失败")
|
||||
@@ -187,7 +175,7 @@ func (s *IndexController) HostList() {
|
||||
func (s *IndexController) GetHost() {
|
||||
if s.Ctx.Request.Method == "POST" {
|
||||
data := make(map[string]interface{})
|
||||
if h, err := server.GetInfoByHost(s.GetString("host")); err != nil {
|
||||
if h, err := file.GetCsvDb().GetInfoByHost(s.GetString("host")); err != nil {
|
||||
data["code"] = 0
|
||||
} else {
|
||||
data["data"] = h
|
||||
@@ -234,7 +222,7 @@ func (s *IndexController) EditHost() {
|
||||
host := s.GetString("host")
|
||||
if s.Ctx.Request.Method == "GET" {
|
||||
s.Data["menu"] = "host"
|
||||
if h, err := server.GetInfoByHost(host); err != nil {
|
||||
if h, err := file.GetCsvDb().GetInfoByHost(host); err != nil {
|
||||
s.error()
|
||||
} else {
|
||||
s.Data["h"] = h
|
||||
@@ -242,7 +230,7 @@ func (s *IndexController) EditHost() {
|
||||
s.SetInfo("修改")
|
||||
s.display("index/hedit")
|
||||
} else {
|
||||
if h, err := server.GetInfoByHost(host); err != nil {
|
||||
if h, err := file.GetCsvDb().GetInfoByHost(host); err != nil {
|
||||
s.error()
|
||||
} else {
|
||||
h.Host = s.GetString("nhost")
|
||||
|
@@ -30,35 +30,6 @@
|
||||
<input value="{{.client_id}}" class="form-control" type="text" name="client_id"
|
||||
placeholder="客户端id">
|
||||
</div>
|
||||
<div class="form-group" id="use_client">
|
||||
<label class="control-label">是否使用客户端配置</label>
|
||||
<select class="form-control" name="use_client">
|
||||
<option value="1">是</option>
|
||||
<option value="0">否</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="compress">
|
||||
<label class="control-label">数据压缩方式</label>
|
||||
<select class="form-control" name="compress">
|
||||
<option value="">不压缩</option>
|
||||
<option value="snappy">snappy</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="crypt">
|
||||
<label class="control-label">是否加密传输</label>
|
||||
<select class="form-control" name="crypt">
|
||||
<option value="0">不加密</option>
|
||||
<option value="1">加密</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="u">
|
||||
<label class="control-label">验证用户名(仅socks5,web穿透支持)</label>
|
||||
<input class="form-control" type="text" name="u" placeholder="不填则无需验证">
|
||||
</div>
|
||||
<div class="form-group" id="p">
|
||||
<label class="control-label">验证密码(仅socks5,web穿透支持)</label>
|
||||
<input class="form-control" type="text" name="p" placeholder="不填则无需验证">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tile-footer">
|
||||
|
@@ -21,7 +21,7 @@
|
||||
</div>
|
||||
<div class="form-group" id="port">
|
||||
<label class="control-label">监听的端口</label>
|
||||
<input class="form-control" value="{{.t.TcpPort}}" type="text" name="port"
|
||||
<input class="form-control" value="{{.t.Port}}" type="text" name="port"
|
||||
placeholder="公网服务器对外访问端口,例如8024">
|
||||
</div>
|
||||
<div class="form-group" id="target">
|
||||
@@ -34,37 +34,6 @@
|
||||
<input class="form-control" value="{{.t.Client.Id}}" type="text" name="client_id"
|
||||
placeholder="客户端id">
|
||||
</div>
|
||||
<div class="form-group" id="use_client">
|
||||
<label class="control-label">是否使用客户端配置</label>
|
||||
<select class="form-control" name="use_client">
|
||||
<option {{if eq false .t.UseClientCnf}}selected{{end}} value="0">否</option>
|
||||
<option {{if eq true .t.UseClientCnf}}selected{{end}} value="1">是</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="compress">
|
||||
<label class="control-label">数据压缩方式(所有模式均支持)</label>
|
||||
<select class="form-control" name="compress">
|
||||
<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.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="u">
|
||||
<label class="control-label">验证用户名(仅socks5,web穿透支持)</label>
|
||||
<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.Config.P}}" type="text" name="p"
|
||||
placeholder="不填则无需验证">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tile-footer">
|
||||
|
@@ -132,7 +132,7 @@
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="tile">
|
||||
<p><b>单个客户端可以田间多条隧道或者域名解析</b></p>
|
||||
<p><b>单个客户端可以添加多条隧道或者域名解析</b></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -15,7 +15,8 @@
|
||||
<th>用户名</th>
|
||||
<th>密码</th>
|
||||
<th>客户端状态</th>
|
||||
<th>状态</th>
|
||||
<th>设置状态</th>
|
||||
<th>运行状态</th>
|
||||
<th>出口流量</th>
|
||||
<th>入口流量</th>
|
||||
<th>操作</th>
|
||||
@@ -109,7 +110,7 @@
|
||||
{data: 'Id'},
|
||||
{data: 'Remark'},
|
||||
{data: 'ClientId'},
|
||||
{data: 'TcpPort'},
|
||||
{data: 'Port'},
|
||||
{data: 'Target'},
|
||||
{data: 'Compress'},
|
||||
{data: 'Crypt'},
|
||||
@@ -117,6 +118,7 @@
|
||||
{data: 'P'},
|
||||
{data: 'ClientStatus'},
|
||||
{data: 'Status'},
|
||||
{data: 'RunStatus'},
|
||||
{data: 'ExportFlow'},
|
||||
{data: 'InletFlow'},
|
||||
{data: "Id"}
|
||||
@@ -143,29 +145,17 @@
|
||||
}, {
|
||||
targets: 5,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
return row.Client.Cnf.Compress
|
||||
} else {
|
||||
return row.Config.Compress
|
||||
}
|
||||
return row.Client.Cnf.Compress
|
||||
}
|
||||
}, {
|
||||
targets: 7,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
return row.Client.Cnf.U
|
||||
} else {
|
||||
return row.Config.U
|
||||
}
|
||||
return row.Client.Cnf.U
|
||||
}
|
||||
}, {
|
||||
targets: 8,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
return row.Client.Cnf.P
|
||||
} else {
|
||||
return row.Config.P
|
||||
}
|
||||
return row.Client.Cnf.P
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -179,13 +169,19 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -8,
|
||||
targets: -5,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
crypt = row.Client.Cnf.Crypt
|
||||
if (data == false) {
|
||||
return "<span class=\"badge badge-pill badge-secondary\">暂停</span>"
|
||||
} else {
|
||||
crypt = row.Config.Crypt
|
||||
return "<span class=\"badge badge-pill badge-success\">正常</span>"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -9,
|
||||
render: function (data, type, row, meta) {
|
||||
crypt = row.Client.Cnf.Crypt
|
||||
if (crypt == "0") {
|
||||
return "不加密"
|
||||
} else {
|
||||
@@ -194,7 +190,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -5,
|
||||
targets: -6,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.Client.IsConnect == false) {
|
||||
return "<span class=\"badge badge-pill badge-secondary\">离线</span>"
|
||||
|
Reference in New Issue
Block a user