mirror of
https://github.com/ehang-io/nps.git
synced 2025-08-31 17:56:56 +00:00
fix udp nil && add version display on web
This commit is contained in:
@@ -216,7 +216,7 @@ func (s *Sock5ModeServer) handleUDP(c net.Conn) {
|
||||
s.sendUdpReply(c, reply, succeeded, common.GetServerIpByClientIp(c.RemoteAddr().(*net.TCPAddr).IP))
|
||||
defer reply.Close()
|
||||
// new a tunnel to client
|
||||
link := conn.NewLink("udp", "", s.task.Client.Cnf.Crypt, s.task.Client.Cnf.Compress, c.RemoteAddr().String(), false)
|
||||
link := conn.NewLink("udp5", "", s.task.Client.Cnf.Crypt, s.task.Client.Cnf.Compress, c.RemoteAddr().String(), false)
|
||||
target, err := s.bridge.SendLinkInfo(s.task.Client.Id, link, s.task)
|
||||
if err != nil {
|
||||
logs.Warn("get connection from client id %d error %s", s.task.Client.Id, err.Error())
|
||||
|
@@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/cnlh/nps/lib/version"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
@@ -271,8 +272,9 @@ func GetClientList(start, length int, search, sort, order string, clientId int)
|
||||
func dealClientData() {
|
||||
file.GetDb().JsonDb.Clients.Range(func(key, value interface{}) bool {
|
||||
v := value.(*file.Client)
|
||||
if _, ok := Bridge.Client.Load(v.Id); ok {
|
||||
if vv, ok := Bridge.Client.Load(v.Id); ok {
|
||||
v.IsConnect = true
|
||||
v.Version = vv.(*bridge.Client).Version
|
||||
} else {
|
||||
v.IsConnect = false
|
||||
}
|
||||
@@ -338,6 +340,7 @@ func DelClientConnect(clientId int) {
|
||||
|
||||
func GetDashboardData() map[string]interface{} {
|
||||
data := make(map[string]interface{})
|
||||
data["version"] = version.VERSION
|
||||
data["hostCount"] = common.GeSynctMapLen(file.GetDb().JsonDb.Hosts)
|
||||
data["clientCount"] = common.GeSynctMapLen(file.GetDb().JsonDb.Clients) - 1 //Remove the public key client
|
||||
dealClientData()
|
||||
|
Reference in New Issue
Block a user