目录变更

This commit is contained in:
刘河
2019-02-03 17:25:00 +08:00
parent 87f2c8b2ce
commit 74b262503e
27 changed files with 328 additions and 203 deletions

View File

@@ -3,7 +3,7 @@ package controllers
import (
"github.com/astaxie/beego"
"github.com/cnlh/nps/server"
"github.com/cnlh/nps/utils"
"github.com/cnlh/nps/lib"
"strconv"
"strings"
)
@@ -40,7 +40,7 @@ func (s *BaseController) display(tpl ...string) {
}
ip := s.Ctx.Request.Host
if strings.LastIndex(ip, ":") > 0 {
arr := strings.Split(utils.GetHostByName(ip), ":")
arr := strings.Split(lib.GetHostByName(ip), ":")
s.Data["ip"] = arr[0]
}
s.Data["p"] = server.Bridge.TunnelPort

View File

@@ -2,7 +2,7 @@ package controllers
import (
"github.com/cnlh/nps/server"
"github.com/cnlh/nps/utils"
"github.com/cnlh/nps/lib"
)
type ClientController struct {
@@ -28,26 +28,26 @@ func (s *ClientController) Add() {
s.SetInfo("新增")
s.display()
} else {
t := &utils.Client{
VerifyKey: utils.GetRandomString(16),
t := &lib.Client{
VerifyKey: lib.GetRandomString(16),
Id: server.CsvDb.GetClientId(),
Status: true,
Remark: s.GetString("remark"),
Cnf: &utils.Config{
Cnf: &lib.Config{
U: s.GetString("u"),
P: s.GetString("p"),
Compress: s.GetString("compress"),
Crypt: s.GetBoolNoErr("crypt"),
},
RateLimit: s.GetIntNoErr("rate_limit"),
Flow: &utils.Flow{
Flow: &lib.Flow{
ExportFlow: 0,
InletFlow: 0,
FlowLimit: int64(s.GetIntNoErr("flow_limit")),
},
}
if t.RateLimit > 0 {
t.Rate = utils.NewRate(int64(t.RateLimit * 1024))
t.Rate = lib.NewRate(int64(t.RateLimit * 1024))
t.Rate.Start()
}
server.CsvDb.NewClient(t)
@@ -96,7 +96,7 @@ func (s *ClientController) Edit() {
c.Rate.Stop()
}
if c.RateLimit > 0 {
c.Rate = utils.NewRate(int64(c.RateLimit * 1024))
c.Rate = lib.NewRate(int64(c.RateLimit * 1024))
c.Rate.Start()
} else {
c.Rate = nil

View File

@@ -2,7 +2,7 @@ package controllers
import (
"github.com/cnlh/nps/server"
"github.com/cnlh/nps/utils"
"github.com/cnlh/nps/lib"
)
type IndexController struct {
@@ -72,11 +72,11 @@ func (s *IndexController) Add() {
s.SetInfo("新增")
s.display()
} else {
t := &utils.Tunnel{
t := &lib.Tunnel{
TcpPort: s.GetIntNoErr("port"),
Mode: s.GetString("type"),
Target: s.GetString("target"),
Config: &utils.Config{
Config: &lib.Config{
U: s.GetString("u"),
P: s.GetString("p"),
Compress: s.GetString("compress"),
@@ -86,7 +86,7 @@ func (s *IndexController) Add() {
UseClientCnf: s.GetBoolNoErr("use_client"),
Status: true,
Remark: s.GetString("remark"),
Flow: &utils.Flow{},
Flow: &lib.Flow{},
}
var err error
if t.Client, err = server.CsvDb.GetClient(s.GetIntNoErr("client_id")); err != nil {
@@ -213,13 +213,13 @@ func (s *IndexController) AddHost() {
s.SetInfo("新增")
s.display("index/hadd")
} else {
h := &utils.Host{
h := &lib.Host{
Host: s.GetString("host"),
Target: s.GetString("target"),
HeaderChange: s.GetString("header"),
HostChange: s.GetString("hostchange"),
Remark: s.GetString("remark"),
Flow: &utils.Flow{},
Flow: &lib.Flow{},
}
var err error
if h.Client, err = server.CsvDb.GetClient(s.GetIntNoErr("client_id")); err != nil {