Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78a733606a | ||
|
|
36182e4b60 | ||
|
|
65528fbcf2 | ||
|
|
9b0b5b00c1 | ||
|
|
899b512ddf | ||
|
|
bf622b87ba | ||
|
|
700332ef0d | ||
|
|
02d8c6b561 | ||
|
|
f7c04f3271 | ||
|
|
257816e793 | ||
|
|
00e16e88ff | ||
|
|
c265f0ea2a | ||
|
|
4085181585 | ||
|
|
55ee7acd97 | ||
|
|
a1894ca898 | ||
|
|
191b21b8cd | ||
|
|
c5d96a4105 | ||
|
|
37b4e234ef | ||
|
|
955687ba31 | ||
|
|
22018dab14 | ||
|
|
7084d7df85 | ||
|
|
83a5e8eb99 | ||
|
|
e505eaa72c | ||
|
|
d4fdd0843c | ||
|
|
eeafa867a5 | ||
|
|
352ac408ed | ||
|
|
9fedfa1023 | ||
|
|
c0afe54bc3 | ||
|
|
91bcc55fbf | ||
|
|
783e475872 | ||
|
|
e53df0cede | ||
|
|
c44a5dade8 | ||
|
|
19a1e31904 | ||
|
|
bc9525938a | ||
|
|
605b6af9d5 | ||
|
|
0c25fca0f8 | ||
|
|
790d985afc | ||
|
|
4a347fe301 |
@@ -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,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,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 . .
|
||||
|
||||
@@ -3,15 +3,80 @@
|
||||
[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)
|
||||
|
||||
***宝塔面板***:[宝塔面板 Docker](docs/bt.md)
|
||||
|
||||
## 更新日志
|
||||
# 交流群
|
||||
聊天灌水QQ群:770569342,619833483(已满)
|
||||
|
||||
# 公益云内网穿透
|
||||
https://natnps.com/
|
||||
公益NPS内网穿透服务,长期免费,6M带宽,3条隧道,不限流量,欢迎来嫖,自行注册账号。
|
||||
|
||||
# 特价云服务器
|
||||
国内BGP,游戏开服,2核 2G 15M上行 25元/月,[专属连接,首月5折](https://www.rainyun.com/MjY0MzY1_)
|
||||
|
||||
|
||||
# 捐赠
|
||||

|
||||
|
||||
|
||||
|
||||
## 更新日志
|
||||
- 2025-01-07 v0.26.21
|
||||
新增:
|
||||
- 客户端列表页面新增【快捷启动命令】,此命令为连接地址+链接秘钥的base64编码,方便一键启动、一键安装客户端。
|
||||
- 域名解析和隧道列表增加访问地址,可以点击隧道链接,直接网页打开。 [#234](https://github.com/yisier/nps/issues/234)
|
||||
|
||||
优化:
|
||||
- 修改vkey生成方式,由16位缩短至10位,截取uuid前10位,避免重复。
|
||||
- 优化客户端启动方式,当npc文件目录下无配置文件时,可直接双击运行客户端,输入命令完成启动、安装、卸载客户端,直接启动和安装服务时需要输入【快捷启动命令】,卸载服务、启动服务、停止服务时,只需输入隧道秘钥【vkey】即可。
|
||||

|
||||
|
||||
|
||||
**注意**
|
||||
强烈推荐使用无配置文件模式启动客户端,所有数据应该在服务端保存和配置,而客户端只做连接转发。客户端配置文件对小白极不友好,配置繁琐,容易出错。
|
||||
|
||||
- 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), 如下图所示。
|
||||

|
||||
|
||||
|
||||
|
||||
- 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,用于防止被肉鸡扫描端口或被恶意攻击。
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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,5 +1,5 @@
|
||||
#/bash/sh
|
||||
export VERSION=0.26.16
|
||||
export VERSION=0.26.21
|
||||
export GOPROXY=direct
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
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"
|
||||
"bufio"
|
||||
"ehang.io/nps/lib/crypt"
|
||||
"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/fatih/color"
|
||||
"github.com/kardianos/service"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -39,6 +43,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 +120,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,19 +234,287 @@ 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()
|
||||
}
|
||||
go client.StartFromFile(*configPath)
|
||||
|
||||
// 判断路径下是否有配置文件
|
||||
if common.FileExists(*configPath) {
|
||||
logs.Info("配置文件模式启动")
|
||||
go client.StartFromFile(*configPath)
|
||||
} else {
|
||||
// 无配置文件模式双击运行
|
||||
printSlogan()
|
||||
inputCmd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func printSlogan() {
|
||||
green := color.New(color.FgGreen).SprintFunc()
|
||||
// 第一次输入,如果输入 1,2,3,4 则需要输入秘钥,否则
|
||||
|
||||
fmt.Printf("%s", green(""))
|
||||
|
||||
fmt.Printf("\033[32;0m###########################################################\n")
|
||||
fmt.Printf("\033[32;0m# \033[31mNPS内网穿透客户端\033[0m #\n")
|
||||
fmt.Printf("\033[32;0m# #\n")
|
||||
fmt.Printf("\033[32;0m#\033[32m 地址:\033[31;0mhttps://github.com/yisier/nps\033[0m #\n")
|
||||
fmt.Printf("\033[32;0m#\033[32m 提示:\033[32;0m1、涉及到系统服务的需要以管理员身份运行\033[0m\033[32;0m #\n")
|
||||
fmt.Printf("\033[32;0m#\033[32m \033[32;0m2、直接启动或[注册系统服务]需要使用[快捷启动命令]\033[0m\033[32;0m #\n")
|
||||
fmt.Printf("\033[32;0m#\033[32m \033[32;0m3、其他命令如卸载/启动/停止只需要输入[vkey]\033[0m\033[32;0m #\n")
|
||||
fmt.Printf("\033[32;0m###########################################################\n")
|
||||
fmt.Printf("\033[0m") // 重置颜色
|
||||
|
||||
fmt.Printf("\n")
|
||||
|
||||
fmt.Printf("\u001B[32m输入[1]\u001B[0m - 注册系统服务\n")
|
||||
fmt.Printf("\u001B[32m输入[2]\u001B[0m - 卸载系统服务\n")
|
||||
fmt.Printf("---------------------\n")
|
||||
fmt.Printf("\u001B[32m输入[3]\u001B[0m - 启动系统服务\n")
|
||||
fmt.Printf("\u001B[32m输入[4]\u001B[0m - 停止系统服务\n")
|
||||
fmt.Printf("---------------------\n")
|
||||
fmt.Printf("\u001B[32m输入[0]\u001B[0m - 退出\n")
|
||||
fmt.Printf("---------------------\n")
|
||||
fmt.Printf("直接输入[快捷启动命令]则是启动隧道,多个[快捷启动命令]用英文逗号拼接\n")
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
|
||||
func inputCmd() {
|
||||
|
||||
var flag string
|
||||
fmt.Printf("请输入:")
|
||||
|
||||
stdin := bufio.NewReader(os.Stdin)
|
||||
_, err := fmt.Fscanln(stdin, &flag)
|
||||
if err != nil {
|
||||
fmt.Println("输入有误")
|
||||
} else {
|
||||
if flag == "0" {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
flag := strings.Replace(flag, " ", "", -1)
|
||||
|
||||
// 如果输入不等于 1,2,3,4,则启动隧道
|
||||
if flag != "1" && flag != "2" && flag != "3" && flag != "4" {
|
||||
|
||||
vkeys := strings.Split(flag, `,`)
|
||||
var cmdArray []string
|
||||
|
||||
for _, key := range vkeys {
|
||||
startCmd, err := crypt.Base64Decoding(key)
|
||||
if err != nil {
|
||||
fmt.Println("快捷启动命令解析失败")
|
||||
inputCmd()
|
||||
return
|
||||
}
|
||||
|
||||
cmdArray = append(cmdArray, startCmd)
|
||||
}
|
||||
|
||||
for _, item := range cmdArray {
|
||||
startNpcServer(item)
|
||||
}
|
||||
|
||||
} else {
|
||||
systemService(flag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func startNpcServer(startCmd string) {
|
||||
var serAddr string
|
||||
var vkey string
|
||||
array := strings.Fields(startCmd)
|
||||
serAddr = array[0]
|
||||
vkey = array[1]
|
||||
|
||||
go func() {
|
||||
for {
|
||||
logs.Info("start cmd:-server=" + serAddr + " -vkey=" + vkey)
|
||||
logs.Info("the version of client is %s, the core version of client is %s", version.VERSION, version.GetVersion())
|
||||
client.NewRPClient(serAddr, vkey, *connType, *proxyUrl, nil, *disconnectTime).Start()
|
||||
logs.Info("Client closed! It will be reconnected in five seconds")
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func systemService(flag string) {
|
||||
|
||||
if flag == "1" {
|
||||
fmt.Printf("请输入[快捷启动命令],多个[快捷启动命令]用英文逗号拼接:")
|
||||
} else {
|
||||
fmt.Printf("请输入[VKEY],多个[VKEY]用英文逗号拼接:")
|
||||
}
|
||||
|
||||
var vkey string
|
||||
stdin := bufio.NewReader(os.Stdin)
|
||||
_, err := fmt.Fscanln(stdin, &vkey)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("输入错误,请重试")
|
||||
systemService(flag)
|
||||
return
|
||||
} else {
|
||||
if vkey == "0" {
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
vkey = strings.Replace(vkey, " ", "", -1)
|
||||
|
||||
vkeys := strings.Split(vkey, `,`)
|
||||
|
||||
if flag == "1" {
|
||||
var cmdArray []string
|
||||
for _, key := range vkeys {
|
||||
startCmd, err := crypt.Base64Decoding(key)
|
||||
if err != nil {
|
||||
fmt.Println("快捷启动命令解析失败")
|
||||
systemService(flag)
|
||||
return
|
||||
}
|
||||
cmdArray = append(cmdArray, startCmd)
|
||||
}
|
||||
|
||||
for _, item := range cmdArray {
|
||||
array := strings.Fields(item)
|
||||
systemPro(flag, array[0], array[1])
|
||||
}
|
||||
} else {
|
||||
for _, key := range vkeys {
|
||||
systemPro(flag, "", key)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inputCmd()
|
||||
return
|
||||
}
|
||||
|
||||
func systemPro(flag string, serAddr string, vkey string) {
|
||||
// init service
|
||||
prg := &npc{
|
||||
exit: make(chan struct{}),
|
||||
}
|
||||
options := make(service.KeyValue)
|
||||
svcConfig := &service.Config{
|
||||
Name: "nps-client-" + vkey,
|
||||
DisplayName: "nps-client-" + vkey,
|
||||
Description: "NPS内网穿透客户端,支持tcp、udp流量转发,支持内网http代理,地址:https://github.com/yisier/nps",
|
||||
Option: options,
|
||||
}
|
||||
s, _ := service.New(prg, svcConfig)
|
||||
|
||||
switch flag {
|
||||
case "1":
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-server="+serAddr)
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-vkey="+vkey)
|
||||
svcConfig.Arguments = append(svcConfig.Arguments, "-debug=false")
|
||||
install.InstallNpc()
|
||||
err := service.Control(s, "install")
|
||||
if err != nil {
|
||||
fmt.Println("隧道["+vkey+"]安装到系统服务失败", err)
|
||||
return
|
||||
} else {
|
||||
fmt.Println("隧道[" + vkey + "]已经安装到系统")
|
||||
}
|
||||
if service.Platform() == "unix-systemv" {
|
||||
logs.Info("unix-systemv service")
|
||||
confPath := "/etc/init.d/" + svcConfig.Name
|
||||
os.Symlink(confPath, "/etc/rc.d/S90"+svcConfig.Name)
|
||||
os.Symlink(confPath, "/etc/rc.d/K02"+svcConfig.Name)
|
||||
}
|
||||
|
||||
err2 := service.Control(s, "start")
|
||||
if err2 != nil {
|
||||
fmt.Println("隧道["+vkey+"]启动服务失败", err2)
|
||||
} else {
|
||||
fmt.Println("隧道[" + vkey + "]服务已启动")
|
||||
}
|
||||
|
||||
return
|
||||
case "2":
|
||||
// 卸载系统服务
|
||||
err := service.Control(s, "stop")
|
||||
if err != nil {
|
||||
fmt.Println("隧道["+vkey+"]服务停止失败", err)
|
||||
} else {
|
||||
fmt.Println("隧道[" + vkey + "]服务已停止")
|
||||
}
|
||||
|
||||
err = service.Control(s, "uninstall")
|
||||
if err != nil {
|
||||
fmt.Println("隧道["+vkey+"]服务卸载失败", err)
|
||||
}
|
||||
if service.Platform() == "unix-systemv" {
|
||||
fmt.Println("unix-systemv service")
|
||||
os.Remove("/etc/rc.d/S90" + svcConfig.Name)
|
||||
os.Remove("/etc/rc.d/K02" + svcConfig.Name)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
fmt.Println("隧道[" + vkey + "]服务已卸载成功")
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
case "3":
|
||||
//启动系统服务
|
||||
if service.Platform() == "unix-systemv" {
|
||||
logs.Info("unix-systemv service")
|
||||
cmd := exec.Command("/etc/init.d/"+svcConfig.Name, "start")
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
err := service.Control(s, "start")
|
||||
if err != nil {
|
||||
fmt.Println("隧道["+vkey+"]服务启动失败", err)
|
||||
} else {
|
||||
fmt.Println("隧道[" + vkey + "]服务启动成功")
|
||||
}
|
||||
|
||||
return
|
||||
case "4":
|
||||
if service.Platform() == "unix-systemv" {
|
||||
logs.Info("unix-systemv service")
|
||||
cmd := exec.Command("/etc/init.d/"+svcConfig.Name, "stop")
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
err := service.Control(s, "stop")
|
||||
if err != nil {
|
||||
fmt.Println("隧道["+vkey+"]服务停止失败", err)
|
||||
} else {
|
||||
fmt.Println("隧道[" + vkey + "]服务停止成功")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,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":34,"VerifyKey":"a1efa114df","Addr":"127.0.0.1","Remark":"","Status":true,"IsConnect":false,"RateLimit":0,"Flow":{"ExportFlow":0,"InletFlow":0,"FlowLimit":0},"Rate":{"NowRate":0},"NoStore":false,"NoDisplay":false,"MaxConn":0,"NowConn":0,"WebUserName":"","WebPassword":"","ConfigConnAllow":true,"MaxTunnelNum":0,"Version":"0.26.20","BlackIpList":[""],"CreateTime":"2025-01-03 17:07:37","LastOnlineTime":"2025-01-07 11:12:00"}
|
||||
*#*
|
||||
@@ -1,2 +0,0 @@
|
||||
{"Id":1,"Host":"testlocal.com","HeaderChange":"","HostChange":"","Location":"/","Remark":"","Scheme":"all","CertFilePath":"","KeyFilePath":"","NoStore":false,"IsClose":false,"Flow":{"ExportFlow":0,"InletFlow":0,"FlowLimit":0},"Client":{"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":[""]},"Target":{"TargetStr":"127.0.0.1:8080","TargetArr":["127.0.0.1:8080"],"LocalProxy":false}}
|
||||
*#*
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,42 @@
|
||||
# 🐳 宝塔面板 (一键部署)
|
||||
|
||||
> 安装宝塔面板,前往宝塔面板官网,选择对应的脚本下载安装,推荐宝塔版本 9.2.0+
|
||||
|
||||

|
||||
|
||||
# 安装宝塔面板
|
||||
1. 安装宝塔面板,前往 [宝塔面板官网](https://www.bt.cn/new/download.html) 进行安装,选择正式版脚本安装。
|
||||
|
||||
2. 登录面板,点击左侧 **Docker** 进入 `Docker 管理`。
|
||||
|
||||
3. 如提示未安装 Docker / Docker Compose, 可根据上方引导安装。
|
||||
|
||||
|
||||
# 安装NPS服务端
|
||||
1. 在宝塔面板左侧` Docker 菜单`,进入 **应用商城**,搜索 `NPS`,找到 `NPS 服务端` 并点击 **安装**。
|
||||
|
||||
2. 配置NPS,进入安装目录,修改 `conf/nps.conf` 即可(修改后记得重启容器),服务端参数配置详见 [配置文件说明](https://ehang-io.github.io/nps/#/server_config)
|
||||

|
||||
|
||||
|
||||
|
||||
**注意**:NPS 默认的`WEB端口`为`80,443`, 如果端口被占用,请修改 `nps.conf` 中的 `http_proxy_port`,`https_proxy_port` 为其他端口。
|
||||
web管理端口默认为`8081`,服务端启动后,输入:`ip:8081` 即可访问。
|
||||
|
||||
|
||||
|
||||
# 安装NPS客户端
|
||||
1. 在宝塔面板左侧` Docker 菜单`,进入 **应用商城**,搜索 `NPS`,找到 `NPS 客户端` 并点击 **安装**。
|
||||
|
||||
2. 客户端配置有两种方式,1. [无配置文件模式](https://ehang-io.github.io/nps/#/use?id=%e6%97%a0%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e6%a8%a1%e5%bc%8f)(推荐),2. [配置文件模式](https://ehang-io.github.io/nps/#/use?id=%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e6%a8%a1%e5%bc%8f)。
|
||||
|
||||
- **无配置文件模式**:点击安装后,输入`服务地址`、`连接密钥`,即可启动客户端。`连接方式`和`开启TLS`参数,为了避免意外错误,不建议修改。如果需要配置多个客户端,直接安装多个即可(注意名字不要重复)。
|
||||
|
||||
- **配置文件模式**: `服务地址`、`连接密钥`不需要填写,直接点击 **安装** ,然后在`安装目录`下找到 `conf/npc.conf`,修改配置文件,再重启容器即可。客户端参数配置详见 [配置文件说明](https://ehang-io.github.io/nps/#/use?id=%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e6%a8%a1%e5%bc%8f)。
|
||||
|
||||
**注意**:强烈推荐使用无配置文件模式,所有数据应该在服务端保存和配置,而客户端只做连接转发。客户端配置文件对小白极不友好,配置繁琐,容易出错。
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
@@ -1,33 +1,65 @@
|
||||
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/fatih/color v1.18.0
|
||||
github.com/golang/snappy v0.0.3
|
||||
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 // indirect
|
||||
github.com/google/uuid v1.6.0
|
||||
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/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // 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.25.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
|
||||
|
||||
@@ -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=
|
||||
@@ -42,6 +38,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/exfly/beego v1.12.0-export-init h1:VQNYKdXhAwZGUaFmQv8Aj921O3rQJZRIF8xeGrhsjrI=
|
||||
github.com/exfly/beego v1.12.0-export-init/go.mod h1:fysx+LZNZKnvh4GED/xND7jWtjCR6HzydR2Hh2Im57o=
|
||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||
github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3 h1:FDqhDm7pcsLhhWl1QtD8vlzI4mm59llRvNzrFg6/LAA=
|
||||
github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3/go.mod h1:CzM2G82Q9BDUvMTGHnXf/6OExw/Dz2ivDj48nVg7Lg8=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
@@ -52,8 +50,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 +78,12 @@ 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/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
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 +107,13 @@ 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-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
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=
|
||||
@@ -115,11 +126,17 @@ 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 +148,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 +164,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 +176,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 +214,22 @@ 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.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
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/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
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 +268,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=
|
||||
|
||||
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 119 KiB |
|
After Width: | Height: | Size: 132 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 166 KiB |
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,13 +5,16 @@ import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"github.com/google/uuid"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
//en
|
||||
// en
|
||||
func AesEncrypt(origData, key []byte) ([]byte, error) {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
@@ -25,7 +28,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 +42,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 +59,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)
|
||||
@@ -74,3 +77,32 @@ func GetRandomString(l int) string {
|
||||
}
|
||||
return string(result)
|
||||
}
|
||||
|
||||
func GetVkey() string {
|
||||
// 生成UUID
|
||||
u, _ := uuid.NewRandom()
|
||||
// 将UUID转换为字符串
|
||||
uuidStr := u.String()
|
||||
uuidStr = strings.ReplaceAll(uuidStr, "-", "")
|
||||
// 截取前10位
|
||||
return uuidStr[:10]
|
||||
}
|
||||
|
||||
func Base64Decoding(encodedString string) (string, error) {
|
||||
decodedBytes, err := base64.StdEncoding.DecodeString(encodedString)
|
||||
if err != nil {
|
||||
// 处理解码错误
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 将解码后的字节数组转换为字符串
|
||||
decodedString := string(decodedBytes)
|
||||
|
||||
// 如果startCmd开头不包含"nps ",则报错
|
||||
if len(decodedString) < 4 || !(decodedString[0:4] == "nps ") {
|
||||
return "", errors.New("快捷启动命令错误,请检查")
|
||||
}
|
||||
|
||||
return decodedString[4:], nil
|
||||
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -22,7 +22,7 @@ var (
|
||||
once sync.Once
|
||||
)
|
||||
|
||||
//init csv from file
|
||||
// init csv from file
|
||||
func GetDb() *DbUtils {
|
||||
once.Do(func() {
|
||||
jsonDb := NewJsonDb(common.GetRunPath())
|
||||
@@ -128,7 +128,7 @@ func (s *DbUtils) DelTask(id int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//md5 password
|
||||
// md5 password
|
||||
func (s *DbUtils) GetTaskByMd5Password(p string) (t *Tunnel) {
|
||||
s.JsonDb.Tasks.Range(func(key, value interface{}) bool {
|
||||
if crypt.Md5(value.(*Tunnel).Password) == p {
|
||||
@@ -218,7 +218,7 @@ func (s *DbUtils) NewClient(c *Client) error {
|
||||
reset:
|
||||
if c.VerifyKey == "" || isNotSet {
|
||||
isNotSet = true
|
||||
c.VerifyKey = crypt.GetRandomString(16)
|
||||
c.VerifyKey = crypt.GetVkey()
|
||||
}
|
||||
if c.RateLimit == 0 {
|
||||
c.Rate = rate.NewRate(int64(2 << 23))
|
||||
@@ -326,7 +326,7 @@ func (s *DbUtils) GetHostById(id int) (h *Host, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
//get key by host from x
|
||||
// get key by host from x
|
||||
func (s *DbUtils) GetInfoByHost(host string, r *http.Request) (h *Host, err error) {
|
||||
var hosts []*Host
|
||||
//Handling Ported Access
|
||||
|
||||
@@ -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,6 +1,6 @@
|
||||
package version
|
||||
|
||||
const VERSION = "0.26.16"
|
||||
const VERSION = "0.26.21"
|
||||
|
||||
// Compulsory minimum version, Minimum downward compatibility to this version
|
||||
func GetVersion() string {
|
||||
|
||||
@@ -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, "", "")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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=20250107',
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -189,10 +189,23 @@
|
||||
<zh-CN>访问端命令</zh-CN>
|
||||
<en-US>Access command</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-quicklycommand">
|
||||
<zh-CN>快捷启动命令</zh-CN>
|
||||
<en-US>Quickly command</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-commandclient">
|
||||
<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 +285,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">
|
||||
@@ -383,6 +396,12 @@
|
||||
<zh-CN>端口</zh-CN>
|
||||
<en-US>Port</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-accessaddress">
|
||||
<zh-CN>访问地址</zh-CN>
|
||||
<en-US>Access address</en-US>
|
||||
</lang>
|
||||
|
||||
<lang id="word-proxytolocal">
|
||||
<zh-CN>代理到服务器本地</zh-CN>
|
||||
<en-US>Proxy to server local</en-US>
|
||||
@@ -733,6 +752,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>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
return '<b langtag="word-maxconnections"></b>: ' + row.MaxConn + ' '
|
||||
+ '<b langtag="word-curconnections"></b>: ' + row.NowConn + ' '
|
||||
+ '<b langtag="word-flowlimit"></b>: ' + row.Flow.FlowLimit + 'm '
|
||||
+ '<b langtag="word-ratelimit"></b>: ' + row.RateLimit + 'kb/s '
|
||||
+ '<b langtag="word-ratelimit"></b>: ' + row.RateLimit + 'KB/s '
|
||||
+ '<b langtag="word-maxtunnels"></b>: ' + row.MaxTunnelNum + ' <br/><br/>'
|
||||
+ '<b langtag="word-webusername"></b>: ' + row.WebUserName + ' '
|
||||
+ '<b langtag="word-webpassword"></b>: ' + row.WebPassword + ' '
|
||||
@@ -71,8 +71,11 @@
|
||||
+ '<b langtag="word-compress"></b>: <span langtag="word-' + row.Cnf.Compress + '"></span> '
|
||||
+ '<b langtag="word-connectbyconfig"></b>: <span langtag="word-' + row.ConfigConnAllow + '"></span> <br/><br/>'
|
||||
+ '<b langtag="word-blackip"></b>: ' + row.BlackIpList + ' <br/><br/>'
|
||||
+ '<b langtag="word-createtime"></b>: ' + row.CreateTime + ' <br/><br/>'
|
||||
+ '<b langtag="word-lastonlinetime"></b>: ' + row.LastOnlineTime + ' <br/><br/>'
|
||||
+ '<b langtag="word-commandclient"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code>"
|
||||
+ '<b langtag="word-quicklycommand"></b>: <span>' + encodeToBase64('{{.ip}}:{{.p}} ' + row.VerifyKey) + '</span> <button class="copy btn btn-info btn-xs" onclick="copyCommand(this)" data-clipboard-text="">复制</button><br/>'
|
||||
+ '<b langtag="word-commandclient"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code><button class=\"copy btn btn-info btn-xs\" onclick=\"copyCommand(this)\" data-clipboard-text=\"\">复制</button><br/>"
|
||||
+ '<b langtag="word-commandclient-tls"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.tls_p}} -vkey=" + row.VerifyKey + " -tls_enable=true</code><button class=\"copy btn btn-info btn-xs\" onclick=\"copyCommand(this)\" data-clipboard-text=\"\">复制</button>"
|
||||
},
|
||||
//表格的列
|
||||
columns: [
|
||||
@@ -211,4 +214,26 @@
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
function encodeToBase64(str){
|
||||
return btoa("nps "+ str);
|
||||
}
|
||||
|
||||
function copyCommand(data) {
|
||||
data.setAttribute("data-clipboard-text", data.previousElementSibling.innerHTML)
|
||||
}
|
||||
|
||||
var clipboard = new ClipboardJS('.copy');
|
||||
clipboard.on('success', function (e) {
|
||||
// alert("复制成功"+e.text)
|
||||
toastr.success('复制成功');
|
||||
e.clearSelection();
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
// alert("复制失败")
|
||||
toastr.error('复制失败', '提示');
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
@@ -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")
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -107,7 +107,10 @@
|
||||
field: 'Host',//域值
|
||||
title: '<span langtag="word-host"></span>',//标题
|
||||
halign: 'center',
|
||||
visible: true//false表示不显示
|
||||
visible: true,//false表示不显示
|
||||
formatter: function (value, row, index) {
|
||||
return "<a href='http://" + row.Host + "' target='_blank'>" + row.Host + "</a>"
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'Scheme',//域值
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,13 +138,26 @@
|
||||
field: 'Port',//域值
|
||||
title: '<span langtag="word-port"></span>',//标题
|
||||
halign: 'center',
|
||||
sortable: true, //启用排序
|
||||
visible: true//false表示不显示
|
||||
},
|
||||
{
|
||||
field: 'address',//域值
|
||||
title: '<span langtag="word-accessaddress"></span>',//标题
|
||||
halign: 'center',
|
||||
sortable: false, //启用排序
|
||||
visible: true,//false表示不显示
|
||||
formatter: function (value, row, index) {
|
||||
var address = {{.ip}} + ":" + row.Port
|
||||
return "<a href='http://" + address + "' target='_blank'>" + address + "</a>"
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'Target',//域值
|
||||
title: '<span langtag="word-target"></span>',//标题
|
||||
halign: 'center',
|
||||
visible: true,//false表示不显示
|
||||
sortable: true, //启用排序
|
||||
formatter: function (value, row, index) {
|
||||
return row.Target.TargetStr
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
<!-- Mainly scripts -->
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link href="{{.web_base_url}}/static/css/toastr.min.css" rel="stylesheet">
|
||||
<link href="{{.web_base_url}}/static/css/fontawesome.min.css" rel="stylesheet">
|
||||
<link href="{{.web_base_url}}/static/css/solid.min.css" rel="stylesheet">
|
||||
<link href="{{.web_base_url}}/static/css/bootstrap.min.css" rel="stylesheet">
|
||||
@@ -19,6 +20,8 @@
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="{{.web_base_url}}/static/js/jquery-3.4.1.min.js"></script>
|
||||
<script src="{{.web_base_url}}/static/js/clipboard.min.js"></script>
|
||||
<script src="{{.web_base_url}}/static/js/toastr.min.js"></script>
|
||||
<script src="{{.web_base_url}}/static/js/popper.min.js"></script>
|
||||
<script src="{{.web_base_url}}/static/js/bootstrap.min.js"></script>
|
||||
<script src="{{.web_base_url}}/static/js/bootstrap-table.min.js"></script>
|
||||
@@ -26,7 +29,8 @@
|
||||
<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>
|
||||
|
||||
|
||||