mirror of
https://github.com/ehang-io/nps.git
synced 2025-07-02 04:00:42 +00:00
项目迁移
This commit is contained in:
parent
cbdad1adb0
commit
87f2c8b2ce
@ -2,7 +2,7 @@ package bridge
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -2,80 +2,32 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/astaxie/beego"
|
"github.com/cnlh/nps/client"
|
||||||
"github.com/cnlh/easyProxy/server"
|
"github.com/cnlh/nps/utils"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
_ "github.com/cnlh/nps/utils"
|
||||||
_ "github.com/cnlh/easyProxy/web/routers"
|
"strings"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "v0.0.13"
|
const VERSION = "v0.0.13"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
TcpPort = flag.Int("tcpport", 0, "客户端与服务端通信端口")
|
serverAddr = flag.String("server", "", "服务器地址ip:端口")
|
||||||
httpPort = flag.Int("httpport", 8024, "对外监听的端口")
|
verifyKey = flag.String("vkey", "", "验证密钥")
|
||||||
rpMode = flag.String("mode", "webServer", "启动模式")
|
logType = flag.String("log", "stdout", "日志输出方式(stdout|file)")
|
||||||
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() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
var test bool
|
utils.InitDaemon("client")
|
||||||
if len(os.Args) > 1 && os.Args[1] == "test" {
|
if *logType == "stdout" {
|
||||||
test = true
|
utils.InitLogFile("client", true)
|
||||||
}
|
|
||||||
utils.InitDaemon("server")
|
|
||||||
if *logType == "stdout" || test {
|
|
||||||
utils.InitLogFile("server", true)
|
|
||||||
} else {
|
} else {
|
||||||
utils.InitLogFile("server", false)
|
utils.InitLogFile("client", false)
|
||||||
}
|
}
|
||||||
task := &utils.Tunnel{
|
stop := make(chan int)
|
||||||
TcpPort: *httpPort,
|
for _, v := range strings.Split(*verifyKey, ",") {
|
||||||
Mode: *rpMode,
|
utils.Println("客户端启动,连接:", *serverAddr, " 验证令牌:", v)
|
||||||
Target: *tunnelTarget,
|
go client.NewRPClient(*serverAddr, v).Start()
|
||||||
Config: &utils.Config{
|
|
||||||
U: *u,
|
|
||||||
P: *p,
|
|
||||||
Compress: *compress,
|
|
||||||
Crypt: utils.GetBoolByStr(*crypt),
|
|
||||||
},
|
|
||||||
Flow: &utils.Flow{},
|
|
||||||
UseClientCnf: false,
|
|
||||||
}
|
}
|
||||||
if *VerifyKey != "" {
|
<-stop
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
@ -2,32 +2,80 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/cnlh/easyProxy/client"
|
"github.com/astaxie/beego"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/server"
|
||||||
_ "github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"strings"
|
_ "github.com/cnlh/nps/web/routers"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "v0.0.13"
|
const VERSION = "v0.0.13"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
serverAddr = flag.String("server", "", "服务器地址ip:端口")
|
TcpPort = flag.Int("tcpport", 0, "客户端与服务端通信端口")
|
||||||
verifyKey = flag.String("vkey", "", "验证密钥")
|
httpPort = flag.Int("httpport", 8024, "对外监听的端口")
|
||||||
logType = flag.String("log", "stdout", "日志输出方式(stdout|file)")
|
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() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
utils.InitDaemon("client")
|
var test bool
|
||||||
if *logType == "stdout" {
|
if len(os.Args) > 1 && os.Args[1] == "test" {
|
||||||
utils.InitLogFile("client", true)
|
test = true
|
||||||
|
}
|
||||||
|
utils.InitDaemon("server")
|
||||||
|
if *logType == "stdout" || test {
|
||||||
|
utils.InitLogFile("server", true)
|
||||||
} else {
|
} else {
|
||||||
utils.InitLogFile("client", false)
|
utils.InitLogFile("server", false)
|
||||||
}
|
}
|
||||||
stop := make(chan int)
|
task := &utils.Tunnel{
|
||||||
for _, v := range strings.Split(*verifyKey, ",") {
|
TcpPort: *httpPort,
|
||||||
utils.Println("客户端启动,连接:", *serverAddr, " 验证令牌:", v)
|
Mode: *rpMode,
|
||||||
go client.NewRPClient(*serverAddr, v).Start()
|
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)
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/cnlh/easyProxy/bridge"
|
"github.com/cnlh/nps/bridge"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/cnlh/easyProxy/bridge"
|
"github.com/cnlh/nps/bridge"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
|
@ -2,8 +2,8 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/cnlh/easyProxy/bridge"
|
"github.com/cnlh/nps/bridge"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -3,8 +3,8 @@ package server
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/cnlh/easyProxy/bridge"
|
"github.com/cnlh/nps/bridge"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -3,8 +3,8 @@ package server
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/cnlh/easyProxy/bridge"
|
"github.com/cnlh/nps/bridge"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cnlh/easyProxy/bridge"
|
"github.com/cnlh/nps/bridge"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -2,8 +2,8 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/cnlh/easyProxy/server"
|
"github.com/cnlh/nps/server"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cnlh/easyProxy/server"
|
"github.com/cnlh/nps/server"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClientController struct {
|
type ClientController struct {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cnlh/easyProxy/server"
|
"github.com/cnlh/nps/server"
|
||||||
"github.com/cnlh/easyProxy/utils"
|
"github.com/cnlh/nps/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IndexController struct {
|
type IndexController struct {
|
||||||
|
@ -2,7 +2,7 @@ package routers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/cnlh/easyProxy/web/controllers"
|
"github.com/cnlh/nps/web/controllers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user