修复问题

This commit is contained in:
bjdgyc 2024-10-22 14:14:10 +08:00
parent 1c5b269aa3
commit c0c15815f9
4 changed files with 49 additions and 32 deletions

View File

@ -2,9 +2,11 @@ package base
import ( import (
"fmt" "fmt"
"github.com/bjdgyc/anylink/pkg/utils"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"strings"
) )
const ( const (
@ -123,6 +125,11 @@ func initServerCfg() {
if Cfg.JwtSecret == defaultJwt { if Cfg.JwtSecret == defaultJwt {
fmt.Fprintln(os.Stderr, "=== 使用默认的jwt_secret有安全风险请设置新的jwt_secret ===") fmt.Fprintln(os.Stderr, "=== 使用默认的jwt_secret有安全风险请设置新的jwt_secret ===")
// 安全问题,自动生成新的密钥
jwtSecret, _ := utils.RandSecret(40, 60)
jwtSecret = strings.Trim(jwtSecret, "=")
Cfg.JwtSecret = jwtSecret
} }
fmt.Printf("ServerCfg: %+v \n", Cfg) fmt.Printf("ServerCfg: %+v \n", Cfg)

View File

@ -11,21 +11,22 @@ import (
) )
type Online struct { type Online struct {
Token string `json:"token"` Token string `json:"token"`
Username string `json:"username"` Username string `json:"username"`
Group string `json:"group"` Group string `json:"group"`
MacAddr string `json:"mac_addr"` MacAddr string `json:"mac_addr"`
UniqueMac bool `json:"unique_mac"` UniqueMac bool `json:"unique_mac"`
Ip net.IP `json:"ip"` Ip net.IP `json:"ip"`
RemoteAddr string `json:"remote_addr"` RemoteAddr string `json:"remote_addr"`
TunName string `json:"tun_name"` TransportProtocol string `json:"transport_protocol"`
Mtu int `json:"mtu"` TunName string `json:"tun_name"`
Client string `json:"client"` Mtu int `json:"mtu"`
BandwidthUp string `json:"bandwidth_up"` Client string `json:"client"`
BandwidthDown string `json:"bandwidth_down"` BandwidthUp string `json:"bandwidth_up"`
BandwidthUpAll string `json:"bandwidth_up_all"` BandwidthDown string `json:"bandwidth_down"`
BandwidthDownAll string `json:"bandwidth_down_all"` BandwidthUpAll string `json:"bandwidth_up_all"`
LastLogin time.Time `json:"last_login"` BandwidthDownAll string `json:"bandwidth_down_all"`
LastLogin time.Time `json:"last_login"`
} }
type Onlines []Online type Onlines []Online
@ -90,22 +91,28 @@ func GetOnlineSess(search_cate string, search_text string, show_sleeper bool) []
} }
if show_sleeper || v.IsActive { if show_sleeper || v.IsActive {
transportProtocol := "TCP"
dSess := cSess.GetDtlsSession()
if dSess != nil {
transportProtocol = "UDP"
}
val := Online{ val := Online{
Token: v.Token, Token: v.Token,
Ip: cSess.IpAddr, Ip: cSess.IpAddr,
Username: v.Username, Username: v.Username,
Group: v.Group, Group: v.Group,
MacAddr: v.MacAddr, MacAddr: v.MacAddr,
UniqueMac: v.UniqueMac, UniqueMac: v.UniqueMac,
RemoteAddr: cSess.RemoteAddr, RemoteAddr: cSess.RemoteAddr,
TunName: cSess.IfName, TransportProtocol: transportProtocol,
Mtu: cSess.Mtu, TunName: cSess.IfName,
Client: cSess.Client, Mtu: cSess.Mtu,
BandwidthUp: utils.HumanByte(cSess.BandwidthUpPeriod.Load()) + "/s", Client: cSess.Client,
BandwidthDown: utils.HumanByte(cSess.BandwidthDownPeriod.Load()) + "/s", BandwidthUp: utils.HumanByte(cSess.BandwidthUpPeriod.Load()) + "/s",
BandwidthUpAll: utils.HumanByte(cSess.BandwidthUpAll.Load()), BandwidthDown: utils.HumanByte(cSess.BandwidthDownPeriod.Load()) + "/s",
BandwidthDownAll: utils.HumanByte(cSess.BandwidthDownAll.Load()), BandwidthUpAll: utils.HumanByte(cSess.BandwidthUpAll.Load()),
LastLogin: v.LastLogin, BandwidthDownAll: utils.HumanByte(cSess.BandwidthDownAll.Load()),
LastLogin: v.LastLogin,
} }
datas = append(datas, val) datas = append(datas, val)
} }

View File

@ -1 +1 @@
0.12.2 0.12.3

View File

@ -99,7 +99,10 @@
prop="remote_addr" prop="remote_addr"
label="远端地址"> label="远端地址">
</el-table-column> </el-table-column>
<el-table-column
prop="transport_protocol"
label="传输协议">
</el-table-column>
<el-table-column <el-table-column
prop="tun_name" prop="tun_name"
label="虚拟网卡"> label="虚拟网卡">