mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
New functions
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/cnlh/nps/lib/crypt"
|
||||
"github.com/cnlh/nps/lib/file"
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
"github.com/cnlh/nps/server"
|
||||
@@ -31,7 +30,7 @@ func (s *ClientController) Add() {
|
||||
s.display()
|
||||
} else {
|
||||
t := &file.Client{
|
||||
VerifyKey: crypt.GetRandomString(16),
|
||||
VerifyKey: s.GetString("vkey"),
|
||||
Id: file.GetCsvDb().GetClientId(),
|
||||
Status: true,
|
||||
Remark: s.GetString("remark"),
|
||||
@@ -53,7 +52,9 @@ func (s *ClientController) Add() {
|
||||
t.Rate = rate.NewRate(int64(t.RateLimit * 1024))
|
||||
t.Rate.Start()
|
||||
}
|
||||
file.GetCsvDb().NewClient(t)
|
||||
if err := file.GetCsvDb().NewClient(t); err != nil {
|
||||
s.AjaxErr(err.Error())
|
||||
}
|
||||
s.AjaxOk("添加成功")
|
||||
}
|
||||
}
|
||||
@@ -88,6 +89,10 @@ func (s *ClientController) Edit() {
|
||||
if c, err := file.GetCsvDb().GetClient(id); err != nil {
|
||||
s.error()
|
||||
} else {
|
||||
if !file.GetCsvDb().VerifyVkey(s.GetString("vkey"), c.Id) {
|
||||
s.AjaxErr("Vkey duplicate, please reset")
|
||||
}
|
||||
c.VerifyKey = s.GetString("vkey")
|
||||
c.Remark = s.GetString("remark")
|
||||
c.Cnf.U = s.GetString("u")
|
||||
c.Cnf.P = s.GetString("p")
|
||||
|
@@ -28,6 +28,10 @@
|
||||
<label class="control-label">验证密码(仅socks5,web穿透支持)</label>
|
||||
<input class="form-control" type="text" name="p" placeholder="不填则无需验证">
|
||||
</div>
|
||||
<div class="form-group" id="vkey">
|
||||
<label class="control-label">客户端连接密钥(唯一、不填将会自动生成)</label>
|
||||
<input class="form-control" type="text" name="vkey" placeholder="客户端连接密钥">
|
||||
</div>
|
||||
<div class="form-group" id="compress">
|
||||
<label class="control-label">数据压缩方式</label>
|
||||
<select class="form-control" name="compress">
|
||||
|
@@ -34,6 +34,11 @@
|
||||
<input class="form-control" value="{{.c.Cnf.P}}" type="text" name="p"
|
||||
placeholder="不填则无需验证">
|
||||
</div>
|
||||
<div class="form-group" id="vkey">
|
||||
<label class="control-label">客户端连接密钥(唯一、不填将会自动生成)</label>
|
||||
<input class="form-control" value="{{.c.VerifyKey}}" type="text" name="vkey"
|
||||
placeholder="客户端连接密钥">
|
||||
</div>
|
||||
<div class="form-group" id="compress">
|
||||
<label class="control-label">数据压缩方式(所有模式均支持)</label>
|
||||
<select class="form-control" name="compress">
|
||||
|
Reference in New Issue
Block a user