diff --git a/.github/workflows/pkg.yml b/.github/workflows/pkg.yml
index b0de22b8..2bf03daf 100644
--- a/.github/workflows/pkg.yml
+++ b/.github/workflows/pkg.yml
@@ -71,3 +71,51 @@ jobs:
npc_sdk.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+
+ build_docker:
+
+ runs-on: ubuntu-latest
+ steps:
+
+ - name: Check out code into the Go module directory
+ uses: actions/checkout@v2
+ - name: Set env
+ run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+ - name: Cache Docker layers
+ uses: actions/cache@v2
+ with:
+ path: /tmp/.buildx-cache
+ key: ${{ runner.os }}-buildx-${{ github.sha }}
+ restore-keys: |
+ ${{ runner.os }}-buildx-
+ - name: Login to DockerHub
+ uses: docker/login-action@v1
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ - name: Build and push nps
+ uses: docker/build-push-action@v2
+ with:
+ context: .
+ file: ./Dockerfile.nps
+ platforms: linux/amd64,linux/arm,linux/arm64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/nps:latest
+ ${{ secrets.DOCKERHUB_USERNAME }}/nps:${{ env.RELEASE_VERSION }}
+ - name: Build and push npc
+ uses: docker/build-push-action@v2
+ with:
+ context: .
+ file: ./Dockerfile.npc
+ platforms: linux/amd64,linux/arm,linux/arm64
+ push: true
+ tags: |
+ ${{ secrets.DOCKERHUB_USERNAME }}/npc:latest
+ ${{ secrets.DOCKERHUB_USERNAME }}/npc:${{ env.RELEASE_VERSION }}
+
diff --git a/conf/clients.json b/conf/clients.json
index e69de29b..8e1be7bd 100644
--- a/conf/clients.json
+++ b/conf/clients.json
@@ -0,0 +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":[""]}
+*#*
\ No newline at end of file
diff --git a/conf/hosts.json b/conf/hosts.json
index e69de29b..40282369 100644
--- a/conf/hosts.json
+++ b/conf/hosts.json
@@ -0,0 +1,2 @@
+{"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}}
+*#*
\ No newline at end of file
diff --git a/conf/nps.conf b/conf/nps.conf
index 6adad0ab..a36de140 100755
--- a/conf/nps.conf
+++ b/conf/nps.conf
@@ -92,4 +92,4 @@ http_add_origin_header=false
disconnect_timeout=60
#管理面板开启验证码校验
-open_captcha=true
\ No newline at end of file
+open_captcha=false
\ No newline at end of file
diff --git a/lib/file/file.go b/lib/file/file.go
index f8aafb60..22aada30 100644
--- a/lib/file/file.go
+++ b/lib/file/file.go
@@ -20,6 +20,7 @@ func NewJsonDb(runPath string) *JsonDb {
TaskFilePath: filepath.Join(runPath, "conf", "tasks.json"),
HostFilePath: filepath.Join(runPath, "conf", "hosts.json"),
ClientFilePath: filepath.Join(runPath, "conf", "clients.json"),
+ GlobalFilePath: filepath.Join(runPath, "conf", "global.json"),
}
}
@@ -28,6 +29,7 @@ type JsonDb struct {
Hosts sync.Map
HostsTmp sync.Map
Clients sync.Map
+ Global sync.Map
RunPath string
ClientIncreaseId int32 //client increased id
TaskIncreaseId int32 //task increased id
@@ -35,6 +37,7 @@ type JsonDb struct {
TaskFilePath string //task file path
HostFilePath string //host file path
ClientFilePath string //client file path
+ GlobalFilePath string //global file path
}
func (s *JsonDb) LoadTaskFromJsonFile() {
@@ -91,6 +94,16 @@ func (s *JsonDb) LoadHostFromJsonFile() {
})
}
+func (s *JsonDb) LoadGlobalFromJsonFile() {
+ loadSyncMapFromFile(s.GlobalFilePath, func(v string) {
+ post := new(Glob)
+ if json.Unmarshal([]byte(v), &post) != nil {
+ return
+ }
+ s.Global.Store("value", post)
+ })
+}
+
func (s *JsonDb) GetClient(id int) (c *Client, err error) {
if v, ok := s.Clients.Load(id); ok {
c = v.(*Client)
@@ -124,6 +137,14 @@ func (s *JsonDb) StoreClientsToJsonFile() {
clientLock.Unlock()
}
+var globalLock sync.Mutex
+
+func (s *JsonDb) StoreGlobalToJsonFile() {
+ globalLock.Lock()
+ storeSyncMapToFile(s.Global, s.GlobalFilePath)
+ globalLock.Unlock()
+}
+
func (s *JsonDb) GetClientId() int32 {
return atomic.AddInt32(&s.ClientIncreaseId, 1)
}
@@ -174,6 +195,9 @@ func storeSyncMapToFile(m sync.Map, filePath string) {
return true
}
b, err = json.Marshal(obj)
+ case *Glob:
+ obj := value.(*Glob)
+ b, err = json.Marshal(obj)
default:
return true
}
diff --git a/lib/file/obj.go b/lib/file/obj.go
index 71b5ed5b..aff9f77a 100644
--- a/lib/file/obj.go
+++ b/lib/file/obj.go
@@ -210,3 +210,8 @@ func (s *Target) GetRandomTarget() (string, error) {
s.nowIndex++
return s.TargetArr[s.nowIndex], nil
}
+
+type Glob struct {
+ BlackIpList []string
+ sync.RWMutex
+}
diff --git a/server/proxy/udp.go b/server/proxy/udp.go
index 268da385..0bf9eb97 100755
--- a/server/proxy/udp.go
+++ b/server/proxy/udp.go
@@ -94,7 +94,7 @@ func (s *UdpModeServer) process(addr *net.UDPAddr, data []byte) {
s.task.Client.Flow.Add(int64(len(data)), int64(len(data)))
for {
- clientConn.SetReadDeadline(time.Now().Add(time.Minute * 10))
+ clientConn.SetReadDeadline(time.Now().Add(time.Duration(60) * time.Second))
if n, err := target.Read(buf); err != nil {
s.addrMap.Delete(addr.String())
logs.Warn(err)
@@ -107,10 +107,10 @@ func (s *UdpModeServer) process(addr *net.UDPAddr, data []byte) {
}
s.task.Client.Flow.Add(int64(n), int64(n))
}
- if err := s.CheckFlowAndConnNum(s.task.Client); err != nil {
- logs.Warn("client id %d, task id %d,error %s, when udp connection", s.task.Client.Id, s.task.Id, err.Error())
- return
- }
+ //if err := s.CheckFlowAndConnNum(s.task.Client); err != nil {
+ // logs.Warn("client id %d, task id %d,error %s, when udp connection", s.task.Client.Id, s.task.Id, err.Error())
+ // return
+ //}
}
}
}
diff --git a/server/server.go b/server/server.go
index 2c53df45..357218e9 100644
--- a/server/server.go
+++ b/server/server.go
@@ -469,6 +469,7 @@ func flowSession(m time.Duration) {
file.GetDb().JsonDb.StoreHostToJsonFile()
file.GetDb().JsonDb.StoreTasksToJsonFile()
file.GetDb().JsonDb.StoreClientsToJsonFile()
+ file.GetDb().JsonDb.StoreGlobalToJsonFile()
}
}
}
diff --git a/web/static/page/languages.xml b/web/static/page/languages.xml
index e9c2be92..6fe57ae3 100644
--- a/web/static/page/languages.xml
+++ b/web/static/page/languages.xml
@@ -558,6 +558,12 @@