diff --git a/bridge/bridge.go b/bridge/bridge.go index 0569b89..de68f9a 100755 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -2,7 +2,7 @@ package bridge import ( "errors" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/utils" "net" "sync" "time" diff --git a/client/client.go b/client/client.go index a5ad630..6ea04ce 100755 --- a/client/client.go +++ b/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/utils" "net" "sync" "time" diff --git a/cmd/npc/npc.go b/cmd/npc/npc.go index 709926f..96dc5e9 100644 --- a/cmd/npc/npc.go +++ b/cmd/npc/npc.go @@ -2,80 +2,32 @@ package main import ( "flag" - "github.com/astaxie/beego" - "github.com/cnlh/easyProxy/server" - "github.com/cnlh/easyProxy/utils" - _ "github.com/cnlh/easyProxy/web/routers" - "os" + "github.com/cnlh/nps/client" + "github.com/cnlh/nps/utils" + _ "github.com/cnlh/nps/utils" + "strings" ) const VERSION = "v0.0.13" var ( - TcpPort = flag.Int("tcpport", 0, "客户端与服务端通信端口") - httpPort = flag.Int("httpport", 8024, "对外监听的端口") - rpMode = flag.String("mode", "webServer", "启动模式") - tunnelTarget = flag.String("target", "127.0.0.1:80", "远程目标") - VerifyKey = flag.String("vkey", "", "验证密钥") - u = flag.String("u", "", "验证用户名(socks5和web)") - p = flag.String("p", "", "验证密码(socks5和web)") - compress = flag.String("compress", "", "数据压缩方式(snappy)") - crypt = flag.String("crypt", "false", "是否加密(true|false)") - logType = flag.String("log", "stdout", "日志输出方式(stdout|file)") + serverAddr = flag.String("server", "", "服务器地址ip:端口") + verifyKey = flag.String("vkey", "", "验证密钥") + logType = flag.String("log", "stdout", "日志输出方式(stdout|file)") ) func main() { flag.Parse() - var test bool - if len(os.Args) > 1 && os.Args[1] == "test" { - test = true - } - utils.InitDaemon("server") - if *logType == "stdout" || test { - utils.InitLogFile("server", true) + utils.InitDaemon("client") + if *logType == "stdout" { + utils.InitLogFile("client", true) } else { - utils.InitLogFile("server", false) + utils.InitLogFile("client", false) } - task := &utils.Tunnel{ - TcpPort: *httpPort, - Mode: *rpMode, - Target: *tunnelTarget, - Config: &utils.Config{ - U: *u, - P: *p, - Compress: *compress, - Crypt: utils.GetBoolByStr(*crypt), - }, - Flow: &utils.Flow{}, - UseClientCnf: false, + stop := make(chan int) + for _, v := range strings.Split(*verifyKey, ",") { + utils.Println("客户端启动,连接:", *serverAddr, " 验证令牌:", v) + go client.NewRPClient(*serverAddr, v).Start() } - if *VerifyKey != "" { - c := &utils.Client{ - Id: 0, - VerifyKey: *VerifyKey, - Addr: "", - Remark: "", - Status: true, - IsConnect: false, - Cnf: &utils.Config{}, - Flow: &utils.Flow{}, - } - c.Cnf.CompressDecode, c.Cnf.CompressEncode = utils.GetCompressType(c.Cnf.Compress) - server.CsvDb.Clients[0] = c - task.Client = c - } - if *TcpPort == 0 { - p, err := beego.AppConfig.Int("tcpport") - if err == nil && *rpMode == "webServer" { - *TcpPort = p - } else { - *TcpPort = 8284 - } - } - utils.Println("服务端启动,监听tcp服务端端口:", *TcpPort) - task.Config.CompressDecode, task.Config.CompressEncode = utils.GetCompressType(task.Config.Compress) - if *rpMode != "webServer" { - server.CsvDb.Tasks[0] = task - } - server.StartNewServer(*TcpPort, task, test) + <-stop } diff --git a/cmd/nps/nps.go b/cmd/nps/nps.go index b41f486..4c6a28c 100644 --- a/cmd/nps/nps.go +++ b/cmd/nps/nps.go @@ -2,32 +2,80 @@ package main import ( "flag" - "github.com/cnlh/easyProxy/client" - "github.com/cnlh/easyProxy/utils" - _ "github.com/cnlh/easyProxy/utils" - "strings" + "github.com/astaxie/beego" + "github.com/cnlh/nps/server" + "github.com/cnlh/nps/utils" + _ "github.com/cnlh/nps/web/routers" + "os" ) const VERSION = "v0.0.13" var ( - serverAddr = flag.String("server", "", "服务器地址ip:端口") - verifyKey = flag.String("vkey", "", "验证密钥") - logType = flag.String("log", "stdout", "日志输出方式(stdout|file)") + TcpPort = flag.Int("tcpport", 0, "客户端与服务端通信端口") + httpPort = flag.Int("httpport", 8024, "对外监听的端口") + rpMode = flag.String("mode", "webServer", "启动模式") + tunnelTarget = flag.String("target", "127.0.0.1:80", "远程目标") + VerifyKey = flag.String("vkey", "", "验证密钥") + u = flag.String("u", "", "验证用户名(socks5和web)") + p = flag.String("p", "", "验证密码(socks5和web)") + compress = flag.String("compress", "", "数据压缩方式(snappy)") + crypt = flag.String("crypt", "false", "是否加密(true|false)") + logType = flag.String("log", "stdout", "日志输出方式(stdout|file)") ) func main() { flag.Parse() - utils.InitDaemon("client") - if *logType == "stdout" { - utils.InitLogFile("client", true) + var test bool + if len(os.Args) > 1 && os.Args[1] == "test" { + test = true + } + utils.InitDaemon("server") + if *logType == "stdout" || test { + utils.InitLogFile("server", true) } else { - utils.InitLogFile("client", false) + utils.InitLogFile("server", false) } - stop := make(chan int) - for _, v := range strings.Split(*verifyKey, ",") { - utils.Println("客户端启动,连接:", *serverAddr, " 验证令牌:", v) - go client.NewRPClient(*serverAddr, v).Start() + task := &utils.Tunnel{ + TcpPort: *httpPort, + Mode: *rpMode, + Target: *tunnelTarget, + Config: &utils.Config{ + U: *u, + P: *p, + Compress: *compress, + Crypt: utils.GetBoolByStr(*crypt), + }, + Flow: &utils.Flow{}, + UseClientCnf: false, } - <-stop + if *VerifyKey != "" { + c := &utils.Client{ + Id: 0, + VerifyKey: *VerifyKey, + Addr: "", + Remark: "", + Status: true, + IsConnect: false, + Cnf: &utils.Config{}, + Flow: &utils.Flow{}, + } + c.Cnf.CompressDecode, c.Cnf.CompressEncode = utils.GetCompressType(c.Cnf.Compress) + server.CsvDb.Clients[0] = c + task.Client = c + } + if *TcpPort == 0 { + p, err := beego.AppConfig.Int("tcpport") + if err == nil && *rpMode == "webServer" { + *TcpPort = p + } else { + *TcpPort = 8284 + } + } + utils.Println("服务端启动,监听tcp服务端端口:", *TcpPort) + task.Config.CompressDecode, task.Config.CompressEncode = utils.GetCompressType(task.Config.Compress) + if *rpMode != "webServer" { + server.CsvDb.Tasks[0] = task + } + server.StartNewServer(*TcpPort, task, test) } diff --git a/server/base.go b/server/base.go index e5cf236..51e6ea3 100644 --- a/server/base.go +++ b/server/base.go @@ -2,8 +2,8 @@ package server import ( "errors" - "github.com/cnlh/easyProxy/bridge" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/bridge" + "github.com/cnlh/nps/utils" "net" "net/http" "sync" diff --git a/server/http.go b/server/http.go index a158a44..b5c6f53 100644 --- a/server/http.go +++ b/server/http.go @@ -4,8 +4,8 @@ import ( "bufio" "crypto/tls" "github.com/astaxie/beego" - "github.com/cnlh/easyProxy/bridge" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/bridge" + "github.com/cnlh/nps/utils" "net" "net/http" "net/http/httputil" diff --git a/server/server.go b/server/server.go index d7fec8e..f52f7f6 100644 --- a/server/server.go +++ b/server/server.go @@ -2,8 +2,8 @@ package server import ( "errors" - "github.com/cnlh/easyProxy/bridge" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/bridge" + "github.com/cnlh/nps/utils" "log" "os" "reflect" diff --git a/server/socks5.go b/server/socks5.go index 08d1aa6..885a244 100755 --- a/server/socks5.go +++ b/server/socks5.go @@ -3,8 +3,8 @@ package server import ( "encoding/binary" "errors" - "github.com/cnlh/easyProxy/bridge" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/bridge" + "github.com/cnlh/nps/utils" "io" "net" "strconv" diff --git a/server/tcp.go b/server/tcp.go index b287d9b..5daaa32 100755 --- a/server/tcp.go +++ b/server/tcp.go @@ -3,8 +3,8 @@ package server import ( "errors" "github.com/astaxie/beego" - "github.com/cnlh/easyProxy/bridge" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/bridge" + "github.com/cnlh/nps/utils" "net" "strings" ) diff --git a/server/udp.go b/server/udp.go index 9557130..274d7c1 100755 --- a/server/udp.go +++ b/server/udp.go @@ -1,8 +1,8 @@ package server import ( - "github.com/cnlh/easyProxy/bridge" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/bridge" + "github.com/cnlh/nps/utils" "net" "strings" ) diff --git a/web/controllers/base.go b/web/controllers/base.go index 017f528..c7a1d03 100755 --- a/web/controllers/base.go +++ b/web/controllers/base.go @@ -2,8 +2,8 @@ package controllers import ( "github.com/astaxie/beego" - "github.com/cnlh/easyProxy/server" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/server" + "github.com/cnlh/nps/utils" "strconv" "strings" ) diff --git a/web/controllers/client.go b/web/controllers/client.go index 6f8eb43..c1fb979 100644 --- a/web/controllers/client.go +++ b/web/controllers/client.go @@ -1,8 +1,8 @@ package controllers import ( - "github.com/cnlh/easyProxy/server" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/server" + "github.com/cnlh/nps/utils" ) type ClientController struct { diff --git a/web/controllers/index.go b/web/controllers/index.go index 0994671..26a0601 100755 --- a/web/controllers/index.go +++ b/web/controllers/index.go @@ -1,8 +1,8 @@ package controllers import ( - "github.com/cnlh/easyProxy/server" - "github.com/cnlh/easyProxy/utils" + "github.com/cnlh/nps/server" + "github.com/cnlh/nps/utils" ) type IndexController struct { diff --git a/web/routers/router.go b/web/routers/router.go index e16d8bd..5c820e2 100755 --- a/web/routers/router.go +++ b/web/routers/router.go @@ -2,7 +2,7 @@ package routers import ( "github.com/astaxie/beego" - "github.com/cnlh/easyProxy/web/controllers" + "github.com/cnlh/nps/web/controllers" ) func init() {