Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf622b87ba | ||
|
|
700332ef0d | ||
|
|
02d8c6b561 | ||
|
|
f7c04f3271 | ||
|
|
257816e793 | ||
|
|
00e16e88ff | ||
|
|
c265f0ea2a | ||
|
|
4085181585 | ||
|
|
55ee7acd97 | ||
|
|
a1894ca898 | ||
|
|
191b21b8cd | ||
|
|
c5d96a4105 | ||
|
|
37b4e234ef |
@@ -16,7 +16,7 @@ jobs:
|
|||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.15
|
go-version: 1.22
|
||||||
id: go
|
id: go
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@@ -72,4 +72,4 @@ jobs:
|
|||||||
windows_amd64_server.tar.gz
|
windows_amd64_server.tar.gz
|
||||||
npc_sdk.tar.gz
|
npc_sdk.tar.gz
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.15 as builder
|
FROM golang:1.22 as builder
|
||||||
ARG GOPROXY=direct
|
ARG GOPROXY=direct
|
||||||
WORKDIR /go/src/ehang.io/nps
|
WORKDIR /go/src/ehang.io/nps
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.15 as builder
|
FROM golang:1.22 as builder
|
||||||
ARG GOPROXY=direct
|
ARG GOPROXY=direct
|
||||||
WORKDIR /go/src/ehang.io/nps
|
WORKDIR /go/src/ehang.io/nps
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -10,7 +10,11 @@
|
|||||||
***DockerHub***: [NPS](https://hub.docker.com/r/yisier1/nps) [NPC](https://hub.docker.com/r/yisier1/npc)
|
***DockerHub***: [NPS](https://hub.docker.com/r/yisier1/nps) [NPC](https://hub.docker.com/r/yisier1/npc)
|
||||||
|
|
||||||
# 交流群
|
# 交流群
|
||||||
聊天灌水QQ群:619833483
|
聊天灌水QQ群:770569342,619833483(已满)
|
||||||
|
|
||||||
|
# 公益云内网穿透
|
||||||
|
https://natnps.com/
|
||||||
|
公益NPS内网穿透服务,长期免费,6M带宽,3条隧道,不限流量,欢迎来嫖,自行注册账号。
|
||||||
|
|
||||||
# 特价云服务器
|
# 特价云服务器
|
||||||
国内BGP,游戏开服,2核 2G 15M上行 25元/月,[专属连接,首月5折](https://www.rainyun.com/MjY0MzY1_)
|
国内BGP,游戏开服,2核 2G 15M上行 25元/月,[专属连接,首月5折](https://www.rainyun.com/MjY0MzY1_)
|
||||||
@@ -22,7 +26,17 @@
|
|||||||
|
|
||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
- 2024-05-28 v0.26.19
|
- 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.
|
- golang 版本升级到 1.22.
|
||||||
- 增加自动https,自动将http 重定向(301)到 https.
|
- 增加自动https,自动将http 重定向(301)到 https.
|
||||||
- 客户端命令行方式启动支持多个隧道ID,使用逗号拼接,示例:`npc -server=xxx:8024 -vkey=ytkpyr0er676m0r7,iwnbjfbvygvzyzzt` .
|
- 客户端命令行方式启动支持多个隧道ID,使用逗号拼接,示例:`npc -server=xxx:8024 -vkey=ytkpyr0er676m0r7,iwnbjfbvygvzyzzt` .
|
||||||
|
|||||||
@@ -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
|
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
|
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
|
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
|
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
|
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
|
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
|
#/bash/sh
|
||||||
export VERSION=0.26.18
|
export VERSION=0.26.20
|
||||||
export GOPROXY=direct
|
export GOPROXY=direct
|
||||||
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
|||||||
+11
-9
@@ -1,23 +1,24 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"ehang.io/nps/client"
|
|
||||||
"ehang.io/nps/lib/common"
|
|
||||||
"ehang.io/nps/lib/config"
|
|
||||||
"ehang.io/nps/lib/file"
|
|
||||||
"ehang.io/nps/lib/install"
|
|
||||||
"ehang.io/nps/lib/version"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/astaxie/beego/logs"
|
|
||||||
"github.com/ccding/go-stun/stun"
|
|
||||||
"github.com/kardianos/service"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"ehang.io/nps/client"
|
||||||
|
"ehang.io/nps/lib/common"
|
||||||
|
"ehang.io/nps/lib/config"
|
||||||
|
"ehang.io/nps/lib/file"
|
||||||
|
"ehang.io/nps/lib/install"
|
||||||
|
"ehang.io/nps/lib/version"
|
||||||
|
"github.com/astaxie/beego/logs"
|
||||||
|
"github.com/ccding/go-stun/stun"
|
||||||
|
"github.com/kardianos/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -116,6 +117,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
case "nat":
|
case "nat":
|
||||||
c := stun.NewClient()
|
c := stun.NewClient()
|
||||||
|
flag.CommandLine.Parse(os.Args[2:])
|
||||||
c.SetServerAddr(*stunAddr)
|
c.SetServerAddr(*stunAddr)
|
||||||
nat, host, err := c.Discover()
|
nat, host, err := c.Discover()
|
||||||
if err != nil || host == nil {
|
if err != nil || host == nil {
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ crypt=true
|
|||||||
compress=true
|
compress=true
|
||||||
#pprof_addr=0.0.0.0:9999
|
#pprof_addr=0.0.0.0:9999
|
||||||
disconnect_timeout=60
|
disconnect_timeout=60
|
||||||
tls_enable = true
|
tls_enable=true
|
||||||
|
|
||||||
[health_check_test1]
|
[health_check_test1]
|
||||||
health_check_timeout=1
|
health_check_timeout=1
|
||||||
|
|||||||
+6
-6
@@ -11,7 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
//en
|
// en
|
||||||
func AesEncrypt(origData, key []byte) ([]byte, error) {
|
func AesEncrypt(origData, key []byte) ([]byte, error) {
|
||||||
block, err := aes.NewCipher(key)
|
block, err := aes.NewCipher(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -25,7 +25,7 @@ func AesEncrypt(origData, key []byte) ([]byte, error) {
|
|||||||
return crypted, nil
|
return crypted, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//de
|
// de
|
||||||
func AesDecrypt(crypted, key []byte) ([]byte, error) {
|
func AesDecrypt(crypted, key []byte) ([]byte, error) {
|
||||||
block, err := aes.NewCipher(key)
|
block, err := aes.NewCipher(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -39,14 +39,14 @@ func AesDecrypt(crypted, key []byte) ([]byte, error) {
|
|||||||
return origData, err
|
return origData, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Completion when the length is insufficient
|
// Completion when the length is insufficient
|
||||||
func PKCS5Padding(ciphertext []byte, blockSize int) []byte {
|
func PKCS5Padding(ciphertext []byte, blockSize int) []byte {
|
||||||
padding := blockSize - len(ciphertext)%blockSize
|
padding := blockSize - len(ciphertext)%blockSize
|
||||||
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
|
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
|
||||||
return append(ciphertext, padtext...)
|
return append(ciphertext, padtext...)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove excess
|
// Remove excess
|
||||||
func PKCS5UnPadding(origData []byte) (error, []byte) {
|
func PKCS5UnPadding(origData []byte) (error, []byte) {
|
||||||
length := len(origData)
|
length := len(origData)
|
||||||
unpadding := int(origData[length-1])
|
unpadding := int(origData[length-1])
|
||||||
@@ -56,14 +56,14 @@ func PKCS5UnPadding(origData []byte) (error, []byte) {
|
|||||||
return nil, origData[:(length - unpadding)]
|
return nil, origData[:(length - unpadding)]
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate 32-bit MD5 strings
|
// Generate 32-bit MD5 strings
|
||||||
func Md5(s string) string {
|
func Md5(s string) string {
|
||||||
h := md5.New()
|
h := md5.New()
|
||||||
h.Write([]byte(s))
|
h.Write([]byte(s))
|
||||||
return hex.EncodeToString(h.Sum(nil))
|
return hex.EncodeToString(h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generating Random Verification Key
|
// Generating Random Verification Key
|
||||||
func GetRandomString(l int) string {
|
func GetRandomString(l int) string {
|
||||||
str := "0123456789abcdefghijklmnopqrstuvwxyz"
|
str := "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||||
bytes := []byte(str)
|
bytes := []byte(str)
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ type Client struct {
|
|||||||
MaxTunnelNum int
|
MaxTunnelNum int
|
||||||
Version string
|
Version string
|
||||||
BlackIpList []string
|
BlackIpList []string
|
||||||
|
CreateTime string
|
||||||
LastOnlineTime string
|
LastOnlineTime string
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
}
|
}
|
||||||
@@ -110,6 +111,14 @@ func (s *Client) GetTunnelNum() (num int) {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
GetDb().JsonDb.Hosts.Range(func(key, value interface{}) bool {
|
||||||
|
v := value.(*Host)
|
||||||
|
if v.Client.Id == s.Id {
|
||||||
|
num++
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package version
|
package version
|
||||||
|
|
||||||
const VERSION = "0.26.19"
|
const VERSION = "0.26.20"
|
||||||
|
|
||||||
// Compulsory minimum version, Minimum downward compatibility to this version
|
// Compulsory minimum version, Minimum downward compatibility to this version
|
||||||
func GetVersion() string {
|
func GetVersion() string {
|
||||||
|
|||||||
+61
-15
@@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -32,7 +33,7 @@ func init() {
|
|||||||
RunList = sync.Map{}
|
RunList = sync.Map{}
|
||||||
}
|
}
|
||||||
|
|
||||||
//init task from db
|
// init task from db
|
||||||
func InitFromCsv() {
|
func InitFromCsv() {
|
||||||
//Add a public password
|
//Add a public password
|
||||||
if vkey := beego.AppConfig.String("public_vkey"); vkey != "" {
|
if vkey := beego.AppConfig.String("public_vkey"); vkey != "" {
|
||||||
@@ -50,7 +51,7 @@ func InitFromCsv() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//get bridge command
|
// get bridge command
|
||||||
func DealBridgeTask() {
|
func DealBridgeTask() {
|
||||||
for {
|
for {
|
||||||
select {
|
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) {
|
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)
|
Bridge = bridge.NewTunnel(bridgePort, bridgeType, common.GetBoolByStr(beego.AppConfig.String("ip_limit")), RunList, bridgeDisconnect)
|
||||||
go func() {
|
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 {
|
func NewMode(Bridge *bridge.Bridge, c *file.Tunnel) proxy.Service {
|
||||||
var service proxy.Service
|
var service proxy.Service
|
||||||
switch c.Mode {
|
switch c.Mode {
|
||||||
@@ -156,7 +157,7 @@ func NewMode(Bridge *bridge.Bridge, c *file.Tunnel) proxy.Service {
|
|||||||
return service
|
return service
|
||||||
}
|
}
|
||||||
|
|
||||||
//stop server
|
// stop server
|
||||||
func StopServer(id int) error {
|
func StopServer(id int) error {
|
||||||
//if v, ok := RunList[id]; ok {
|
//if v, ok := RunList[id]; ok {
|
||||||
if v, ok := RunList.Load(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")
|
return errors.New("task is not running")
|
||||||
}
|
}
|
||||||
|
|
||||||
//add task
|
// add task
|
||||||
func AddTask(t *file.Tunnel) error {
|
func AddTask(t *file.Tunnel) error {
|
||||||
if t.Mode == "secret" || t.Mode == "p2p" {
|
if t.Mode == "secret" || t.Mode == "p2p" {
|
||||||
logs.Info("secret task %s start ", t.Remark)
|
logs.Info("secret task %s start ", t.Remark)
|
||||||
@@ -215,7 +216,7 @@ func AddTask(t *file.Tunnel) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//start task
|
// start task
|
||||||
func StartTask(id int) error {
|
func StartTask(id int) error {
|
||||||
if t, err := file.GetDb().GetTask(id); err != nil {
|
if t, err := file.GetDb().GetTask(id); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -227,7 +228,7 @@ func StartTask(id int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete task
|
// delete task
|
||||||
func DelTask(id int) error {
|
func DelTask(id int) error {
|
||||||
//if _, ok := RunList[id]; ok {
|
//if _, ok := RunList[id]; ok {
|
||||||
if _, ok := RunList.Load(id); ok {
|
if _, ok := RunList.Load(id); ok {
|
||||||
@@ -238,18 +239,64 @@ func DelTask(id int) error {
|
|||||||
return file.GetDb().DelTask(id)
|
return file.GetDb().DelTask(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
//get task list by page num
|
// get task list by page num
|
||||||
func GetTunnel(start, length int, typeVal string, clientId int, search string) ([]*file.Tunnel, int) {
|
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)
|
list := make([]*file.Tunnel, 0)
|
||||||
var cnt int
|
var cnt int
|
||||||
keys := file.GetMapKeys(file.GetDb().JsonDb.Tasks, false, "", "")
|
keys := file.GetMapKeys(file.GetDb().JsonDb.Tasks, false, "", "")
|
||||||
|
|
||||||
|
//get all Tunnel and sort
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
if value, ok := file.GetDb().JsonDb.Tasks.Load(key); ok {
|
if value, ok := file.GetDb().JsonDb.Tasks.Load(key); ok {
|
||||||
v := value.(*file.Tunnel)
|
v := value.(*file.Tunnel)
|
||||||
if (typeVal != "" && v.Mode != typeVal || (clientId != 0 && v.Client.Id != clientId)) || (typeVal == "" && clientId != v.Client.Id) {
|
if (typeVal != "" && v.Mode != typeVal || (clientId != 0 && v.Client.Id != clientId)) || (typeVal == "" && clientId != v.Client.Id) {
|
||||||
continue
|
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
|
continue
|
||||||
}
|
}
|
||||||
cnt++
|
cnt++
|
||||||
@@ -260,7 +307,6 @@ func GetTunnel(start, length int, typeVal string, clientId int, search string) (
|
|||||||
}
|
}
|
||||||
if start--; start < 0 {
|
if start--; start < 0 {
|
||||||
if length--; length >= 0 {
|
if length--; length >= 0 {
|
||||||
//if _, ok := RunList[v.Id]; ok {
|
|
||||||
if _, ok := RunList.Load(v.Id); ok {
|
if _, ok := RunList.Load(v.Id); ok {
|
||||||
v.RunStatus = true
|
v.RunStatus = true
|
||||||
} else {
|
} else {
|
||||||
@@ -274,7 +320,7 @@ func GetTunnel(start, length int, typeVal string, clientId int, search string) (
|
|||||||
return list, cnt
|
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) {
|
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)
|
list, cnt = file.GetDb().GetClientList(start, length, search, sort, order, clientId)
|
||||||
dealClientData()
|
dealClientData()
|
||||||
@@ -326,7 +372,7 @@ func dealClientData() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete all host and tasks by client id
|
// delete all host and tasks by client id
|
||||||
func DelTunnelAndHostByClientId(clientId int, justDelNoStore bool) {
|
func DelTunnelAndHostByClientId(clientId int, justDelNoStore bool) {
|
||||||
var ids []int
|
var ids []int
|
||||||
file.GetDb().JsonDb.Tasks.Range(func(key, value interface{}) bool {
|
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) {
|
func DelClientConnect(clientId int) {
|
||||||
Bridge.DelClient(clientId)
|
Bridge.DelClient(clientId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"ehang.io/nps/server"
|
"ehang.io/nps/server"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClientController struct {
|
type ClientController struct {
|
||||||
@@ -37,7 +38,7 @@ func (s *ClientController) List() {
|
|||||||
s.AjaxTable(list, cnt, cnt, cmd)
|
s.AjaxTable(list, cnt, cnt, cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加客户端
|
// 添加客户端
|
||||||
func (s *ClientController) Add() {
|
func (s *ClientController) Add() {
|
||||||
if s.Ctx.Request.Method == "GET" {
|
if s.Ctx.Request.Method == "GET" {
|
||||||
s.Data["menu"] = "client"
|
s.Data["menu"] = "client"
|
||||||
@@ -68,6 +69,7 @@ func (s *ClientController) Add() {
|
|||||||
FlowLimit: int64(s.GetIntNoErr("flow_limit")),
|
FlowLimit: int64(s.GetIntNoErr("flow_limit")),
|
||||||
},
|
},
|
||||||
BlackIpList: RemoveRepeatedElement(strings.Split(s.getEscapeString("blackiplist"), "\r\n")),
|
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 {
|
if err := file.GetDb().NewClient(t); err != nil {
|
||||||
s.AjaxErr(err.Error())
|
s.AjaxErr(err.Error())
|
||||||
@@ -90,7 +92,7 @@ func (s *ClientController) GetClient() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//修改客户端
|
// 修改客户端
|
||||||
func (s *ClientController) Edit() {
|
func (s *ClientController) Edit() {
|
||||||
id := s.GetIntNoErr("id")
|
id := s.GetIntNoErr("id")
|
||||||
if s.Ctx.Request.Method == "GET" {
|
if s.Ctx.Request.Method == "GET" {
|
||||||
@@ -172,7 +174,7 @@ func RemoveRepeatedElement(arr []string) (newArr []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//更改状态
|
// 更改状态
|
||||||
func (s *ClientController) ChangeStatus() {
|
func (s *ClientController) ChangeStatus() {
|
||||||
id := s.GetIntNoErr("id")
|
id := s.GetIntNoErr("id")
|
||||||
if client, err := file.GetDb().GetClient(id); err == nil {
|
if client, err := file.GetDb().GetClient(id); err == nil {
|
||||||
@@ -185,7 +187,7 @@ func (s *ClientController) ChangeStatus() {
|
|||||||
s.AjaxErr("modified fail")
|
s.AjaxErr("modified fail")
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除客户端
|
// 删除客户端
|
||||||
func (s *ClientController) Del() {
|
func (s *ClientController) Del() {
|
||||||
id := s.GetIntNoErr("id")
|
id := s.GetIntNoErr("id")
|
||||||
if err := file.GetDb().DelClient(id); err != nil {
|
if err := file.GetDb().DelClient(id); err != nil {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func (s *IndexController) GetTunnel() {
|
|||||||
start, length := s.GetAjaxParams()
|
start, length := s.GetAjaxParams()
|
||||||
taskType := s.getEscapeString("type")
|
taskType := s.getEscapeString("type")
|
||||||
clientId := s.GetIntNoErr("client_id")
|
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)
|
s.AjaxTable(list, cnt, cnt, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,6 +278,10 @@ func (s *IndexController) AddHost() {
|
|||||||
if h.Client, err = file.GetDb().GetClient(s.GetIntNoErr("client_id")); err != nil {
|
if h.Client, err = file.GetDb().GetClient(s.GetIntNoErr("client_id")); err != nil {
|
||||||
s.AjaxErr("add error the client can not be found")
|
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 {
|
if err := file.GetDb().NewHost(h); err != nil {
|
||||||
s.AjaxErr("add fail" + err.Error())
|
s.AjaxErr("add fail" + err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,11 @@ function submitform(action, url, postdata) {
|
|||||||
success: function (res) {
|
success: function (res) {
|
||||||
alert(langreply(res.msg));
|
alert(langreply(res.msg));
|
||||||
if (res.status) {
|
if (res.status) {
|
||||||
if (postsubmit) {document.location.reload();}else{history.back(-1);}
|
if (postsubmit) {
|
||||||
|
document.location.reload();
|
||||||
|
}else{
|
||||||
|
window.location.href= document.referrer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -740,6 +740,11 @@
|
|||||||
<en-US>IP Black List</en-US>
|
<en-US>IP Black List</en-US>
|
||||||
</lang>
|
</lang>
|
||||||
|
|
||||||
|
<lang id="word-createtime">
|
||||||
|
<zh-CN>创建时间</zh-CN>
|
||||||
|
<en-US>Create Time</en-US>
|
||||||
|
</lang>
|
||||||
|
|
||||||
<lang id="word-lastonlinetime">
|
<lang id="word-lastonlinetime">
|
||||||
<zh-CN>上次在线时间</zh-CN>
|
<zh-CN>上次在线时间</zh-CN>
|
||||||
<en-US>Last Online Time</en-US>
|
<en-US>Last Online Time</en-US>
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
return '<b langtag="word-maxconnections"></b>: ' + row.MaxConn + ' '
|
return '<b langtag="word-maxconnections"></b>: ' + row.MaxConn + ' '
|
||||||
+ '<b langtag="word-curconnections"></b>: ' + row.NowConn + ' '
|
+ '<b langtag="word-curconnections"></b>: ' + row.NowConn + ' '
|
||||||
+ '<b langtag="word-flowlimit"></b>: ' + row.Flow.FlowLimit + 'm '
|
+ '<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-maxtunnels"></b>: ' + row.MaxTunnelNum + ' <br/><br/>'
|
||||||
+ '<b langtag="word-webusername"></b>: ' + row.WebUserName + ' '
|
+ '<b langtag="word-webusername"></b>: ' + row.WebUserName + ' '
|
||||||
+ '<b langtag="word-webpassword"></b>: ' + row.WebPassword + ' '
|
+ '<b langtag="word-webpassword"></b>: ' + row.WebPassword + ' '
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
+ '<b langtag="word-compress"></b>: <span langtag="word-' + row.Cnf.Compress + '"></span> '
|
+ '<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-connectbyconfig"></b>: <span langtag="word-' + row.ConfigConnAllow + '"></span> <br/><br/>'
|
||||||
+ '<b langtag="word-blackip"></b>: ' + row.BlackIpList + ' <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-lastonlinetime"></b>: ' + row.LastOnlineTime + ' <br/><br/>'
|
||||||
+ '<b langtag="word-commandclient"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code><br/>"
|
+ '<b langtag="word-commandclient"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code><br/>"
|
||||||
+ '<b langtag="word-commandclient-tls"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.tls_p}} -vkey=" + row.VerifyKey + " -tls_enable=true</code>"
|
+ '<b langtag="word-commandclient-tls"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.tls_p}} -vkey=" + row.VerifyKey + " -tls_enable=true</code>"
|
||||||
|
|||||||
@@ -32,8 +32,10 @@
|
|||||||
<div class="form-group" id="client_id">
|
<div class="form-group" id="client_id">
|
||||||
<label class="control-label font-bold" langtag="word-clientid"></label>
|
<label class="control-label font-bold" langtag="word-clientid"></label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input value="{{.client_id}}" class="form-control" type="text" name="client_id"
|
<select class="form-control" name="client_id" placeholder="" langtag="word-belongclient"></select>
|
||||||
placeholder="" langtag="word-clientid">
|
|
||||||
|
<!-- <input value="{{.client_id}}" class="form-control" type="text" name="client_id"-->
|
||||||
|
<!-- placeholder="" langtag="word-clientid">-->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -151,5 +153,27 @@
|
|||||||
$("#use_client").on("change", function () {
|
$("#use_client").on("change", function () {
|
||||||
resetForm()
|
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>
|
</script>
|
||||||
|
|||||||
+47
-16
@@ -7,7 +7,9 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label font-bold" langtag="word-clientid"></label>
|
<label class="control-label font-bold" langtag="word-clientid"></label>
|
||||||
<div class="col-sm-10">
|
<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>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -19,7 +21,8 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label font-bold" langtag="word-host"></label>
|
<label class="control-label font-bold" langtag="word-host"></label>
|
||||||
<div class="col-sm-10">
|
<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>
|
</div>
|
||||||
<div class="form-group" id="scheme">
|
<div class="form-group" id="scheme">
|
||||||
@@ -46,22 +49,25 @@
|
|||||||
<div class="form-group" id="cert_file">
|
<div class="form-group" id="cert_file">
|
||||||
<label class="control-label font-bold" langtag="word-httpscert"></label>
|
<label class="control-label font-bold" langtag="word-httpscert"></label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<textarea rows="6" class="form-control" type="text" name="cert_file_path" id="pemText" placeholder="请将证书文件拖拽或将内容复制粘贴到此处,证书文件格式为:xxxx_example.com.pem"></textarea>
|
<textarea rows="6" class="form-control" type="text" name="cert_file_path" id="pemText"
|
||||||
|
placeholder="请将证书文件拖拽或将内容复制粘贴到此处,证书文件格式为:xxxx_example.com.pem"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" id="key_file">
|
<div class="form-group" id="key_file">
|
||||||
<label class="control-label font-bold" langtag="word-httpskey"></label>
|
<label class="control-label font-bold" langtag="word-httpskey"></label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<textarea rows="6" class="form-control" type="text" name="key_file_path" id="pemKey" placeholder="请将私钥文件拖拽或复制粘贴到此处,证书秘钥格式为:xxxx_example.com.key"></textarea>
|
<textarea rows="6" class="form-control" type="text" name="key_file_path" id="pemKey"
|
||||||
|
placeholder="请将私钥文件拖拽或复制粘贴到此处,证书秘钥格式为:xxxx_example.com.key"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label font-bold" langtag="word-urlroute"></label>
|
<label class="control-label font-bold" langtag="word-urlroute"></label>
|
||||||
<div class="col-sm-10">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{{if eq true .allow_local_proxy}}
|
{{if eq true .allow_local_proxy}}
|
||||||
<div class="form-group" id="local_proxy">
|
<div class="form-group" id="local_proxy">
|
||||||
<label class="control-label font-bold" langtag="word-proxytolocal"></label>
|
<label class="control-label font-bold" langtag="word-proxytolocal"></label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
@@ -71,11 +77,12 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label font-bold" langtag="word-target"></label>
|
<label class="control-label font-bold" langtag="word-target"></label>
|
||||||
<div class="col-sm-10">
|
<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>
|
<span class="help-block m-b-none" langtag="info-targethost"></span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -83,7 +90,8 @@
|
|||||||
<div class="form-group" id="header">
|
<div class="form-group" id="header">
|
||||||
<label class="control-label font-bold" langtag="word-requestheader"></label>
|
<label class="control-label font-bold" langtag="word-requestheader"></label>
|
||||||
<div class="col-sm-10">
|
<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>
|
<span class="help-block m-b-none" langtag="info-header"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -91,13 +99,15 @@
|
|||||||
<div class="form-group" id="hostchange">
|
<div class="form-group" id="hostchange">
|
||||||
<label class="control-label font-bold" langtag="word-requesthost"></label>
|
<label class="control-label font-bold" langtag="word-requesthost"></label>
|
||||||
<div class="col-sm-10">
|
<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>
|
</div>
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-4 col-sm-offset-2">
|
<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>
|
<i class="fa fa-fw fa-lg fa-check-circle"></i> <span langtag="word-add"></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -113,16 +123,16 @@
|
|||||||
const pemKey = document.getElementById("pemKey");
|
const pemKey = document.getElementById("pemKey");
|
||||||
|
|
||||||
// 阻止浏览器默认打开文件的行为
|
// 阻止浏览器默认打开文件的行为
|
||||||
document.addEventListener("dragover", function(event) {
|
document.addEventListener("dragover", function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
pemText.addEventListener("drop", function(event) {
|
pemText.addEventListener("drop", function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const file = event.dataTransfer.files[0];
|
const file = event.dataTransfer.files[0];
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
|
|
||||||
reader.onload = function(e) {
|
reader.onload = function (e) {
|
||||||
pemText.value = e.target.result;
|
pemText.value = e.target.result;
|
||||||
console.log("上传pem")
|
console.log("上传pem")
|
||||||
$('#edit_form').data('bootstrapValidator').updateStatus('pemText', 'NOT_VALIDATED');
|
$('#edit_form').data('bootstrapValidator').updateStatus('pemText', 'NOT_VALIDATED');
|
||||||
@@ -132,12 +142,12 @@
|
|||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
pemKey.addEventListener("drop", function(event) {
|
pemKey.addEventListener("drop", function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const file = event.dataTransfer.files[0];
|
const file = event.dataTransfer.files[0];
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
|
|
||||||
reader.onload = function(e) {
|
reader.onload = function (e) {
|
||||||
pemKey.value = e.target.result;
|
pemKey.value = e.target.result;
|
||||||
$('#edit_form').data('bootstrapValidator').updateStatus('pemKey', 'NOT_VALIDATED');
|
$('#edit_form').data('bootstrapValidator').updateStatus('pemKey', 'NOT_VALIDATED');
|
||||||
$('#edit_form').data('bootstrapValidator').validateField('pemKey');
|
$('#edit_form').data('bootstrapValidator').validateField('pemKey');
|
||||||
@@ -158,5 +168,26 @@
|
|||||||
$("#AutoHttps").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>
|
</script>
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
halign: 'center',
|
halign: 'center',
|
||||||
visible: true,//false表示不显示
|
visible: true,//false表示不显示
|
||||||
formatter: function (value, row, index) {
|
formatter: function (value, row, index) {
|
||||||
return row.Client.Id
|
return row.Client.Id + '-' + row.Client.Remark
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,9 @@
|
|||||||
"limit": params.limit,
|
"limit": params.limit,
|
||||||
"type":{{.type}},
|
"type":{{.type}},
|
||||||
"client_id":{{.client_id}},
|
"client_id":{{.client_id}},
|
||||||
"search": params.search
|
"search": params.search,
|
||||||
|
"sort": params.sort,
|
||||||
|
"order": params.order
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
search: true,
|
search: true,
|
||||||
@@ -97,15 +99,17 @@
|
|||||||
field: 'Id',//域值
|
field: 'Id',//域值
|
||||||
title: '<span langtag="word-id"></span>',//标题
|
title: '<span langtag="word-id"></span>',//标题
|
||||||
halign: 'center',
|
halign: 'center',
|
||||||
visible: true//false表示不显示
|
visible: true,//false表示不显示
|
||||||
|
sortable: true,//启用排序
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'Id',//域值
|
field: 'ClientId',//域值
|
||||||
title: '<span langtag="word-clientid"></span>',//标题
|
title: '<span langtag="word-clientid"></span>',//标题
|
||||||
halign: 'center',
|
halign: 'center',
|
||||||
visible: true,//false表示不显示
|
visible: true,//false表示不显示
|
||||||
|
sortable: true, //启用排序
|
||||||
formatter: function (value, row, index) {
|
formatter: function (value, row, index) {
|
||||||
return row.Client.Id
|
return row.Client.Id + '-' + row.Client.Remark
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -118,6 +122,7 @@
|
|||||||
field: 'Client.VerifyKey',//域值
|
field: 'Client.VerifyKey',//域值
|
||||||
title: '<span langtag="word-verifykey"></span>',//标题
|
title: '<span langtag="word-verifykey"></span>',//标题
|
||||||
halign: 'center',
|
halign: 'center',
|
||||||
|
sortable: true, //启用排序
|
||||||
visible: true//false表示不显示
|
visible: true//false表示不显示
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -133,6 +138,7 @@
|
|||||||
field: 'Port',//域值
|
field: 'Port',//域值
|
||||||
title: '<span langtag="word-port"></span>',//标题
|
title: '<span langtag="word-port"></span>',//标题
|
||||||
halign: 'center',
|
halign: 'center',
|
||||||
|
sortable: true, //启用排序
|
||||||
visible: true//false表示不显示
|
visible: true//false表示不显示
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -140,6 +146,7 @@
|
|||||||
title: '<span langtag="word-target"></span>',//标题
|
title: '<span langtag="word-target"></span>',//标题
|
||||||
halign: 'center',
|
halign: 'center',
|
||||||
visible: true,//false表示不显示
|
visible: true,//false表示不显示
|
||||||
|
sortable: true, //启用排序
|
||||||
formatter: function (value, row, index) {
|
formatter: function (value, row, index) {
|
||||||
return row.Target.TargetStr
|
return row.Target.TargetStr
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user