mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
redo web UI |web close| client log |system info |p2p |max、ump optimization
This commit is contained in:
@@ -124,6 +124,7 @@ func (s *Csv) GetTaskId() int {
|
||||
s.TaskIncreaseId++
|
||||
return s.TaskIncreaseId
|
||||
}
|
||||
|
||||
func (s *Csv) GetHostId() int {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
@@ -147,7 +148,7 @@ func (s *Csv) GetIdByVerifyKey(vKey string, addr string) (int, error) {
|
||||
|
||||
func (s *Csv) NewTask(t *Tunnel) error {
|
||||
for _, v := range s.Tasks {
|
||||
if v.Mode == "secretServer" && v.Password == t.Password {
|
||||
if v.Mode == "secret" && v.Password == t.Password {
|
||||
return errors.New(fmt.Sprintf("Secret mode keys %s must be unique", t.Password))
|
||||
}
|
||||
}
|
||||
@@ -256,7 +257,7 @@ func (s *Csv) LoadClientFromCsv() {
|
||||
U: item[4],
|
||||
P: item[5],
|
||||
Crypt: common.GetBoolByStr(item[6]),
|
||||
Compress: item[7],
|
||||
Compress: common.GetBoolByStr(item[7]),
|
||||
},
|
||||
MaxConn: common.GetIntNoErrByStr(item[10]),
|
||||
}
|
||||
@@ -327,10 +328,14 @@ func (s *Csv) IsHostExist(h *Host) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *Csv) NewHost(t *Host) {
|
||||
func (s *Csv) NewHost(t *Host) error {
|
||||
if s.IsHostExist(t) {
|
||||
return errors.New("host has exist")
|
||||
}
|
||||
t.Flow = new(Flow)
|
||||
s.Hosts = append(s.Hosts, t)
|
||||
s.StoreHostToCsv()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Csv) UpdateHost(t *Host) error {
|
||||
@@ -535,7 +540,7 @@ func (s *Csv) StoreClientsToCsv() {
|
||||
client.Cnf.U,
|
||||
client.Cnf.P,
|
||||
common.GetStrByBool(client.Cnf.Crypt),
|
||||
client.Cnf.Compress,
|
||||
strconv.FormatBool(client.Cnf.Compress),
|
||||
strconv.Itoa(client.RateLimit),
|
||||
strconv.Itoa(int(client.Flow.FlowLimit)),
|
||||
strconv.Itoa(int(client.MaxConn)),
|
||||
|
@@ -2,7 +2,6 @@ package file
|
||||
|
||||
import (
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
"math"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
@@ -14,7 +13,7 @@ type Flow struct {
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
func (s *Flow) Add(in, out int) {
|
||||
func (s *Flow) Add(in, out int64) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
s.InletFlow += int64(in)
|
||||
@@ -57,15 +56,6 @@ func NewClient(vKey string, noStore bool, noDisplay bool) *Client {
|
||||
NoDisplay: noDisplay,
|
||||
}
|
||||
}
|
||||
func (s *Client) GetId() int {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
if s.id == math.MaxInt32 {
|
||||
s.id = 0
|
||||
}
|
||||
s.id++
|
||||
return s.id
|
||||
}
|
||||
|
||||
func (s *Client) CutConn() {
|
||||
s.Lock()
|
||||
@@ -104,12 +94,10 @@ type Tunnel struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
U string //socks5验证用户名
|
||||
P string //socks5验证密码
|
||||
Compress string //压缩方式
|
||||
Crypt bool //是否加密
|
||||
CompressEncode int //加密方式
|
||||
CompressDecode int //解密方式
|
||||
U string //socks5验证用户名
|
||||
P string //socks5验证密码
|
||||
Compress bool //压缩方式
|
||||
Crypt bool //是否加密
|
||||
}
|
||||
|
||||
type Host struct {
|
||||
|
Reference in New Issue
Block a user