fix udp nil && add version display on web

This commit is contained in:
刘河
2019-12-04 01:28:26 +08:00
parent 5a85e47646
commit 08f7c1844a
10 changed files with 52 additions and 19 deletions

View File

@@ -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())

View File

@@ -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()