Compare commits

..
13 Commits
Author SHA1 Message Date
yisier bf622b87ba 隧道列表排序 2024-11-07 15:40:37 +08:00
yisier 700332ef0d Merge pull request #177 from axfinn/fix/nat_0614
fix: 修复nat参数指定stun服务错误问题
2024-11-07 14:59:16 +08:00
yisier 02d8c6b561 - 在 Client 结构中添加 CreateTime 字段,用于记录客户端创建时间
- 在添加客户端时设置创建时间
- 在客户端列表页面显示创建时间- 修复了客户端限速单位不统一的问题
- 增加了从下拉菜单选择客户端的功能
- 优化了编辑客户端后不会刷新页面的问题
-修复了隧道数量限制无法统计域名映射的问题
2024-11-07 14:49:49 +08:00
yisier f7c04f3271 Update README.md 2024-09-27 22:29:49 +08:00
yisier 257816e793 Update README.md 2024-09-26 15:05:24 +08:00
yisier 00e16e88ff 客户端限速单位不统一 2024-09-03 11:26:43 -04:00
yisier c265f0ea2a Update README.md 2024-08-31 18:14:26 -04:00
axiu 4085181585 fix: 修复nat参数指定stun服务错误问题 2024-06-14 10:42:39 +08:00
yisier 55ee7acd97 配置文件多了空格 2024-06-04 18:03:02 +08:00
yisier a1894ca898 darwin arm64 2024-06-04 15:46:15 +08:00
yisier 191b21b8cd v0.26.19 2024-06-01 22:25:27 +08:00
yisier c5d96a4105 v0.26.19 2024-06-01 22:09:11 +08:00
yisier 37b4e234ef Update pkg.yml 2024-06-01 21:58:30 +08:00
21 changed files with 229 additions and 69 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.22
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
@@ -72,4 +72,4 @@ jobs:
windows_amd64_server.tar.gz
npc_sdk.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.15 as builder
FROM golang:1.22 as builder
ARG GOPROXY=direct
WORKDIR /go/src/ehang.io/nps
COPY . .
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.15 as builder
FROM golang:1.22 as builder
ARG GOPROXY=direct
WORKDIR /go/src/ehang.io/nps
COPY . .
+16 -2
View File
@@ -10,7 +10,11 @@
***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_)
@@ -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.
- 增加自动https,自动将http 重定向(301)到 https.
- 客户端命令行方式启动支持多个隧道ID,使用逗号拼接,示例:`npc -server=xxx:8024 -vkey=ytkpyr0er676m0r7,iwnbjfbvygvzyzzt` .
+11
View File
@@ -78,6 +78,11 @@ CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -sta
tar -czvf darwin_amd64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go
tar -czvf darwin_arm64_client.tar.gz npc conf/npc.conf conf/multi_account.conf
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go
tar -czvf linux_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps
@@ -146,6 +151,12 @@ CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -sta
tar -czvf darwin_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go
tar -czvf darwin_arm64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go
tar -czvf windows_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe
+1 -1
View File
@@ -1,5 +1,5 @@
#/bash/sh
export VERSION=0.26.18
export VERSION=0.26.20
export GOPROXY=direct
sudo apt-get update
+11 -9
View File
@@ -1,23 +1,24 @@
package main
import (
"ehang.io/nps/client"
"ehang.io/nps/lib/common"
"ehang.io/nps/lib/config"
"ehang.io/nps/lib/file"
"ehang.io/nps/lib/install"
"ehang.io/nps/lib/version"
"flag"
"fmt"
"github.com/astaxie/beego/logs"
"github.com/ccding/go-stun/stun"
"github.com/kardianos/service"
"os"
"os/exec"
"runtime"
"strings"
"sync"
"time"
"ehang.io/nps/client"
"ehang.io/nps/lib/common"
"ehang.io/nps/lib/config"
"ehang.io/nps/lib/file"
"ehang.io/nps/lib/install"
"ehang.io/nps/lib/version"
"github.com/astaxie/beego/logs"
"github.com/ccding/go-stun/stun"
"github.com/kardianos/service"
)
var (
@@ -116,6 +117,7 @@ func main() {
return
case "nat":
c := stun.NewClient()
flag.CommandLine.Parse(os.Args[2:])
c.SetServerAddr(*stunAddr)
nat, host, err := c.Discover()
if err != nil || host == nil {
+1 -1
View File
@@ -14,7 +14,7 @@ crypt=true
compress=true
#pprof_addr=0.0.0.0:9999
disconnect_timeout=60
tls_enable = true
tls_enable=true
[health_check_test1]
health_check_timeout=1
+6 -6
View File
@@ -11,7 +11,7 @@ import (
"time"
)
//en
// en
func AesEncrypt(origData, key []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
@@ -25,7 +25,7 @@ func AesEncrypt(origData, key []byte) ([]byte, error) {
return crypted, nil
}
//de
// de
func AesDecrypt(crypted, key []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
@@ -39,14 +39,14 @@ func AesDecrypt(crypted, key []byte) ([]byte, error) {
return origData, err
}
//Completion when the length is insufficient
// Completion when the length is insufficient
func PKCS5Padding(ciphertext []byte, blockSize int) []byte {
padding := blockSize - len(ciphertext)%blockSize
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
return append(ciphertext, padtext...)
}
//Remove excess
// Remove excess
func PKCS5UnPadding(origData []byte) (error, []byte) {
length := len(origData)
unpadding := int(origData[length-1])
@@ -56,14 +56,14 @@ func PKCS5UnPadding(origData []byte) (error, []byte) {
return nil, origData[:(length - unpadding)]
}
//Generate 32-bit MD5 strings
// Generate 32-bit MD5 strings
func Md5(s string) string {
h := md5.New()
h.Write([]byte(s))
return hex.EncodeToString(h.Sum(nil))
}
//Generating Random Verification Key
// Generating Random Verification Key
func GetRandomString(l int) string {
str := "0123456789abcdefghijklmnopqrstuvwxyz"
bytes := []byte(str)
+9
View File
@@ -52,6 +52,7 @@ type Client struct {
MaxTunnelNum int
Version string
BlackIpList []string
CreateTime string
LastOnlineTime string
sync.RWMutex
}
@@ -110,6 +111,14 @@ func (s *Client) GetTunnelNum() (num int) {
}
return true
})
GetDb().JsonDb.Hosts.Range(func(key, value interface{}) bool {
v := value.(*Host)
if v.Client.Id == s.Id {
num++
}
return true
})
return
}
+1 -1
View File
@@ -1,6 +1,6 @@
package version
const VERSION = "0.26.19"
const VERSION = "0.26.20"
// Compulsory minimum version, Minimum downward compatibility to this version
func GetVersion() string {
+61 -15
View File
@@ -5,6 +5,7 @@ import (
"errors"
"math"
"os"
"sort"
"strconv"
"strings"
"sync"
@@ -32,7 +33,7 @@ func init() {
RunList = sync.Map{}
}
//init task from db
// init task from db
func InitFromCsv() {
//Add a public password
if vkey := beego.AppConfig.String("public_vkey"); vkey != "" {
@@ -50,7 +51,7 @@ func InitFromCsv() {
})
}
//get bridge command
// get bridge command
func DealBridgeTask() {
for {
select {
@@ -84,7 +85,7 @@ func DealBridgeTask() {
}
}
//start a new server
// start a new server
func StartNewServer(bridgePort int, cnf *file.Tunnel, bridgeType string, bridgeDisconnect int) {
Bridge = bridge.NewTunnel(bridgePort, bridgeType, common.GetBoolByStr(beego.AppConfig.String("ip_limit")), RunList, bridgeDisconnect)
go func() {
@@ -122,7 +123,7 @@ func dealClientFlow() {
}
}
//new a server by mode name
// new a server by mode name
func NewMode(Bridge *bridge.Bridge, c *file.Tunnel) proxy.Service {
var service proxy.Service
switch c.Mode {
@@ -156,7 +157,7 @@ func NewMode(Bridge *bridge.Bridge, c *file.Tunnel) proxy.Service {
return service
}
//stop server
// stop server
func StopServer(id int) error {
//if v, ok := RunList[id]; ok {
if v, ok := RunList.Load(id); ok {
@@ -182,7 +183,7 @@ func StopServer(id int) error {
return errors.New("task is not running")
}
//add task
// add task
func AddTask(t *file.Tunnel) error {
if t.Mode == "secret" || t.Mode == "p2p" {
logs.Info("secret task %s start ", t.Remark)
@@ -215,7 +216,7 @@ func AddTask(t *file.Tunnel) error {
return nil
}
//start task
// start task
func StartTask(id int) error {
if t, err := file.GetDb().GetTask(id); err != nil {
return err
@@ -227,7 +228,7 @@ func StartTask(id int) error {
return nil
}
//delete task
// delete task
func DelTask(id int) error {
//if _, ok := RunList[id]; ok {
if _, ok := RunList.Load(id); ok {
@@ -238,18 +239,64 @@ func DelTask(id int) error {
return file.GetDb().DelTask(id)
}
//get task list by page num
func GetTunnel(start, length int, typeVal string, clientId int, search string) ([]*file.Tunnel, int) {
// get task list by page num
func GetTunnel(start, length int, typeVal string, clientId int, search string, sortField string, order string) ([]*file.Tunnel, int) {
all_list := make([]*file.Tunnel, 0) //store all Tunnel
list := make([]*file.Tunnel, 0)
var cnt int
keys := file.GetMapKeys(file.GetDb().JsonDb.Tasks, false, "", "")
//get all Tunnel and sort
for _, key := range keys {
if value, ok := file.GetDb().JsonDb.Tasks.Load(key); ok {
v := value.(*file.Tunnel)
if (typeVal != "" && v.Mode != typeVal || (clientId != 0 && v.Client.Id != clientId)) || (typeVal == "" && clientId != v.Client.Id) {
continue
}
if search != "" && !(v.Id == common.GetIntNoErrByStr(search) || v.Port == common.GetIntNoErrByStr(search) || strings.Contains(v.Password, search) || strings.Contains(v.Remark, search) || strings.Contains(v.Client.VerifyKey, search)) {
all_list = append(all_list, v)
}
}
//sort by Id, Remark, TargetStr, Port, asc or desc
if sortField == "Id" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Id < all_list[j].Id })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Id > all_list[j].Id })
}
} else if sortField == "ClientId" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Client.Id < all_list[j].Client.Id })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Client.Id > all_list[j].Client.Id })
}
} else if sortField == "Remark" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Remark < all_list[j].Remark })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Remark > all_list[j].Remark })
}
} else if sortField == "Client.VerifyKey" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Client.VerifyKey < all_list[j].Client.VerifyKey })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Client.VerifyKey > all_list[j].Client.VerifyKey })
}
} else if sortField == "Target" {
if order == "asc" {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Target.TargetStr < all_list[j].Target.TargetStr })
} else {
sort.SliceStable(all_list, func(i, j int) bool { return all_list[i].Target.TargetStr > all_list[j].Target.TargetStr })
}
}
//search
for _, key := range all_list {
if value, ok := file.GetDb().JsonDb.Tasks.Load(key.Id); ok {
v := value.(*file.Tunnel)
if (typeVal != "" && v.Mode != typeVal || (clientId != 0 && v.Client.Id != clientId)) || (typeVal == "" && clientId != v.Client.Id) {
continue
}
if search != "" && !(v.Id == common.GetIntNoErrByStr(search) || v.Port == common.GetIntNoErrByStr(search) || strings.Contains(v.Password, search) || strings.Contains(v.Remark, search) || strings.Contains(v.Target.TargetStr, search)) {
continue
}
cnt++
@@ -260,7 +307,6 @@ func GetTunnel(start, length int, typeVal string, clientId int, search string) (
}
if start--; start < 0 {
if length--; length >= 0 {
//if _, ok := RunList[v.Id]; ok {
if _, ok := RunList.Load(v.Id); ok {
v.RunStatus = true
} else {
@@ -274,7 +320,7 @@ func GetTunnel(start, length int, typeVal string, clientId int, search string) (
return list, cnt
}
//get client list
// get client list
func GetClientList(start, length int, search, sort, order string, clientId int) (list []*file.Client, cnt int) {
list, cnt = file.GetDb().GetClientList(start, length, search, sort, order, clientId)
dealClientData()
@@ -326,7 +372,7 @@ func dealClientData() {
return
}
//delete all host and tasks by client id
// delete all host and tasks by client id
func DelTunnelAndHostByClientId(clientId int, justDelNoStore bool) {
var ids []int
file.GetDb().JsonDb.Tasks.Range(func(key, value interface{}) bool {
@@ -358,7 +404,7 @@ func DelTunnelAndHostByClientId(clientId int, justDelNoStore bool) {
}
}
//close the client
// close the client
func DelClientConnect(clientId int) {
Bridge.DelClient(clientId)
}
+6 -4
View File
@@ -7,6 +7,7 @@ import (
"ehang.io/nps/server"
"github.com/astaxie/beego"
"strings"
"time"
)
type ClientController struct {
@@ -37,7 +38,7 @@ func (s *ClientController) List() {
s.AjaxTable(list, cnt, cnt, cmd)
}
//添加客户端
// 添加客户端
func (s *ClientController) Add() {
if s.Ctx.Request.Method == "GET" {
s.Data["menu"] = "client"
@@ -68,6 +69,7 @@ func (s *ClientController) Add() {
FlowLimit: int64(s.GetIntNoErr("flow_limit")),
},
BlackIpList: RemoveRepeatedElement(strings.Split(s.getEscapeString("blackiplist"), "\r\n")),
CreateTime: time.Now().Format("2006-01-02 15:04:05"),
}
if err := file.GetDb().NewClient(t); err != nil {
s.AjaxErr(err.Error())
@@ -90,7 +92,7 @@ func (s *ClientController) GetClient() {
}
}
//修改客户端
// 修改客户端
func (s *ClientController) Edit() {
id := s.GetIntNoErr("id")
if s.Ctx.Request.Method == "GET" {
@@ -172,7 +174,7 @@ func RemoveRepeatedElement(arr []string) (newArr []string) {
return
}
//更改状态
// 更改状态
func (s *ClientController) ChangeStatus() {
id := s.GetIntNoErr("id")
if client, err := file.GetDb().GetClient(id); err == nil {
@@ -185,7 +187,7 @@ func (s *ClientController) ChangeStatus() {
s.AjaxErr("modified fail")
}
//删除客户端
// 删除客户端
func (s *ClientController) Del() {
id := s.GetIntNoErr("id")
if err := file.GetDb().DelClient(id); err != nil {
+5 -1
View File
@@ -81,7 +81,7 @@ func (s *IndexController) GetTunnel() {
start, length := s.GetAjaxParams()
taskType := s.getEscapeString("type")
clientId := s.GetIntNoErr("client_id")
list, cnt := server.GetTunnel(start, length, taskType, clientId, s.getEscapeString("search"))
list, cnt := server.GetTunnel(start, length, taskType, clientId, s.getEscapeString("search"), s.getEscapeString("sort"), s.getEscapeString("order"))
s.AjaxTable(list, cnt, cnt, nil)
}
@@ -278,6 +278,10 @@ func (s *IndexController) AddHost() {
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())
}
+5 -1
View File
@@ -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
}
}
}
});
+5
View File
@@ -740,6 +740,11 @@
<en-US>IP Black List</en-US>
</lang>
<lang id="word-createtime">
<zh-CN>创建时间</zh-CN>
<en-US>Create Time</en-US>
</lang>
<lang id="word-lastonlinetime">
<zh-CN>上次在线时间</zh-CN>
<en-US>Last Online Time</en-US>
+2 -1
View File
@@ -61,7 +61,7 @@
return '<b langtag="word-maxconnections"></b>: ' + row.MaxConn + '&emsp;'
+ '<b langtag="word-curconnections"></b>: ' + row.NowConn + '&emsp;'
+ '<b langtag="word-flowlimit"></b>: ' + row.Flow.FlowLimit + 'm&emsp;'
+ '<b langtag="word-ratelimit"></b>: ' + row.RateLimit + 'kb/s&emsp;'
+ '<b langtag="word-ratelimit"></b>: ' + row.RateLimit + 'KB/s&emsp;'
+ '<b langtag="word-maxtunnels"></b>: ' + row.MaxTunnelNum + '&emsp;<br/><br/>'
+ '<b langtag="word-webusername"></b>: ' + row.WebUserName + '&emsp;'
+ '<b langtag="word-webpassword"></b>: ' + row.WebPassword + '&emsp;'
@@ -71,6 +71,7 @@
+ '<b langtag="word-compress"></b>: <span langtag="word-' + row.Cnf.Compress + '"></span>&emsp;'
+ '<b langtag="word-connectbyconfig"></b>: <span langtag="word-' + row.ConfigConnAllow + '"></span>&emsp;<br/><br/>'
+ '<b langtag="word-blackip"></b>: ' + row.BlackIpList + '&emsp;<br/><br/>'
+ '<b langtag="word-createtime"></b>: ' + row.CreateTime + '&emsp;<br/><br/>'
+ '<b langtag="word-lastonlinetime"></b>: ' + row.LastOnlineTime + '&emsp;<br/><br/>'
+ '<b langtag="word-commandclient"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"</code><br/>"
+ '<b langtag="word-commandclient-tls"></b>: ' + "<code>./npc{{.win}} -server={{.ip}}:{{.tls_p}} -vkey=" + row.VerifyKey + " -tls_enable=true</code>"
+26 -2
View File
@@ -32,8 +32,10 @@
<div class="form-group" id="client_id">
<label class="control-label font-bold" langtag="word-clientid"></label>
<div class="col-sm-10">
<input value="{{.client_id}}" class="form-control" type="text" name="client_id"
placeholder="" langtag="word-clientid">
<select class="form-control" name="client_id" placeholder="" langtag="word-belongclient"></select>
<!-- <input value="{{.client_id}}" class="form-control" type="text" name="client_id"-->
<!-- placeholder="" langtag="word-clientid">-->
</div>
</div>
@@ -151,5 +153,27 @@
$("#use_client").on("change", function () {
resetForm()
})
getClientList()
})
function getClientList() {
$("select[name='client_id']").empty();
$.ajax({
type: "POST",
url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址
data: {order:"asc",offset:0,limit:999},
dataType : "json",
success : function(data) {
if (data && data.rows.length > 0) {
for(var i=0; i<data.rows.length; i++){
var option="<option value=\""+data.rows[i].Id+"\"";
option += ">"+data.rows[i].Id + '-' +data.rows[i].Remark+"</option>"; //动态添加数据
$("select[name='client_id']").append(option);
$("select[name='client_id']").find("option[value='{{.t.Client.Id}}']").attr("selected",true);
}
}
}
});
}
</script>
+47 -16
View File
@@ -7,7 +7,9 @@
<div class="form-group">
<label class="control-label font-bold" langtag="word-clientid"></label>
<div class="col-sm-10">
<input value="{{.client_id}}" class="form-control" type="text" name="client_id" placeholder="" langtag="word-clientid">
<select class="form-control" name="client_id" placeholder=""
langtag="word-belongclient"></select>
<!-- <input value="{{.client_id}}" class="form-control" type="text" name="client_id" placeholder="" langtag="word-clientid">-->
</div>
</div>
<div class="form-group">
@@ -19,7 +21,8 @@
<div class="form-group">
<label class="control-label font-bold" langtag="word-host"></label>
<div class="col-sm-10">
<input class="form-control" type="text" name="host" placeholder="" langtag="info-suchashost">
<input class="form-control" type="text" name="host" placeholder=""
langtag="info-suchashost">
</div>
</div>
<div class="form-group" id="scheme">
@@ -46,22 +49,25 @@
<div class="form-group" id="cert_file">
<label class="control-label font-bold" langtag="word-httpscert"></label>
<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 class="form-group" id="key_file">
<label class="control-label font-bold" langtag="word-httpskey"></label>
<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 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">
@@ -71,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>
@@ -83,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>
@@ -91,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>
@@ -113,16 +123,16 @@
const pemKey = document.getElementById("pemKey");
// 阻止浏览器默认打开文件的行为
document.addEventListener("dragover", function(event) {
document.addEventListener("dragover", function (event) {
event.preventDefault();
});
pemText.addEventListener("drop", function(event) {
pemText.addEventListener("drop", function (event) {
event.preventDefault();
const file = event.dataTransfer.files[0];
const reader = new FileReader();
reader.onload = function(e) {
reader.onload = function (e) {
pemText.value = e.target.result;
console.log("上传pem")
$('#edit_form').data('bootstrapValidator').updateStatus('pemText', 'NOT_VALIDATED');
@@ -132,12 +142,12 @@
reader.readAsText(file);
});
pemKey.addEventListener("drop", function(event) {
pemKey.addEventListener("drop", function (event) {
event.preventDefault();
const file = event.dataTransfer.files[0];
const reader = new FileReader();
reader.onload = function(e) {
reader.onload = function (e) {
pemKey.value = e.target.result;
$('#edit_form').data('bootstrapValidator').updateStatus('pemKey', 'NOT_VALIDATED');
$('#edit_form').data('bootstrapValidator').validateField('pemKey');
@@ -158,5 +168,26 @@
$("#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>
+1 -1
View File
@@ -88,7 +88,7 @@
halign: 'center',
visible: true,//false表示不显示
formatter: function (value, row, index) {
return row.Client.Id
return row.Client.Id + '-' + row.Client.Remark
}
},
{
+11 -4
View File
@@ -49,7 +49,9 @@
"limit": params.limit,
"type":{{.type}},
"client_id":{{.client_id}},
"search": params.search
"search": params.search,
"sort": params.sort,
"order": params.order
}
},
search: true,
@@ -97,15 +99,17 @@
field: 'Id',//域值
title: '<span langtag="word-id"></span>',//标题
halign: 'center',
visible: true//false表示不显示
visible: true,//false表示不显示
sortable: true,//启用排序
},
{
field: 'Id',//域值
field: 'ClientId',//域值
title: '<span langtag="word-clientid"></span>',//标题
halign: 'center',
visible: true,//false表示不显示
sortable: true, //启用排序
formatter: function (value, row, index) {
return row.Client.Id
return row.Client.Id + '-' + row.Client.Remark
}
},
{
@@ -118,6 +122,7 @@
field: 'Client.VerifyKey',//域值
title: '<span langtag="word-verifykey"></span>',//标题
halign: 'center',
sortable: true, //启用排序
visible: true//false表示不显示
},
{
@@ -133,6 +138,7 @@
field: 'Port',//域值
title: '<span langtag="word-port"></span>',//标题
halign: 'center',
sortable: true, //启用排序
visible: true//false表示不显示
},
{
@@ -140,6 +146,7 @@
title: '<span langtag="word-target"></span>',//标题
halign: 'center',
visible: true,//false表示不显示
sortable: true, //启用排序
formatter: function (value, row, index) {
return row.Target.TargetStr
}