Compare commits

...
33 Commits
Author SHA1 Message Date
yisier bf622b87ba 隧道列表排序 2024-11-07 15:40:37 +08:00
yisier 700332ef0d Merge pull request #177 from axfinn/fix/nat_0614
fix: 修复nat参数指定stun服务错误问题
2024-11-07 14:59:16 +08:00
yisier 02d8c6b561 - 在 Client 结构中添加 CreateTime 字段,用于记录客户端创建时间
- 在添加客户端时设置创建时间
- 在客户端列表页面显示创建时间- 修复了客户端限速单位不统一的问题
- 增加了从下拉菜单选择客户端的功能
- 优化了编辑客户端后不会刷新页面的问题
-修复了隧道数量限制无法统计域名映射的问题
2024-11-07 14:49:49 +08:00
yisier f7c04f3271 Update README.md 2024-09-27 22:29:49 +08:00
yisier 257816e793 Update README.md 2024-09-26 15:05:24 +08:00
yisier 00e16e88ff 客户端限速单位不统一 2024-09-03 11:26:43 -04:00
yisier c265f0ea2a Update README.md 2024-08-31 18:14:26 -04:00
axiu 4085181585 fix: 修复nat参数指定stun服务错误问题 2024-06-14 10:42:39 +08:00
yisier 55ee7acd97 配置文件多了空格 2024-06-04 18:03:02 +08:00
yisier a1894ca898 darwin arm64 2024-06-04 15:46:15 +08:00
yisier 191b21b8cd v0.26.19 2024-06-01 22:25:27 +08:00
yisier c5d96a4105 v0.26.19 2024-06-01 22:09:11 +08:00
yisier 37b4e234ef Update pkg.yml 2024-06-01 21:58:30 +08:00
yisier 955687ba31 Merge remote-tracking branch 'origin/master' into dev 2024-05-28 17:58:26 +08:00
yisier 22018dab14 v0.26.19 2024-05-28 17:56:36 +08:00
yisier 7084d7df85 1.移除版本强校验
2.客户端支持启动多个vkey
2024-03-19 15:43:31 +08:00
yisier 83a5e8eb99 Update README.md 2024-03-18 13:50:02 +08:00
yisier e505eaa72c Merge remote-tracking branch 'origin/master' 2024-03-07 12:00:11 +08:00
yisier d4fdd0843c README.md 2024-03-07 11:59:52 +08:00
yisier eeafa867a5 Update README.md 2024-03-07 11:30:10 +08:00
yisier 352ac408ed Update README.md 2024-03-07 11:29:48 +08:00
yisier 9fedfa1023 Update README.md 2024-02-28 15:43:45 +08:00
yisier c0afe54bc3 Update README.md 2024-02-28 15:43:34 +08:00
yisier 91bcc55fbf tls 独立端口 2024-02-27 16:57:47 +08:00
yisier 783e475872 version 2024-01-31 23:00:34 +08:00
yisier e53df0cede 版本号将继续沿用 0.26.xx 2024-01-31 22:53:30 +08:00
yisier c44a5dade8 http optimize 2024-01-05 21:00:13 +08:00
yisier 19a1e31904 log 2024-01-02 22:57:48 +08:00
yisier bc9525938a Merge pull request #116 from lesteryou/logs
log中remoteAddr优先从X-Forwarded-For中获取
2024-01-02 22:28:28 +08:00
yisier 605b6af9d5 tls 流量加密 2024-01-02 22:02:03 +08:00
lesteryou 0c25fca0f8 Merge branch 'master' into logs 2023-08-21 14:44:07 +08:00
lesteryou 790d985afc log中remoteAddr优先从X-Forwarded-For中获取 2023-08-21 14:12:45 +08:00
yisier 4a347fe301 新增一次客户端,列表会增加2个一样的客户端,Bug 修复 2023-06-05 23:34:22 +08:00
44 changed files with 884 additions and 239 deletions
+4 -2
View File
@@ -16,7 +16,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.22
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
@@ -64,10 +64,12 @@ jobs:
linux_mips_server.tar.gz
darwin_amd64_client.tar.gz
darwin_amd64_server.tar.gz
darwin_arm64_client.tar.gz
darwin_arm64_server.tar.gz
windows_386_client.tar.gz
windows_386_server.tar.gz
windows_amd64_client.tar.gz
windows_amd64_server.tar.gz
npc_sdk.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.15 as builder
FROM golang:1.22 as builder
ARG GOPROXY=direct
WORKDIR /go/src/ehang.io/nps
COPY . .
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.15 as builder
FROM golang:1.22 as builder
ARG GOPROXY=direct
WORKDIR /go/src/ehang.io/nps
COPY . .
+51 -2
View File
@@ -3,15 +3,64 @@
[README](https://github.com/ehang-io/nps/blob/master/README.md)|[中文文档](https://github.com/ehang-io/nps/blob/master/README_zh.md)
# 说明
由于nps已经有一年多的时间没有更新了,存留了不少bug和未完善的功能。
由于nps已经有二年多的时间没有更新了,存留了不少bug和未完善的功能。
此版本基于 nps 0.26.10的基础上二次开发而来。
***DockerHub***: [NPS](https://hub.docker.com/r/yisier1/nps) [NPC](https://hub.docker.com/r/yisier1/npc)
# 交流群
聊天灌水QQ群:770569342,619833483(已满)
## 更新日志
# 公益云内网穿透
https://natnps.com/
公益NPS内网穿透服务,长期免费,6M带宽,3条隧道,不限流量,欢迎来嫖,自行注册账号。
# 特价云服务器
国内BGP,游戏开服,2核 2G 15M上行 25元/月,[专属连接,首月5折](https://www.rainyun.com/MjY0MzY1_)
# 捐赠
![image](image/new/payCode.png)
## 更新日志
- 2024-11-07 v0.26.20
新增:
- 客户端增加创建时间
修复:
- 客户端限速单位不统一 [#185](https://github.com/yisier/nps/issues/185)
- 增加从下拉选择客户端,隧道列表排序,新增编辑后不会刷新界面 [#183](https://github.com/yisier/nps/issues/183)
- 隧道数量限制无法统计域名映射 [#209](https://github.com/yisier/nps/issues/209)
- 2024-06-01 v0.26.19
- golang 版本升级到 1.22.
- 增加自动https,自动将http 重定向(301)到 https.
- 客户端命令行方式启动支持多个隧道ID,使用逗号拼接,示例:`npc -server=xxx:8024 -vkey=ytkpyr0er676m0r7,iwnbjfbvygvzyzzt` .
- 移除 nps.conf 参数 `https_just_proxy` , 调整 https 处理逻辑,如果上传了 https 证书,则由nps负责SSL (此方式可以获取真实IP),
否则走端口转发模式(使用本地证书,nps 获取不到真实IP), 如下图所示。
![image](image/new/https.png)
- 2024-02-27 v0.26.18
***新增***:nps.conf 新增 `tls_bridge_port=8025` 参数,当 `tls_enable=true` 时,nps 会监听8025端口,作为 tls 的连接端口。
客户端可以选择连接 tls 端口或者非 tls 端口: `npc.exe -server=xxx:8024 -vkey=xxx` 或 `npc.exe -server=xxx:8025 -vkey=xxx -tls_enable=true`
- 2024-01-31 v0.26.17
***说明***:考虑到 npc 历史版本客户端众多,版本号不同旧版本客户端无法连接,为了兼容,仓库版本号将继续沿用 0.26.xx
- 2024-01-02 v0.27.01 (已作废,功能移动到v0.26.17 版本)
***新增***:tls 流量加密,(客户端忽略证书校验,谨慎使用,客户端与服务端需要同时开启,或同时关闭),使用方式:
服务端:nps.conf `tls_enable=true`;
客户端:npc.conf `tls_enable=true` 或者 `npc.exe -server=xxx -vkey=xxx -tls_enable=true`
- 2023-06-01 v0.26.16
***修复***:https 流量不统计 Bug 修复。
***新增***:新增全局黑名单IP,用于防止被肉鸡扫描端口或被恶意攻击。
+42 -16
View File
@@ -1,6 +1,8 @@
package bridge
import (
"crypto/tls"
_ "crypto/tls"
"ehang.io/nps/lib/nps_mux"
"encoding/binary"
"errors"
@@ -23,6 +25,8 @@ import (
"github.com/astaxie/beego/logs"
)
var ServerTlsEnable bool = false
type Client struct {
tunnel *nps_mux.Mux
signal *conn.Conn
@@ -76,20 +80,42 @@ func (s *Bridge) StartTunnel() error {
s.cliProcess(conn.NewConn(c))
})
} else {
listener, err := connection.GetBridgeListener(s.tunnelType)
if err != nil {
logs.Error(err)
os.Exit(0)
return err
go func() {
listener, err := connection.GetBridgeListener(s.tunnelType)
if err != nil {
logs.Error(err)
os.Exit(0)
return
}
conn.Accept(listener, func(c net.Conn) {
s.cliProcess(conn.NewConn(c))
})
}()
// tls
if ServerTlsEnable {
go func() {
// 监听TLS 端口
tlsBridgePort := beego.AppConfig.DefaultInt("tls_bridge_port", 8025)
logs.Info("tls server start, the bridge type is %s, the tls bridge port is %d", "tcp", tlsBridgePort)
tlsListener, tlsErr := net.ListenTCP("tcp", &net.TCPAddr{net.ParseIP(beego.AppConfig.String("bridge_ip")), tlsBridgePort, ""})
if tlsErr != nil {
logs.Error(tlsErr)
os.Exit(0)
return
}
conn.Accept(tlsListener, func(c net.Conn) {
s.cliProcess(conn.NewConn(tls.Server(c, &tls.Config{Certificates: []tls.Certificate{crypt.GetCert()}})))
})
}()
}
conn.Accept(listener, func(c net.Conn) {
s.cliProcess(conn.NewConn(c))
})
}
return nil
}
//get health information form client
// get health information form client
func (s *Bridge) GetHealthFromClient(id int, c *conn.Conn) {
for {
if info, status, err := c.GetHealthInfo(); err != nil {
@@ -154,7 +180,7 @@ func (s *Bridge) GetHealthFromClient(id int, c *conn.Conn) {
s.DelClient(id)
}
//验证失败,返回错误验证flag,并且关闭连接
// 验证失败,返回错误验证flag,并且关闭连接
func (s *Bridge) verifyError(c *conn.Conn) {
c.Write([]byte(common.VERIFY_EER))
}
@@ -171,9 +197,9 @@ func (s *Bridge) cliProcess(c *conn.Conn) {
}
//version check
if b, err := c.GetShortLenContent(); err != nil || string(b) != version.GetVersion() {
logs.Info("The client %s version does not match", c.Conn.RemoteAddr())
c.Close()
return
//logs.Info("The client %s version does not match", c.Conn.RemoteAddr())
//c.Close()
//return
}
//version get
var vs []byte
@@ -224,7 +250,7 @@ func (s *Bridge) DelClient(id int) {
}
}
//use different
// use different
func (s *Bridge) typeDeal(typeVal string, c *conn.Conn, id int, vs string) {
isPub := file.GetDb().IsPubClient(id)
switch typeVal {
@@ -303,7 +329,7 @@ func (s *Bridge) typeDeal(typeVal string, c *conn.Conn, id int, vs string) {
return
}
//register ip
// register ip
func (s *Bridge) register(c *conn.Conn) {
var hour int32
if err := binary.Read(c, binary.LittleEndian, &hour); err == nil {
@@ -387,7 +413,7 @@ func (s *Bridge) ping() {
}
}
//get config and add task from client config
// get config and add task from client config
func (s *Bridge) getConfig(c *conn.Conn, isPub bool, client *file.Client) {
var fail bool
loop:
+11
View File
@@ -78,6 +78,11 @@ CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -sta
tar -czvf darwin_amd64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
tar -czvf darwin_arm64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go
tar -czvf linux_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps
@@ -146,6 +151,12 @@ CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -sta
tar -czvf darwin_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go
tar -czvf darwin_arm64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go
tar -czvf windows_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe
+1 -1
View File
@@ -1,5 +1,5 @@
#/bash/sh
export VERSION=0.26.16
export VERSION=0.26.20
export GOPROXY=direct
sudo apt-get update
+6 -1
View File
@@ -7,6 +7,7 @@ import (
"net"
"net/http"
"strconv"
"strings"
"sync"
"time"
@@ -197,7 +198,11 @@ func (s *TRPClient) handleChan(src net.Conn) {
targetConn.Close()
break
} else {
logs.Trace("http request, method %s, host %s, url %s, remote address %s", r.Method, r.Host, r.URL.Path, r.RemoteAddr)
remoteAddr := strings.TrimSpace(r.Header.Get("X-Forwarded-For"))
if len(remoteAddr) == 0 {
remoteAddr = r.RemoteAddr
}
logs.Trace("http request, method %s, host %s, url %s, remote address %s", r.Method, r.Host, r.URL.Path, remoteAddr)
r.Write(targetConn)
}
}
+43 -5
View File
@@ -2,6 +2,7 @@ package client
import (
"bufio"
"crypto/tls"
"encoding/base64"
"encoding/binary"
"errors"
@@ -29,6 +30,16 @@ import (
"golang.org/x/net/proxy"
)
var tlsEnable1 = false
func SetTlsEnable(tlsEnable11 bool) {
tlsEnable1 = tlsEnable11
}
func GetTlsEnable() bool {
return tlsEnable1
}
func GetTaskStatus(path string) {
cnf, err := config.NewConfig(path)
if err != nil {
@@ -96,6 +107,8 @@ func StartFromFile(path string) {
}
logs.Info("Loading configuration file %s successfully", path)
SetTlsEnable(cnf.CommonConfig.TlsEnable)
logs.Info("the version of client is %s, the core version of client is %s,tls enable is %t", version.VERSION, version.GetVersion(), GetTlsEnable())
re:
if first || cnf.CommonConfig.AutoReconnection {
if !first {
@@ -202,7 +215,32 @@ func NewConn(tp string, vkey string, server string, connType string, proxyUrl st
connection, err = NewHttpProxyConn(u, server)
}
} else {
connection, err = net.Dial("tcp", server)
if GetTlsEnable() {
//tls 流量加密
conf := &tls.Config{
InsecureSkipVerify: true,
}
connection, err = tls.Dial("tcp", server, conf)
} else {
connection, err = net.Dial("tcp", server)
}
//header := &proxyproto.Header{
// Version: 1,
// Command: proxyproto.PROXY,
// TransportProtocol: proxyproto.TCPv4,
// SourceAddr: &net.TCPAddr{
// IP: net.ParseIP("10.1.1.1"),
// Port: 1000,
// },
// DestinationAddr: &net.TCPAddr{
// IP: net.ParseIP("20.2.2.2"),
// Port: 2000,
// },
//}
//
//_, err = header.WriteTo(connection)
//_, err = io.WriteString(connection, "HELO")
}
} else {
sess, err = kcp.DialWithOptions(server, nil, 10, 3)
@@ -232,8 +270,8 @@ func NewConn(tp string, vkey string, server string, connType string, proxyUrl st
return nil, err
}
if crypt.Md5(version.GetVersion()) != string(b) {
logs.Error("The client does not match the server version. The current core version of the client is", version.GetVersion())
return nil, err
//logs.Error("The client does not match the server version. The current core version of the client is", version.GetVersion())
//return nil, err
}
if _, err := c.Write([]byte(common.Getverifyval(vkey))); err != nil {
return nil, err
@@ -251,7 +289,7 @@ func NewConn(tp string, vkey string, server string, connType string, proxyUrl st
return c, nil
}
//http proxy connection
// http proxy connection
func NewHttpProxyConn(url *url.URL, remoteAddr string) (net.Conn, error) {
req, err := http.NewRequest("CONNECT", "http://"+remoteAddr, nil)
if err != nil {
@@ -278,7 +316,7 @@ func NewHttpProxyConn(url *url.URL, remoteAddr string) (net.Conn, error) {
return proxyConn, nil
}
//get a basic auth string
// get a basic auth string
func basicAuth(username, password string) string {
auth := username + ":" + password
return base64.StdEncoding.EncodeToString([]byte(auth))
+28 -17
View File
@@ -1,23 +1,24 @@
package main
import (
"ehang.io/nps/client"
"ehang.io/nps/lib/common"
"ehang.io/nps/lib/config"
"ehang.io/nps/lib/file"
"ehang.io/nps/lib/install"
"ehang.io/nps/lib/version"
"flag"
"fmt"
"github.com/astaxie/beego/logs"
"github.com/ccding/go-stun/stun"
"github.com/kardianos/service"
"os"
"os/exec"
"runtime"
"strings"
"sync"
"time"
"ehang.io/nps/client"
"ehang.io/nps/lib/common"
"ehang.io/nps/lib/config"
"ehang.io/nps/lib/file"
"ehang.io/nps/lib/install"
"ehang.io/nps/lib/version"
"github.com/astaxie/beego/logs"
"github.com/ccding/go-stun/stun"
"github.com/kardianos/service"
)
var (
@@ -39,6 +40,7 @@ var (
stunAddr = flag.String("stun_addr", "stun.stunprotocol.org:3478", "stun server address (eg:stun.stunprotocol.org:3478)")
ver = flag.Bool("version", false, "show current version")
disconnectTime = flag.Int("disconnect_timeout", 60, "not receiving check packet times, until timeout will disconnect the client")
tlsEnable = flag.Bool("tls_enable", false, "enable tls")
)
func main() {
@@ -115,6 +117,7 @@ func main() {
return
case "nat":
c := stun.NewClient()
flag.CommandLine.Parse(os.Args[2:])
c.SetServerAddr(*stunAddr)
nat, host, err := c.Discover()
if err != nil || host == nil {
@@ -228,15 +231,23 @@ func run() {
if *verifyKey == "" {
*verifyKey, _ = env["NPC_SERVER_VKEY"]
}
logs.Info("the version of client is %s, the core version of client is %s", version.VERSION, version.GetVersion())
if *verifyKey != "" && *serverAddr != "" && *configPath == "" {
go func() {
for {
client.NewRPClient(*serverAddr, *verifyKey, *connType, *proxyUrl, nil, *disconnectTime).Start()
logs.Info("Client closed! It will be reconnected in five seconds")
time.Sleep(time.Second * 5)
}
}()
client.SetTlsEnable(*tlsEnable)
logs.Info("the version of client is %s, the core version of client is %s,tls enable is %t", version.VERSION, version.GetVersion(), client.GetTlsEnable())
vkeys := strings.Split(*verifyKey, `,`)
for _, key := range vkeys {
key := key
go func() {
for {
logs.Info("start vkey:" + key)
client.NewRPClient(*serverAddr, key, *connType, *proxyUrl, nil, *disconnectTime).Start()
logs.Info("Client closed! It will be reconnected in five seconds")
time.Sleep(time.Second * 5)
}
}()
}
} else {
if *configPath == "" {
*configPath = common.GetConfigPath()
+4 -1
View File
@@ -1,6 +1,7 @@
package main
import (
"ehang.io/nps/bridge"
"ehang.io/nps/lib/daemon"
"flag"
"log"
@@ -80,6 +81,8 @@ func main() {
Option: options,
}
bridge.ServerTlsEnable = beego.AppConfig.DefaultBool("tls_enable", false)
for _, v := range os.Args[1:] {
switch v {
case "install", "start", "stop", "uninstall", "restart":
@@ -227,7 +230,7 @@ func run() {
}
logs.Info("the config path is:" + common.GetRunPath())
logs.Info("the version of server is %s ,allow client core version to be %s", version.VERSION, version.GetVersion())
logs.Info("the version of server is %s ,allow client core version to be %s,tls enable is %t", version.VERSION, version.GetVersion(), bridge.ServerTlsEnable)
connection.InitConnectionService()
//crypt.InitTls(filepath.Join(common.GetRunPath(), "conf", "server.pem"), filepath.Join(common.GetRunPath(), "conf", "server.key"))
crypt.InitTls()
+1 -1
View File
@@ -1,2 +1,2 @@
{"Cnf":{"U":"","P":"","Compress":false,"Crypt":false},"Id":2,"VerifyKey":"a82kjhdyllqnlruk","Addr":"127.0.0.1","Remark":"","Status":true,"IsConnect":false,"RateLimit":0,"Flow":{"ExportFlow":551,"InletFlow":551,"FlowLimit":0},"Rate":{"NowRate":0},"NoStore":false,"NoDisplay":false,"MaxConn":0,"NowConn":0,"WebUserName":"","WebPassword":"","ConfigConnAllow":true,"MaxTunnelNum":0,"Version":"0.26.12","BlackIpList":[""]}
{"Cnf":{"U":"","P":"","Compress":false,"Crypt":false},"Id":2,"VerifyKey":"a82kjhdyllqnlruk","Addr":"127.0.0.1","Remark":"","Status":true,"IsConnect":false,"RateLimit":0,"Flow":{"ExportFlow":551,"InletFlow":551,"FlowLimit":0},"Rate":{"NowRate":0},"NoStore":false,"NoDisplay":false,"MaxConn":0,"NowConn":0,"WebUserName":"","WebPassword":"","ConfigConnAllow":true,"MaxTunnelNum":0,"Version":"0.26.19","BlackIpList":[""],"LastOnlineTime":"2024-05-28 15:08:39"}
*#*
+1 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -14,6 +14,7 @@ crypt=true
compress=true
#pprof_addr=0.0.0.0:9999
disconnect_timeout=60
tls_enable=true
[health_check_test1]
health_check_timeout=1
+10 -3
View File
@@ -51,7 +51,9 @@ web_key_file=conf/server.key
#Web API unauthenticated IP address(the len of auth_crypt_key must be 16)
#Remove comments if needed
#auth_key=test
auth_crypt_key =1234567812345678
auth_key=123
#获取服务端authKey时的aes加密密钥,16位
auth_crypt_key =213
#allow_ports=9001-9009,10001,11000-12000
@@ -82,7 +84,7 @@ http_cache=false
http_cache_length=100
#get origin ip
http_add_origin_header=false
#http_add_origin_header=false
#pprof debug options
#pprof_ip=0.0.0.0
@@ -92,4 +94,9 @@ http_add_origin_header=false
disconnect_timeout=60
#管理面板开启验证码校验
open_captcha=false
open_captcha=false
# 是否开启tls
tls_enable=true
tls_bridge_port=8025
+39 -10
View File
@@ -1,33 +1,62 @@
module ehang.io/nps
go 1.15
go 1.22
require (
fyne.io/fyne/v2 v2.0.2
github.com/astaxie/beego v1.12.0
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/c4milo/unpackit v0.0.0-20170704181138-4ed373e9ef1c
github.com/ccding/go-stun v0.0.0-20180726100737-be486d185f3d
github.com/dsnet/compress v0.0.1 // indirect
github.com/golang/snappy v0.0.3
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 // indirect
github.com/kardianos/service v1.2.0
github.com/panjf2000/ants/v2 v2.4.2
github.com/pkg/errors v0.9.1
github.com/shirou/gopsutil/v3 v3.23.10
github.com/xtaci/kcp-go v5.4.20+incompatible
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
)
require (
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/fyne-io/mobile v0.1.3-0.20210318200029-09e9c4e13a8f // indirect
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 // indirect
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210311203641-62640a716d48 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/godbus/dbus/v5 v5.0.3 // indirect
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff // indirect
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 // indirect
github.com/klauspost/compress v1.4.1 // indirect
github.com/klauspost/cpuid v1.3.1 // indirect
github.com/klauspost/cpuid/v2 v2.0.6 // indirect
github.com/klauspost/pgzip v1.2.1 // indirect
github.com/klauspost/reedsolomon v1.9.12 // indirect
github.com/panjf2000/ants/v2 v2.4.2
github.com/pkg/errors v0.9.1
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/pires/go-proxyproto v0.7.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
github.com/shirou/gopsutil/v3 v3.21.3
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/srwiley/oksvg v0.0.0-20200311192757-870daf9aa564 // indirect
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect
github.com/tjfoc/gmsm v1.4.0 // indirect
github.com/xtaci/kcp-go v5.4.20+incompatible
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/ulikunitz/xz v0.5.6 // indirect
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.3.3 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace github.com/astaxie/beego => github.com/exfly/beego v1.12.0-export-init
+38 -18
View File
@@ -1,14 +1,10 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
ehang.io/nps-mux v0.0.0-20210407130203-4afa0c10c992 h1:LvlcB+8JveSBprHnva0g+OyLwAH8CRxEwtWzTe6ocoE=
ehang.io/nps-mux v0.0.0-20210407130203-4afa0c10c992/go.mod h1:v54y/8ICChiM/aVUuKxGIcWwjm4HGNRyyAwbgLBoMbI=
fyne.io/fyne/v2 v2.0.2 h1:6pDvFuCmL1odyT/fPI+2L54hMJW1Zt9Dno41HmLInRs=
fyne.io/fyne/v2 v2.0.2/go.mod h1:3+FYmLJVgeb8EvTPJ5YzZeo7LkAq4bbuY3Zrir6xHbg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I=
github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
@@ -52,8 +48,8 @@ github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluN
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210311203641-62640a716d48 h1:QrUfZrT8n72FUuiABt4tbu8PwDnOPAbnj3Mql1UhdRI=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210311203641-62640a716d48/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME=
@@ -80,6 +76,10 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 h1:WgfvpuKg42WVLkxNwzfFraXkTXPK36bMqXvMFN67clI=
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214/go.mod h1:kj6hFWqfwSjFjLnYW5PK1DoxZ4O0uapwHRmd9jhln4E=
github.com/jackmordaunt/icns v0.0.0-20181231085925-4f16af745526/go.mod h1:UQkeMHVoNcyXYq9otUupF7/h/2tmHlhrS2zw7ZVvUqc=
@@ -103,6 +103,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lucor/goinfo v0.0.0-20200401173949-526b5363a13a/go.mod h1:ORP3/rB5IsulLEBwQZCJyyV6niqmI7P4EWSmkug+1Ng=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
@@ -110,16 +112,24 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
github.com/panjf2000/ants/v2 v2.4.2 h1:kesjjo8JipN3vNNg1XaiXaeSs6xJweBTgenkBtsrHf8=
github.com/panjf2000/ants/v2 v2.4.2/go.mod h1:f6F0NZVFsGCp5A7QW/Zj/m92atWwOkY0OIhFxRNFr4A=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pires/go-proxyproto v0.7.0 h1:IukmRewDQFWC7kfnb66CSomk2q/seBuilHBYFwyq0Hs=
github.com/pires/go-proxyproto v0.7.0/go.mod h1:Vz/1JPY/OACxWGQNIRY2BeyDmpoaWmEP40O9LbuiFR4=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
github.com/shirou/gopsutil/v3 v3.21.3 h1:wgcdAHZS2H6qy4JFewVTtqfiYxFzCeEJod/mLztdPG8=
github.com/shirou/gopsutil/v3 v3.21.3/go.mod h1:ghfMypLDrFSWN2c9cDYFLHyynQ+QUht0cv/18ZqVczw=
github.com/shirou/gopsutil/v3 v3.23.10 h1:/N42opWlYzegYaVkWejXWJpbzKv2JDy3mrgGzKsh9hM=
github.com/shirou/gopsutil/v3 v3.23.10/go.mod h1:JIE26kpucQi+innVlAUnIEOSBhBUkirr5b44yr55+WE=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
@@ -131,11 +141,15 @@ github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9 h1:m59mIOBO4kfcNCE
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9/go.mod h1:mvWM0+15UqyrFKqdRjY6LuAVJR0HOVhJlEgZ5JWtSWU=
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 h1:89CEmDvlq/F7SJEOqkIdNDGJXrQIhuIx9D2DBXjavSU=
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU=
@@ -143,10 +157,10 @@ github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b h1:fj5tQ8acgNUr6O8LE
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4=
github.com/tjfoc/gmsm v1.4.0 h1:8nbaiZG+iVdh+fXVw0DZoZZa7a4TGm3Qab+xdrdzj8s=
github.com/tjfoc/gmsm v1.4.0/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
github.com/tklauser/go-sysconf v0.3.4 h1:HT8SVixZd3IzLdfs/xlpq0jeSfTX57g1v6wB1EuzV7M=
github.com/tklauser/go-sysconf v0.3.4/go.mod h1:Cl2c8ZRWfHD5IrfHo9VN+FX9kCFjIOyVklgXycLB6ek=
github.com/tklauser/numcpus v0.2.1 h1:ct88eFm+Q7m2ZfXJdan1xYoXKlmwsfP+k88q05KvlZc=
github.com/tklauser/numcpus v0.2.1/go.mod h1:9aU+wOc6WjUIZEwWMP62PL/41d65P+iks1gBkr4QyP8=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
@@ -155,6 +169,8 @@ github.com/xtaci/kcp-go v5.4.20+incompatible/go.mod h1:bN6vIwHQbfHaHtFpEssmWsN45
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM=
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -191,16 +207,19 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200720211630-cb9d2d5c5666/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
@@ -239,7 +258,8 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

+34 -30
View File
@@ -7,6 +7,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"html/template"
"io"
@@ -23,7 +24,7 @@ import (
"ehang.io/nps/lib/crypt"
)
//Get the corresponding IP address through domain name
// Get the corresponding IP address through domain name
func GetHostByName(hostname string) string {
if !DomainCheck(hostname) {
return hostname
@@ -39,7 +40,7 @@ func GetHostByName(hostname string) string {
return ""
}
//Check the legality of domain
// Check the legality of domain
func DomainCheck(domain string) bool {
var match bool
IsLine := "^((http://)|(https://))?([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}(/)"
@@ -51,7 +52,7 @@ func DomainCheck(domain string) bool {
return match
}
//Check if the Request request is validated
// Check if the Request request is validated
func CheckAuth(r *http.Request, user, passwd string) bool {
s := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
if len(s) != 2 {
@@ -73,7 +74,7 @@ func CheckAuth(r *http.Request, user, passwd string) bool {
return pair[0] == user && pair[1] == passwd
}
//get bool by str
// get bool by str
func GetBoolByStr(s string) bool {
switch s {
case "1", "true":
@@ -82,7 +83,7 @@ func GetBoolByStr(s string) bool {
return false
}
//get str by bool
// get str by bool
func GetStrByBool(b bool) string {
if b {
return "1"
@@ -90,19 +91,19 @@ func GetStrByBool(b bool) string {
return "0"
}
//int
// int
func GetIntNoErrByStr(str string) int {
i, _ := strconv.Atoi(strings.TrimSpace(str))
return i
}
//Get verify value
// Get verify value
func Getverifyval(vkey string) string {
return crypt.Md5(vkey)
}
//Change headers and host of request
func ChangeHostAndHeader(r *http.Request, host string, header string, addr string, addOrigin bool) {
// Change headers and host of request
func ChangeHostAndHeader(r *http.Request, host string, header string, addr string) {
if host != "" {
r.Host = host
}
@@ -119,13 +120,17 @@ func ChangeHostAndHeader(r *http.Request, host string, header string, addr strin
if prior, ok := r.Header["X-Forwarded-For"]; ok {
addr = strings.Join(prior, ", ") + ", " + addr
}
addOrigin, _ := beego.AppConfig.Bool("http_add_origin_header")
if addOrigin {
logs.Debug("set X-Forwarded-For X-Real-IP = " + addr)
r.Header.Set("X-Forwarded-For", addr)
r.Header.Set("X-Real-IP", addr)
}
}
//Read file content by file path
// Read file content by file path
func ReadAllFromFile(filePath string) ([]byte, error) {
f, err := os.Open(filePath)
if err != nil {
@@ -145,7 +150,7 @@ func FileExists(name string) bool {
return true
}
//Judge whether the TCP port can open normally
// Judge whether the TCP port can open normally
func TestTcpPort(port int) bool {
l, err := net.ListenTCP("tcp", &net.TCPAddr{net.ParseIP("0.0.0.0"), port, ""})
defer func() {
@@ -159,7 +164,7 @@ func TestTcpPort(port int) bool {
return true
}
//Judge whether the UDP port can open normally
// Judge whether the UDP port can open normally
func TestUdpPort(port int) bool {
l, err := net.ListenUDP("udp", &net.UDPAddr{net.ParseIP("0.0.0.0"), port, ""})
defer func() {
@@ -173,9 +178,9 @@ func TestUdpPort(port int) bool {
return true
}
//Write length and individual byte data
//Length prevents sticking
//# Characters are used to separate data
// Write length and individual byte data
// Length prevents sticking
// # Characters are used to separate data
func BinaryWrite(raw *bytes.Buffer, v ...string) {
b := GetWriteStr(v...)
binary.Write(raw, binary.LittleEndian, int32(len(b)))
@@ -194,7 +199,7 @@ func GetWriteStr(v ...string) []byte {
return buffer.Bytes()
}
//inArray str interface
// inArray str interface
func InStrArr(arr []string, val string) bool {
for _, v := range arr {
if v == val {
@@ -204,7 +209,7 @@ func InStrArr(arr []string, val string) bool {
return false
}
//inArray int interface
// inArray int interface
func InIntArr(arr []int, val int) bool {
for _, v := range arr {
if v == val {
@@ -214,7 +219,7 @@ func InIntArr(arr []int, val int) bool {
return false
}
//format ports str to a int array
// format ports str to a int array
func GetPorts(p string) []int {
var ps []int
arr := strings.Split(p, ",")
@@ -238,7 +243,7 @@ func GetPorts(p string) []int {
return ps
}
//is the string a port
// is the string a port
func IsPort(p string) bool {
pi, err := strconv.Atoi(p)
if err != nil {
@@ -250,7 +255,7 @@ func IsPort(p string) bool {
return true
}
//if the s is just a port,return 127.0.0.1:s
// if the s is just a port,return 127.0.0.1:s
func FormatAddress(s string) string {
if strings.Contains(s, ":") {
return s
@@ -258,13 +263,13 @@ func FormatAddress(s string) string {
return "127.0.0.1:" + s
}
//get address from the complete address
// get address from the complete address
func GetIpByAddr(addr string) string {
arr := strings.Split(addr, ":")
return arr[0]
}
//get port from the complete address
// get port from the complete address
func GetPortByAddr(addr string) int {
arr := strings.Split(addr, ":")
if len(arr) < 2 {
@@ -327,7 +332,7 @@ func CopyBuffer(dst io.Writer, src io.Reader, label ...string) (written int64, e
return written, err
}
//send this ip forget to get a local udp port
// send this ip forget to get a local udp port
func GetLocalUdpAddr() (net.Conn, error) {
tmpConn, err := net.Dial("udp", "114.114.114.114:53")
if err != nil {
@@ -336,7 +341,7 @@ func GetLocalUdpAddr() (net.Conn, error) {
return tmpConn, tmpConn.Close()
}
//parse template
// parse template
func ParseStr(str string) (string, error) {
tmp := template.New("npc")
var err error
@@ -350,7 +355,7 @@ func ParseStr(str string) (string, error) {
return w.String(), nil
}
//get env
// get env
func GetEnvMap() map[string]string {
m := make(map[string]string)
environ := os.Environ()
@@ -363,7 +368,7 @@ func GetEnvMap() map[string]string {
return m
}
//throw the empty element of the string array
// throw the empty element of the string array
func TrimArr(arr []string) []string {
newArr := make([]string, 0)
for _, v := range arr {
@@ -374,7 +379,6 @@ func TrimArr(arr []string) []string {
return newArr
}
//
func IsArrContains(arr []string, val string) bool {
if arr == nil {
return false
@@ -387,7 +391,7 @@ func IsArrContains(arr []string, val string) bool {
return false
}
//remove value from string array
// remove value from string array
func RemoveArrVal(arr []string, val string) []string {
for k, v := range arr {
if v == val {
@@ -398,7 +402,7 @@ func RemoveArrVal(arr []string, val string) []string {
return arr
}
//convert bytes to num
// convert bytes to num
func BytesToNum(b []byte) int {
var str string
for i := 0; i < len(b); i++ {
@@ -408,7 +412,7 @@ func BytesToNum(b []byte) int {
return int(x)
}
//get the length of the sync map
// get the length of the sync map
func GeSynctMapLen(m sync.Map) int {
var c int
m.Range(func(key, value interface{}) bool {
+3
View File
@@ -15,6 +15,7 @@ type CommonConfig struct {
VKey string
Tp string //bridgeType kcp or tcp
AutoReconnection bool
TlsEnable bool
ProxyUrl string
Client *file.Client
DisconnectTime int
@@ -150,6 +151,8 @@ func dealCommon(s string) *CommonConfig {
common.InitPProfFromArg(item[1])
case "disconnect_timeout":
c.DisconnectTime = common.GetIntNoErrByStr(item[1])
case "tls_enable":
c.TlsEnable = common.GetBoolByStr(item[1])
}
}
return c
+6 -6
View File
@@ -11,7 +11,7 @@ import (
"time"
)
//en
// en
func AesEncrypt(origData, key []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
@@ -25,7 +25,7 @@ func AesEncrypt(origData, key []byte) ([]byte, error) {
return crypted, nil
}
//de
// de
func AesDecrypt(crypted, key []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
@@ -39,14 +39,14 @@ func AesDecrypt(crypted, key []byte) ([]byte, error) {
return origData, err
}
//Completion when the length is insufficient
// Completion when the length is insufficient
func PKCS5Padding(ciphertext []byte, blockSize int) []byte {
padding := blockSize - len(ciphertext)%blockSize
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
return append(ciphertext, padtext...)
}
//Remove excess
// Remove excess
func PKCS5UnPadding(origData []byte) (error, []byte) {
length := len(origData)
unpadding := int(origData[length-1])
@@ -56,14 +56,14 @@ func PKCS5UnPadding(origData []byte) (error, []byte) {
return nil, origData[:(length - unpadding)]
}
//Generate 32-bit MD5 strings
// Generate 32-bit MD5 strings
func Md5(s string) string {
h := md5.New()
h.Write([]byte(s))
return hex.EncodeToString(h.Sum(nil))
}
//Generating Random Verification Key
// Generating Random Verification Key
func GetRandomString(l int) string {
str := "0123456789abcdefghijklmnopqrstuvwxyz"
bytes := []byte(str)
+4
View File
@@ -30,6 +30,10 @@ func InitTls() {
}
}
func GetCert() tls.Certificate {
return cert
}
func NewTlsServerConn(conn net.Conn) net.Conn {
var err error
if err != nil {
+10
View File
@@ -52,6 +52,7 @@ type Client struct {
MaxTunnelNum int
Version string
BlackIpList []string
CreateTime string
LastOnlineTime string
sync.RWMutex
}
@@ -110,6 +111,14 @@ func (s *Client) GetTunnelNum() (num int) {
}
return true
})
GetDb().JsonDb.Hosts.Range(func(key, value interface{}) bool {
v := value.(*Host)
if v.Client.Id == s.Id {
num++
}
return true
})
return
}
@@ -174,6 +183,7 @@ type Host struct {
KeyFilePath string
NoStore bool
IsClose bool
AutoHttps bool // 自动https
Flow *Flow
Client *Client
Target *Target //目标
+1 -1
View File
@@ -1,6 +1,6 @@
package version
const VERSION = "0.26.16"
const VERSION = "0.26.20"
// Compulsory minimum version, Minimum downward compatibility to this version
func GetVersion() string {
+68 -10
View File
@@ -102,6 +102,20 @@ func (s *httpServer) Close() error {
func (s *httpServer) handleTunneling(w http.ResponseWriter, r *http.Request) {
var host *file.Host
var err error
host, err = file.GetDb().GetInfoByHost(r.Host, r)
if err != nil {
logs.Debug("the url %s %s %s can't be parsed!", r.URL.Scheme, r.Host, r.RequestURI)
return
}
// 自动 http 301 https
if host.AutoHttps && r.TLS == nil {
http.Redirect(w, r, "https://"+r.Host+r.RequestURI, http.StatusMovedPermanently)
return
}
if r.Header.Get("Upgrade") != "" {
rProxy := NewHttpReverseProxy(s)
rProxy.ServeHTTP(w, r)
@@ -133,6 +147,7 @@ func (s *httpServer) handleHttp(c *conn.Conn, r *http.Request) {
lenConn *conn.LenConn
isReset bool
wg sync.WaitGroup
remoteAddr string
)
defer func() {
if connClient != nil {
@@ -146,12 +161,27 @@ reset:
if isReset {
host.Client.AddConn()
}
if host, err = file.GetDb().GetInfoByHost(r.Host, r); err != nil {
logs.Notice("the url %s %s %s can't be parsed!", r.URL.Scheme, r.Host, r.RequestURI)
remoteAddr = strings.TrimSpace(r.Header.Get("X-Forwarded-For"))
if len(remoteAddr) == 0 {
remoteAddr = c.RemoteAddr().String()
}
// 判断访问地址是否在全局黑名单内
if IsGlobalBlackIp(c.RemoteAddr().String()) {
c.Close()
return
}
if host, err = file.GetDb().GetInfoByHost(r.Host, r); err != nil {
logs.Notice("the url %s %s %s can't be parsed!, host %s, url %s, remote address %s", r.URL.Scheme, r.Host, r.RequestURI, r.Host, r.URL.Path, remoteAddr)
c.Close()
return
}
if err := s.CheckFlowAndConnNum(host.Client); err != nil {
logs.Warn("client id %d, host id %d, error %s, when https connection", host.Client.Id, host.Id, err.Error())
c.Close()
return
}
if !isReset {
@@ -166,12 +196,6 @@ reset:
return
}
// 判断访问地址是否在全局黑名单内
if IsGlobalBlackIp(c.RemoteAddr().String()) {
c.Close()
return
}
// 判断访问地址是否在黑名单内
if common.IsBlackIp(c.RemoteAddr().String(), host.Client.VerifyKey, host.Client.BlackIpList) {
c.Close()
@@ -236,8 +260,10 @@ reset:
}
//change the host and header and set proxy setting
common.ChangeHostAndHeader(r, host.HostChange, host.HeaderChange, c.Conn.RemoteAddr().String(), s.addOrigin)
logs.Info("%s request, method %s, host %s, url %s, remote address %s, target %s", r.URL.Scheme, r.Method, r.Host, r.URL.Path, c.RemoteAddr().String(), lk.Host)
common.ChangeHostAndHeader(r, host.HostChange, host.HeaderChange, c.Conn.RemoteAddr().String())
logs.Info("%s request, method %s, host %s, url %s, remote address %s, target %s", r.URL.Scheme, r.Method, r.Host, r.URL.Path, remoteAddr, lk.Host)
//write
lenConn = conn.NewLenConn(connClient)
//lenConn = conn.LenConn
@@ -291,3 +317,35 @@ func (s *httpServer) NewServer(port int, scheme string) *http.Server {
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
}
}
func (s *httpServer) NewServerWithTls(port int, scheme string, l net.Listener, certFile string, keyFile string) error {
if certFile == "" || keyFile == "" {
logs.Error("证书文件为空")
return nil
}
var certFileByte = []byte(certFile)
var keyFileByte = []byte(keyFile)
config := &tls.Config{}
config.Certificates = make([]tls.Certificate, 1)
var err error
config.Certificates[0], err = tls.X509KeyPair(certFileByte, keyFileByte)
if err != nil {
return err
}
s2 := &http.Server{
Addr: ":" + strconv.Itoa(port),
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r.URL.Scheme = scheme
s.handleTunneling(w, r)
}),
// Disable HTTP/2.
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
TLSConfig: config,
}
return s2.ServeTLS(l, "", "")
}
+163 -55
View File
@@ -4,7 +4,6 @@ import (
"net"
"net/http"
"net/url"
"path/filepath"
"sync"
"ehang.io/nps/lib/cache"
@@ -12,7 +11,6 @@ import (
"ehang.io/nps/lib/conn"
"ehang.io/nps/lib/crypt"
"ehang.io/nps/lib/file"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/pkg/errors"
)
@@ -21,6 +19,7 @@ type HttpsServer struct {
httpServer
listener net.Listener
httpsListenerMap sync.Map
hostIdCertMap sync.Map
}
func NewHttpsServer(l net.Listener, bridge NetBridge, useCache bool, cacheLen int) *HttpsServer {
@@ -33,63 +32,170 @@ func NewHttpsServer(l net.Listener, bridge NetBridge, useCache bool, cacheLen in
return https
}
//start https server
// start https server
func (https *HttpsServer) Start() error {
var err error
if https.errorContent, err = common.ReadAllFromFile(filepath.Join(common.GetRunPath(), "web", "static", "page", "error.html")); err != nil {
https.errorContent = []byte("nps 404")
}
if b, err := beego.AppConfig.Bool("https_just_proxy"); err == nil && b {
conn.Accept(https.listener, func(c net.Conn) {
https.handleHttps(c)
})
} else {
//start the default listener
certFile := beego.AppConfig.String("https_default_cert_file")
keyFile := beego.AppConfig.String("https_default_key_file")
if common.FileExists(certFile) && common.FileExists(keyFile) {
l := NewHttpsListener(https.listener)
https.NewHttps(l, certFile, keyFile)
https.httpsListenerMap.Store("default", l)
}
conn.Accept(https.listener, func(c net.Conn) {
serverName, rb := GetServerNameFromClientHello(c)
//if the clientHello does not contains sni ,use the default ssl certificate
if serverName == "" {
serverName = "default"
}
var l *HttpsListener
if v, ok := https.httpsListenerMap.Load(serverName); ok {
l = v.(*HttpsListener)
conn.Accept(https.listener, func(c net.Conn) {
serverName, rb := GetServerNameFromClientHello(c)
r := buildHttpsRequest(serverName)
if host, err := file.GetDb().GetInfoByHost(serverName, r); err != nil {
c.Close()
logs.Debug("the url %s can't be parsed!,remote addr %s", serverName, c.RemoteAddr().String())
return
} else {
if host.CertFilePath == "" || host.KeyFilePath == "" {
logs.Debug("加载客户端本地证书")
https.handleHttps2(c, serverName, rb, r)
} else {
r := buildHttpsRequest(serverName)
if host, err := file.GetDb().GetInfoByHost(serverName, r); err != nil {
c.Close()
logs.Notice("the url %s can't be parsed!,remote addr %s", serverName, c.RemoteAddr().String())
return
} else {
if !common.FileExists(host.CertFilePath) || !common.FileExists(host.KeyFilePath) {
//if the host cert file or key file is not set ,use the default file
if v, ok := https.httpsListenerMap.Load("default"); ok {
l = v.(*HttpsListener)
} else {
c.Close()
logs.Error("the key %s cert %s file is not exist", host.KeyFilePath, host.CertFilePath)
return
}
} else {
l = NewHttpsListener(https.listener)
https.NewHttps(l, host.CertFilePath, host.KeyFilePath)
https.httpsListenerMap.Store(serverName, l)
logs.Debug("使用上传证书")
https.cert(host, c, rb, host.CertFilePath, host.KeyFilePath)
}
}
})
//var err error
//if https.errorContent, err = common.ReadAllFromFile(filepath.Join(common.GetRunPath(), "web", "static", "page", "error.html")); err != nil {
// https.errorContent = []byte("nps 404")
//}
//if b, err := beego.AppConfig.Bool("https_just_proxy"); err == nil && b {
// conn.Accept(https.listener, func(c net.Conn) {
// https.handleHttps(c)
// })
//} else {
// //start the default listener
// certFile := beego.AppConfig.String("https_default_cert_file")
// keyFile := beego.AppConfig.String("https_default_key_file")
// if common.FileExists(certFile) && common.FileExists(keyFile) {
// l := NewHttpsListener(https.listener)
// https.NewHttps(l, certFile, keyFile)
// https.httpsListenerMap.Store("default", l)
// }
// conn.Accept(https.listener, func(c net.Conn) {
// serverName, rb := GetServerNameFromClientHello(c)
// //if the clientHello does not contains sni ,use the default ssl certificate
// if serverName == "" {
// serverName = "default"
// }
// var l *HttpsListener
// if v, ok := https.httpsListenerMap.Load(serverName); ok {
// l = v.(*HttpsListener)
// } else {
// r := buildHttpsRequest(serverName)
// if host, err := file.GetDb().GetInfoByHost(serverName, r); err != nil {
// c.Close()
// logs.Notice("the url %s can't be parsed!,remote addr %s", serverName, c.RemoteAddr().String())
// return
// } else {
// if !common.FileExists(host.CertFilePath) || !common.FileExists(host.KeyFilePath) {
// //if the host cert file or key file is not set ,use the default file
// if v, ok := https.httpsListenerMap.Load("default"); ok {
// l = v.(*HttpsListener)
// } else {
// c.Close()
// logs.Error("the key %s cert %s file is not exist", host.KeyFilePath, host.CertFilePath)
// return
// }
// } else {
// l = NewHttpsListener(https.listener)
// https.NewHttps(l, host.CertFilePath, host.KeyFilePath)
// https.httpsListenerMap.Store(serverName, l)
// }
// }
// }
// acceptConn := conn.NewConn(c)
// acceptConn.Rb = rb
// l.acceptConn <- acceptConn
// })
//}
return nil
}
func (https *HttpsServer) cert(host *file.Host, c net.Conn, rb []byte, certFileUrl string, keyFileUrl string) {
var l *HttpsListener
i := 0
https.hostIdCertMap.Range(func(key, value interface{}) bool {
i++
// 如果host Id 不存在,则删除map
if id, ok := key.(int); ok {
var err error
_, err = file.GetDb().GetHostById(id)
if err != nil {
// 说明这个host已经不存了,需要释放Listener
logs.Error(err)
if oldL, ok := https.httpsListenerMap.Load(value); ok {
err := oldL.(*HttpsListener).Close()
if err != nil {
logs.Error(err)
}
https.httpsListenerMap.Delete(value)
https.hostIdCertMap.Delete(key)
logs.Info("Listener 已释放")
}
}
acceptConn := conn.NewConn(c)
acceptConn.Rb = rb
l.acceptConn <- acceptConn
})
}
return true
})
logs.Info("当前 Listener 连接数量", i)
if cert, ok := https.hostIdCertMap.Load(host.Id); ok {
if cert == certFileUrl {
// 证书已经存在,直接加载
if v, ok := https.httpsListenerMap.Load(certFileUrl); ok {
l = v.(*HttpsListener)
}
} else {
// 证书修改过,重新加载证书
l = NewHttpsListener(https.listener)
https.NewHttps(l, certFileUrl, keyFileUrl)
if oldL, ok := https.httpsListenerMap.Load(cert); ok {
err := oldL.(*HttpsListener).Close()
if err != nil {
logs.Error(err)
}
https.httpsListenerMap.Delete(cert)
}
https.httpsListenerMap.Store(certFileUrl, l)
https.hostIdCertMap.Store(host.Id, certFileUrl)
}
} else {
// 第一次加载证书
l = NewHttpsListener(https.listener)
https.NewHttps(l, certFileUrl, keyFileUrl)
https.httpsListenerMap.Store(certFileUrl, l)
https.hostIdCertMap.Store(host.Id, certFileUrl)
}
return nil
acceptConn := conn.NewConn(c)
acceptConn.Rb = rb
l.acceptConn <- acceptConn
}
// handle the https which is just proxy to other client
func (https *HttpsServer) handleHttps2(c net.Conn, hostName string, rb []byte, r *http.Request) {
var targetAddr string
var host *file.Host
var err error
if host, err = file.GetDb().GetInfoByHost(hostName, r); err != nil {
c.Close()
logs.Debug("the url %s can't be parsed!", hostName)
return
}
if err := https.CheckFlowAndConnNum(host.Client); err != nil {
logs.Debug("client id %d, host id %d, error %s, when https connection", host.Client.Id, host.Id, err.Error())
c.Close()
return
}
defer host.Client.AddConn()
if err = https.auth(r, conn.NewConn(c), host.Client.Cnf.U, host.Client.Cnf.P); err != nil {
logs.Warn("auth error", err, r.RemoteAddr)
return
}
if targetAddr, err = host.Target.GetRandomTarget(); err != nil {
logs.Warn(err.Error())
}
logs.Info("new https connection,clientId %d,host %s,remote address %s", host.Client.Id, r.Host, c.RemoteAddr().String())
https.DealClient(conn.NewConn(c), host.Client, targetAddr, rb, common.CONN_TCP, nil, host.Client.Flow, host.Target.LocalProxy, nil)
}
// close
@@ -100,11 +206,13 @@ func (https *HttpsServer) Close() error {
// new https server by cert and key file
func (https *HttpsServer) NewHttps(l net.Listener, certFile string, keyFile string) {
go func() {
logs.Error(https.NewServer(0, "https").ServeTLS(l, certFile, keyFile))
//logs.Error(https.NewServer(0, "https").ServeTLS(l, certFile, keyFile))
logs.Error(https.NewServerWithTls(0, "https", l, certFile, keyFile))
}()
}
//handle the https which is just proxy to other client
// handle the https which is just proxy to other client
func (https *HttpsServer) handleHttps(c net.Conn) {
hostName, rb := GetServerNameFromClientHello(c)
var targetAddr string
+1 -1
View File
@@ -100,7 +100,7 @@ func NewHttpReverseProxy(s *httpServer) *HttpReverseProxy {
proxy := NewReverseProxy(&httputil.ReverseProxy{
Director: func(r *http.Request) {
host := r.Context().Value("host").(*file.Host)
common.ChangeHostAndHeader(r, host.HostChange, host.HeaderChange, "", false)
common.ChangeHostAndHeader(r, host.HostChange, host.HeaderChange, "")
},
Transport: &http.Transport{
ResponseHeaderTimeout: rp.responseHeaderTimeout,
+61 -15
View File
@@ -5,6 +5,7 @@ import (
"errors"
"math"
"os"
"sort"
"strconv"
"strings"
"sync"
@@ -32,7 +33,7 @@ func init() {
RunList = sync.Map{}
}
//init task from db
// init task from db
func InitFromCsv() {
//Add a public password
if vkey := beego.AppConfig.String("public_vkey"); vkey != "" {
@@ -50,7 +51,7 @@ func InitFromCsv() {
})
}
//get bridge command
// get bridge command
func DealBridgeTask() {
for {
select {
@@ -84,7 +85,7 @@ func DealBridgeTask() {
}
}
//start a new server
// start a new server
func StartNewServer(bridgePort int, cnf *file.Tunnel, bridgeType string, bridgeDisconnect int) {
Bridge = bridge.NewTunnel(bridgePort, bridgeType, common.GetBoolByStr(beego.AppConfig.String("ip_limit")), RunList, bridgeDisconnect)
go func() {
@@ -122,7 +123,7 @@ func dealClientFlow() {
}
}
//new a server by mode name
// new a server by mode name
func NewMode(Bridge *bridge.Bridge, c *file.Tunnel) proxy.Service {
var service proxy.Service
switch c.Mode {
@@ -156,7 +157,7 @@ func NewMode(Bridge *bridge.Bridge, c *file.Tunnel) proxy.Service {
return service
}
//stop server
// stop server
func StopServer(id int) error {
//if v, ok := RunList[id]; ok {
if v, ok := RunList.Load(id); ok {
@@ -182,7 +183,7 @@ func StopServer(id int) error {
return errors.New("task is not running")
}
//add task
// add task
func AddTask(t *file.Tunnel) error {
if t.Mode == "secret" || t.Mode == "p2p" {
logs.Info("secret task %s start ", t.Remark)
@@ -215,7 +216,7 @@ func AddTask(t *file.Tunnel) error {
return nil
}
//start task
// start task
func StartTask(id int) error {
if t, err := file.GetDb().GetTask(id); err != nil {
return err
@@ -227,7 +228,7 @@ func StartTask(id int) error {
return nil
}
//delete task
// delete task
func DelTask(id int) error {
//if _, ok := RunList[id]; ok {
if _, ok := RunList.Load(id); ok {
@@ -238,18 +239,64 @@ func DelTask(id int) error {
return file.GetDb().DelTask(id)
}
//get task list by page num
func GetTunnel(start, length int, typeVal string, clientId int, search string) ([]*file.Tunnel, int) {
// get task list by page num
func GetTunnel(start, length int, typeVal string, clientId int, search string, sortField string, order string) ([]*file.Tunnel, int) {
all_list := make([]*file.Tunnel, 0) //store all Tunnel
list := make([]*file.Tunnel, 0)
var cnt int
keys := file.GetMapKeys(file.GetDb().JsonDb.Tasks, false, "", "")
//get all Tunnel and sort
for _, key := range keys {
if value, ok := file.GetDb().JsonDb.Tasks.Load(key); ok {
v := value.(*file.Tunnel)
if (typeVal != "" && v.Mode != typeVal || (clientId != 0 && v.Client.Id != clientId)) || (typeVal == "" && clientId != v.Client.Id) {
continue
}
if search != "" && !(v.Id == common.GetIntNoErrByStr(search) || v.Port == common.GetIntNoErrByStr(search) || strings.Contains(v.Password, search) || strings.Contains(v.Remark, search) || strings.Contains(v.Client.VerifyKey, search)) {
all_list = append(all_list, v)
}
}
//sort by Id, Remark, TargetStr, Port, asc or desc
if sortField == "Id" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Id < all_list[j].Id })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Id > all_list[j].Id })
}
} else if sortField == "ClientId" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Client.Id < all_list[j].Client.Id })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Client.Id > all_list[j].Client.Id })
}
} else if sortField == "Remark" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Remark < all_list[j].Remark })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Remark > all_list[j].Remark })
}
} else if sortField == "Client.VerifyKey" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Client.VerifyKey < all_list[j].Client.VerifyKey })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Client.VerifyKey > all_list[j].Client.VerifyKey })
}
} else if sortField == "Target" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Target.TargetStr < all_list[j].Target.TargetStr })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Target.TargetStr > all_list[j].Target.TargetStr })
}
}
//search
for _, key := range all_list {
if value, ok := file.GetDb().JsonDb.Tasks.Load(key.Id); ok {
v := value.(*file.Tunnel)
if (typeVal != "" && v.Mode != typeVal || (clientId != 0 && v.Client.Id != clientId)) || (typeVal == "" && clientId != v.Client.Id) {
continue
}
if search != "" && !(v.Id == common.GetIntNoErrByStr(search) || v.Port == common.GetIntNoErrByStr(search) || strings.Contains(v.Password, search) || strings.Contains(v.Remark, search) || strings.Contains(v.Target.TargetStr, search)) {
continue
}
cnt++
@@ -260,7 +307,6 @@ func GetTunnel(start, length int, typeVal string, clientId int, search string) (
}
if start--; start < 0 {
if length--; length >= 0 {
//if _, ok := RunList[v.Id]; ok {
if _, ok := RunList.Load(v.Id); ok {
v.RunStatus = true
} else {
@@ -274,7 +320,7 @@ func GetTunnel(start, length int, typeVal string, clientId int, search string) (
return list, cnt
}
//get client list
// get client list
func GetClientList(start, length int, search, sort, order string, clientId int) (list []*file.Client, cnt int) {
list, cnt = file.GetDb().GetClientList(start, length, search, sort, order, clientId)
dealClientData()
@@ -326,7 +372,7 @@ func dealClientData() {
return
}
//delete all host and tasks by client id
// delete all host and tasks by client id
func DelTunnelAndHostByClientId(clientId int, justDelNoStore bool) {
var ids []int
file.GetDb().JsonDb.Tasks.Range(func(key, value interface{}) bool {
@@ -358,7 +404,7 @@ func DelTunnelAndHostByClientId(clientId int, justDelNoStore bool) {
}
}
//close the client
// close the client
func DelClientConnect(clientId int) {
Bridge.DelClient(clientId)
}
+12 -1
View File
@@ -1,6 +1,7 @@
package controllers
import (
"ehang.io/nps/bridge"
"html"
"math"
"strconv"
@@ -83,7 +84,17 @@ func (s *BaseController) display(tpl ...string) {
if common.IsWindows() {
s.Data["win"] = ".exe"
}
s.Data["p"] = server.Bridge.TunnelPort
s.Data["p"] = strconv.Itoa(server.Bridge.TunnelPort)
if bridge.ServerTlsEnable {
tlsPort := strconv.Itoa(beego.AppConfig.DefaultInt("tls_bridge_port", 8025))
s.Data["tls_p"] = tlsPort
s.Data["p1"] = strconv.Itoa(server.Bridge.TunnelPort) + " / " + tlsPort
} else {
s.Data["p1"] = strconv.Itoa(server.Bridge.TunnelPort)
}
s.Data["proxyPort"] = beego.AppConfig.String("hostPort")
s.Layout = "public/layout.html"
s.TplName = tplname
+6 -4
View File
@@ -7,6 +7,7 @@ import (
"ehang.io/nps/server"
"github.com/astaxie/beego"
"strings"
"time"
)
type ClientController struct {
@@ -37,7 +38,7 @@ func (s *ClientController) List() {
s.AjaxTable(list, cnt, cnt, cmd)
}
//添加客户端
// 添加客户端
func (s *ClientController) Add() {
if s.Ctx.Request.Method == "GET" {
s.Data["menu"] = "client"
@@ -68,6 +69,7 @@ func (s *ClientController) Add() {
FlowLimit: int64(s.GetIntNoErr("flow_limit")),
},
BlackIpList: RemoveRepeatedElement(strings.Split(s.getEscapeString("blackiplist"), "\r\n")),
CreateTime: time.Now().Format("2006-01-02 15:04:05"),
}
if err := file.GetDb().NewClient(t); err != nil {
s.AjaxErr(err.Error())
@@ -90,7 +92,7 @@ func (s *ClientController) GetClient() {
}
}
//修改客户端
// 修改客户端
func (s *ClientController) Edit() {
id := s.GetIntNoErr("id")
if s.Ctx.Request.Method == "GET" {
@@ -172,7 +174,7 @@ func RemoveRepeatedElement(arr []string) (newArr []string) {
return
}
//更改状态
// 更改状态
func (s *ClientController) ChangeStatus() {
id := s.GetIntNoErr("id")
if client, err := file.GetDb().GetClient(id); err == nil {
@@ -185,7 +187,7 @@ func (s *ClientController) ChangeStatus() {
s.AjaxErr("modified fail")
}
//删除客户端
// 删除客户端
func (s *ClientController) Del() {
id := s.GetIntNoErr("id")
if err := file.GetDb().DelClient(id); err != nil {
+7 -1
View File
@@ -81,7 +81,7 @@ func (s *IndexController) GetTunnel() {
start, length := s.GetAjaxParams()
taskType := s.getEscapeString("type")
clientId := s.GetIntNoErr("client_id")
list, cnt := server.GetTunnel(start, length, taskType, clientId, s.getEscapeString("search"))
list, cnt := server.GetTunnel(start, length, taskType, clientId, s.getEscapeString("search"), s.getEscapeString("sort"), s.getEscapeString("order"))
s.AjaxTable(list, cnt, cnt, nil)
}
@@ -272,11 +272,16 @@ func (s *IndexController) AddHost() {
Scheme: s.getEscapeString("scheme"),
KeyFilePath: s.getEscapeString("key_file_path"),
CertFilePath: s.getEscapeString("cert_file_path"),
AutoHttps: s.GetBoolNoErr("AutoHttps"),
}
var err error
if h.Client, err = file.GetDb().GetClient(s.GetIntNoErr("client_id")); err != nil {
s.AjaxErr("add error the client can not be found")
}
if h.Client.MaxTunnelNum != 0 && h.Client.GetTunnelNum() >= h.Client.MaxTunnelNum {
s.AjaxErr("The number of tunnels exceeds the limit")
}
if err := file.GetDb().NewHost(h); err != nil {
s.AjaxErr("add fail" + err.Error())
}
@@ -324,6 +329,7 @@ func (s *IndexController) EditHost() {
h.KeyFilePath = s.getEscapeString("key_file_path")
h.CertFilePath = s.getEscapeString("cert_file_path")
h.Target.LocalProxy = s.GetBoolNoErr("local_proxy")
h.AutoHttps = s.GetBoolNoErr("AutoHttps")
file.GetDb().JsonDb.StoreHostToJsonFile()
}
s.AjaxOk("modified success")
+6 -2
View File
@@ -59,7 +59,7 @@
$.fn.cloudLang = function () {
$.ajax({
type: 'GET',
url: window.nps.web_base_url + '/static/page/languages.xml',
url: window.nps.web_base_url + '/static/page/languages.xml?v=20240528',
dataType: 'xml',
success: function (xml) {
languages['content'] = xml2json($(xml).children())['content'];
@@ -157,7 +157,11 @@ function submitform(action, url, postdata) {
success: function (res) {
alert(langreply(res.msg));
if (res.status) {
if (postsubmit) {document.location.reload();}else{history.back(-1);}
if (postsubmit) {
document.location.reload();
}else{
window.location.href= document.referrer
}
}
}
});
+14 -2
View File
@@ -193,6 +193,13 @@
<zh-CN>客户端命令</zh-CN>
<en-US>Command</en-US>
</lang>
<lang id="word-commandclient-tls">
<zh-CN>TLS 启动命令</zh-CN>
<en-US>TLS Command</en-US>
</lang>
<lang id="word-compress">
<zh-CN>压缩</zh-CN>
<en-US>Compress</en-US>
@@ -272,13 +279,13 @@
<en-US>HTTP port</en-US>
</lang>
<lang id="word-httpscert">
<zh-CN>HTTPS 证书</zh-CN>
<zh-CN>HTTPS 证书(pem格式)</zh-CN>
<en-US>HTTPS cert</en-US>
</lang>
<lang id="word-https">HTTPS
</lang>
<lang id="word-httpskey">
<zh-CN>HTTPS 密钥</zh-CN>
<zh-CN>HTTPS 密钥(key格式)</zh-CN>
<en-US>HTTPS key</en-US>
</lang>
<lang id="word-httpsport">
@@ -733,6 +740,11 @@
<en-US>IP Black List</en-US>
</lang>
<lang id="word-createtime">
<zh-CN>创建时间</zh-CN>
<en-US>Create Time</en-US>
</lang>
<lang id="word-lastonlinetime">
<zh-CN>上次在线时间</zh-CN>
<en-US>Last Online Time</en-US>
+4 -2
View File
@@ -61,7 +61,7 @@
return '<b langtag="word-maxconnections"></b>: ' + row.MaxConn + '&emsp;'
+ '<b langtag="word-curconnections"></b>: ' + row.NowConn + '&emsp;'
+ '<b langtag="word-flowlimit"></b>: ' + row.Flow.FlowLimit + 'm&emsp;'
+ '<b langtag="word-ratelimit"></b>: ' + row.RateLimit + 'kb/s&emsp;'
+ '<b langtag="word-ratelimit"></b>: ' + row.RateLimit + 'KB/s&emsp;'
+ '<b langtag="word-maxtunnels"></b>: ' + row.MaxTunnelNum + '&emsp;<br/><br/>'
+ '<b langtag="word-webusername"></b>: ' + row.WebUserName + '&emsp;'
+ '<b langtag="word-webpassword"></b>: ' + row.WebPassword + '&emsp;'
@@ -71,8 +71,10 @@
+ '<b langtag="word-compress"></b>: <span langtag="word-' + row.Cnf.Compress + '"></span>&emsp;'
+ '<b langtag="word-connectbyconfig"></b>: <span langtag="word-' + row.ConfigConnAllow + '"></span>&emsp;<br/><br/>'
+ '<b langtag="word-blackip"></b>: ' + row.BlackIpList + '&emsp;<br/><br/>'
+ '<b langtag="word-createtime"></b>: ' + row.CreateTime + '&emsp;<br/><br/>'
+ '<b langtag="word-lastonlinetime"></b>: ' + row.LastOnlineTime + '&emsp;<br/><br/>'
+ '<b langtag="word-commandclient"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code>"
+ '<b langtag="word-commandclient"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code><br/>"
+ '<b langtag="word-commandclient-tls"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.tls_p}} -vkey=" + row.VerifyKey + " -tls_enable=true</code>"
},
//表格的列
columns: [
+26 -2
View File
@@ -32,8 +32,10 @@
<div class="form-group" id="client_id">
<label class="control-label font-bold" langtag="word-clientid"></label>
<div class="col-sm-10">
<input value="{{.client_id}}" class="form-control" type="text" name="client_id"
placeholder="" langtag="word-clientid">
<select class="form-control" name="client_id" placeholder="" langtag="word-belongclient"></select>
<!-- <input value="{{.client_id}}" class="form-control" type="text" name="client_id"-->
<!-- placeholder="" langtag="word-clientid">-->
</div>
</div>
@@ -151,5 +153,27 @@
$("#use_client").on("change", function () {
resetForm()
})
getClientList()
})
function getClientList() {
$("select[name='client_id']").empty();
$.ajax({
type: "POST",
url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址
data: {order:"asc",offset:0,limit:999},
dataType : "json",
success : function(data) {
if (data && data.rows.length > 0) {
for(var i=0; i<data.rows.length; i++){
var option="<option value=\""+data.rows[i].Id+"\"";
option += ">"+data.rows[i].Id + '-' +data.rows[i].Remark+"</option>"; //动态添加数据
$("select[name='client_id']").append(option);
$("select[name='client_id']").find("option[value='{{.t.Client.Id}}']").attr("selected",true);
}
}
}
});
}
</script>
+93 -13
View File
@@ -7,7 +7,9 @@
<div class="form-group">
<label class="control-label font-bold" langtag="word-clientid"></label>
<div class="col-sm-10">
<input value="{{.client_id}}" class="form-control" type="text" name="client_id" placeholder="" langtag="word-clientid">
<select class="form-control" name="client_id" placeholder=""
langtag="word-belongclient"></select>
<!-- <input value="{{.client_id}}" class="form-control" type="text" name="client_id" placeholder="" langtag="word-clientid">-->
</div>
</div>
<div class="form-group">
@@ -19,7 +21,8 @@
<div class="form-group">
<label class="control-label font-bold" langtag="word-host"></label>
<div class="col-sm-10">
<input class="form-control" type="text" name="host" placeholder="" langtag="info-suchashost">
<input class="form-control" type="text" name="host" placeholder=""
langtag="info-suchashost">
</div>
</div>
<div class="form-group" id="scheme">
@@ -32,27 +35,39 @@
</select>
</div>
</div>
{{if eq false .https_just_proxy}}
<div class="form-group" id="AutoHttps">
<label class="control-label font-bold">自动HTTPS(301)</label>
<div class="col-sm-10">
<select class="form-control" name="AutoHttps">
<option value="0" langtag="word-no"></option>
<option value="1" langtag="word-yes"></option>
</select>
</div>
</div>
<div class="form-group" id="cert_file">
<label class="control-label font-bold" langtag="word-httpscert"></label>
<div class="col-sm-10">
<input class="form-control" type="text" name="cert_file_path" placeholder="" langtag="info-unrestricted">
<textarea rows="6" class="form-control" type="text" name="cert_file_path" id="pemText"
placeholder="请将证书文件拖拽或将内容复制粘贴到此处,证书文件格式为:xxxx_example.com.pem"></textarea>
</div>
</div>
<div class="form-group" id="key_file">
<label class="control-label font-bold" langtag="word-httpskey"></label>
<div class="col-sm-10">
<input class="form-control" type="text" name="key_file_path" placeholder="" langtag="info-unrestricted">
<textarea rows="6" class="form-control" type="text" name="key_file_path" id="pemKey"
placeholder="请将私钥文件拖拽或复制粘贴到此处,证书秘钥格式为:xxxx_example.com.key"></textarea>
</div>
</div>
{{end}}
<div class="form-group">
<label class="control-label font-bold" langtag="word-urlroute"></label>
<div class="col-sm-10">
<input class="form-control" type="text" name="location" placeholder="" langtag="info-unrestricted">
<input class="form-control" type="text" name="location" placeholder=""
langtag="info-unrestricted">
</div>
</div>
{{if eq true .allow_local_proxy}}
{{if eq true .allow_local_proxy}}
<div class="form-group" id="local_proxy">
<label class="control-label font-bold" langtag="word-proxytolocal"></label>
<div class="col-sm-10">
@@ -62,11 +77,12 @@
</select>
</div>
</div>
{{end}}
{{end}}
<div class="form-group">
<label class="control-label font-bold" langtag="word-target"></label>
<div class="col-sm-10">
<textarea class="form-control" rows="4" type="text" name="target" placeholder="" langtag="info-suchasiplist"></textarea>
<textarea class="form-control" rows="4" type="text" name="target" placeholder=""
langtag="info-suchasiplist"></textarea>
<span class="help-block m-b-none" langtag="info-targethost"></span>
</div>
@@ -74,7 +90,8 @@
<div class="form-group" id="header">
<label class="control-label font-bold" langtag="word-requestheader"></label>
<div class="col-sm-10">
<textarea class="form-control" rows="4" type="text" name="header" placeholder="Cache-Control: no-cache"></textarea>
<textarea class="form-control" rows="4" type="text" name="header"
placeholder="Cache-Control: no-cache"></textarea>
<span class="help-block m-b-none" langtag="info-header"></span>
</div>
@@ -82,13 +99,15 @@
<div class="form-group" id="hostchange">
<label class="control-label font-bold" langtag="word-requesthost"></label>
<div class="col-sm-10">
<input class="form-control" value="" type="text" name="hostchange" placeholder="" langtag="word-requesthost">
<input class="form-control" value="" type="text" name="hostchange" placeholder=""
langtag="word-requesthost">
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-success" type="button" onclick="submitform('add', '{{.web_base_url}}/index/addhost', $('form').serializeArray())">
<button class="btn btn-success" type="button"
onclick="submitform('add', '{{.web_base_url}}/index/addhost', $('form').serializeArray())">
<i class="fa fa-fw fa-lg fa-check-circle"></i> <span langtag="word-add"></span>
</button>
</div>
@@ -100,14 +119,75 @@
</div>
<script>
$(function () {
const pemText = document.getElementById("pemText");
const pemKey = document.getElementById("pemKey");
// 阻止浏览器默认打开文件的行为
document.addEventListener("dragover", function (event) {
event.preventDefault();
});
pemText.addEventListener("drop", function (event) {
event.preventDefault();
const file = event.dataTransfer.files[0];
const reader = new FileReader();
reader.onload = function (e) {
pemText.value = e.target.result;
console.log("上传pem")
$('#edit_form').data('bootstrapValidator').updateStatus('pemText', 'NOT_VALIDATED');
$('#edit_form').data('bootstrapValidator').validateField('pemText');
}
reader.readAsText(file);
});
pemKey.addEventListener("drop", function (event) {
event.preventDefault();
const file = event.dataTransfer.files[0];
const reader = new FileReader();
reader.onload = function (e) {
pemKey.value = e.target.result;
$('#edit_form').data('bootstrapValidator').updateStatus('pemKey', 'NOT_VALIDATED');
$('#edit_form').data('bootstrapValidator').validateField('pemKey');
}
reader.readAsText(file);
});
$("#scheme_select").on("change", function () {
if ($("#scheme_select").val() == "all" || $("#scheme_select").val() == "https") {
$("#cert_file").css("display", "block")
$("#key_file").css("display", "block")
$("#AutoHttps").css("display", "block")
} else {
$("#cert_file").css("display", "none")
$("#key_file").css("display", "none")
$("#AutoHttps").css("display", "none")
}
})
getClientList();
})
function getClientList() {
$("select[name='client_id']").empty();
$.ajax({
type: "POST",
url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址
data: {order: "asc", offset: 0, limit: 999},
dataType: "json",
success: function (data) {
if (data && data.rows.length > 0) {
for (var i = 0; i < data.rows.length; i++) {
var option = "<option value=\"" + data.rows[i].Id + "\"";
option += ">" + data.rows[i].Id + '-' + data.rows[i].Remark + "</option>"; //动态添加数据
$("select[name='client_id']").append(option);
}
}
}
});
}
</script>
+67 -5
View File
@@ -34,24 +34,33 @@
</select>
</div>
</div>
{{if eq false .https_just_proxy}}
<div class="form-group" id="AutoHttps">
<label class="control-label font-bold">自动HTTPS(301)</label>
<div class="col-sm-10">
<select class="form-control" name="AutoHttps">
<option {{if eq false .h.AutoHttps}}selected{{end}} value="0" langtag="word-no"></option>
<option {{if eq true .h.AutoHttps}}selected{{end}} value="1" langtag="word-yes"></option>
</select>
</div>
</div>
<div class="form-group" id="cert_file">
<label class="control-label font-bold" langtag="word-httpscert"></label>
<div class="col-sm-10">
<input value="{{.h.CertFilePath}}" class="form-control" type="text" name="cert_file_path" placeholder="" langtag="info-unrestricted">
<textarea rows="6" class="form-control" type="text" name="cert_file_path" id="pemText" placeholder="请将证书文件拖拽或将内容复制粘贴到此处,证书文件格式为:xxxx_example.com.pem">{{.h.CertFilePath}}</textarea>
</div>
</div>
<div class="form-group" id="key_file">
<label class="control-label font-bold" langtag="word-httpskey"></label>
<div class="col-sm-10">
<input value="{{.h.KeyFilePath}}" class="form-control" type="text" name="key_file_path" placeholder="" langtag="info-unrestricted">
<textarea rows="6" class="form-control" type="text" name="key_file_path" id="pemKey" placeholder="请将私钥文件拖拽或复制粘贴到此处,证书秘钥格式为:xxxx_example.com.key">{{.h.KeyFilePath}}</textarea>
</div>
</div>
{{end}}
<div class="form-group">
<label class="control-label font-bold" langtag="word-urlroute"></label>
<div class="col-sm-10">
<input value="{{.h.Location}}" class="form-control" type="text" name="location" placeholder="" langtag="info-unrestricted">
<input value="{{.h.Location}}" class="form-control" type="text" name="location" placeholder="" langtag="info-unrestricted">
</div>
</div>
{{if eq true .allow_local_proxy}}
@@ -103,13 +112,66 @@
<script>
$(function () {
if ($("#scheme_select").val() == "all" || $("#scheme_select").val() == "https") {
$("#cert_file").css("display", "block")
$("#key_file").css("display", "block")
$("#AutoHttps").css("display", "block")
} else {
$("#cert_file").css("display", "none")
$("#key_file").css("display", "none")
$("#AutoHttps").css("display", "none")
}
const pemText = document.getElementById("pemText");
const pemKey = document.getElementById("pemKey");
// 阻止浏览器默认打开文件的行为
document.addEventListener("dragover", function(event) {
event.preventDefault();
});
pemText.addEventListener("drop", function(event) {
event.preventDefault();
const file = event.dataTransfer.files[0];
const reader = new FileReader();
reader.onload = function(e) {
pemText.value = e.target.result;
console.log("上传pem")
$('#edit_form').data('bootstrapValidator').updateStatus('pemText', 'NOT_VALIDATED');
$('#edit_form').data('bootstrapValidator').validateField('pemText');
}
reader.readAsText(file);
});
pemKey.addEventListener("drop", function(event) {
event.preventDefault();
const file = event.dataTransfer.files[0];
const reader = new FileReader();
reader.onload = function(e) {
pemKey.value = e.target.result;
$('#edit_form').data('bootstrapValidator').updateStatus('pemKey', 'NOT_VALIDATED');
$('#edit_form').data('bootstrapValidator').validateField('pemKey');
}
reader.readAsText(file);
});
$("#scheme_select").on("change", function () {
if ($("#scheme_select").val() == "all" || $("#scheme_select").val() == "https") {
$("#cert_file").css("display", "block")
$("#key_file").css("display", "block")
$("#AutoHttps").css("display", "block")
} else {
$("#cert_file").css("display", "none")
$("#key_file").css("display", "none")
$("#AutoHttps").css("display", "none")
}
})
})
+1 -1
View File
@@ -88,7 +88,7 @@
halign: 'center',
visible: true,//false表示不显示
formatter: function (value, row, index) {
return row.Client.Id
return row.Client.Id + '-' + row.Client.Remark
}
},
{
+1 -1
View File
@@ -6,7 +6,7 @@
<h5 langtag="word-connectionport"></h5>
</div>
<div class="ibox-content">
<h1 class="no-margins">{{.p}}</h1>
<h1 class="no-margins">{{.p1}}</h1>
</div>
</div>
</div>
+11 -4
View File
@@ -49,7 +49,9 @@
"limit": params.limit,
"type":{{.type}},
"client_id":{{.client_id}},
"search": params.search
"search": params.search,
"sort": params.sort,
"order": params.order
}
},
search: true,
@@ -97,15 +99,17 @@
field: 'Id',//域值
title: '<span langtag="word-id"></span>',//标题
halign: 'center',
visible: true//false表示不显示
visible: true,//false表示不显示
sortable: true,//启用排序
},
{
field: 'Id',//域值
field: 'ClientId',//域值
title: '<span langtag="word-clientid"></span>',//标题
halign: 'center',
visible: true,//false表示不显示
sortable: true, //启用排序
formatter: function (value, row, index) {
return row.Client.Id
return row.Client.Id + '-' + row.Client.Remark
}
},
{
@@ -118,6 +122,7 @@
field: 'Client.VerifyKey',//域值
title: '<span langtag="word-verifykey"></span>',//标题
halign: 'center',
sortable: true, //启用排序
visible: true//false表示不显示
},
{
@@ -133,6 +138,7 @@
field: 'Port',//域值
title: '<span langtag="word-port"></span>',//标题
halign: 'center',
sortable: true, //启用排序
visible: true//false表示不显示
},
{
@@ -140,6 +146,7 @@
title: '<span langtag="word-target"></span>',//标题
halign: 'center',
visible: true,//false表示不显示
sortable: true, //启用排序
formatter: function (value, row, index) {
return row.Target.TargetStr
}
+1 -1
View File
@@ -19,7 +19,7 @@
<script src="{{.web_base_url}}/static/js/jquery-3.4.1.min.js"></script>
<script src="{{.web_base_url}}/static/js/bootstrap.min.js"></script>
<!-- Latest compiled and minified Locales -->
<script src="{{.web_base_url}}/static/js/language.js" type="text/javascript"></script>
<script src="{{.web_base_url}}/static/js/language.js?v=20250528" type="text/javascript"></script>
</head>
+1 -1
View File
@@ -19,7 +19,7 @@
<script src="{{.web_base_url}}/static/js/jquery-3.4.1.min.js"></script>
<script src="{{.web_base_url}}/static/js/bootstrap.min.js"></script>
<!-- Latest compiled and minified Locales -->
<script src="{{.web_base_url}}/static/js/language.js" type="text/javascript"></script>
<script src="{{.web_base_url}}/static/js/language.js?v=20250528" type="text/javascript"></script>
</head>
+1 -1
View File
@@ -26,7 +26,7 @@
<script src="{{.web_base_url}}/static/js/echarts.min.js"></script>
<script src="{{.web_base_url}}/static/js/inspinia.js"></script>
<!-- Latest compiled and minified Locales -->
<script src="{{.web_base_url}}/static/js/language.js" type="text/javascript"></script>
<script src="{{.web_base_url}}/static/js/language.js?v=20250528" type="text/javascript"></script>
</head>