show client address in server dashboard

This commit is contained in:
Lang Tian 2024-03-20 16:37:10 +08:00
parent 002831ea82
commit 46bb91f679
7 changed files with 26 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<title>frps dashboard</title>
<script type="module" crossorigin src="./index-Q42Pu2_S.js"></script>
<script type="module" crossorigin src="./index-J-KX0R9O.js"></script>
<link rel="stylesheet" crossorigin href="./index-rzPDshRD.css">
</head>

View File

@ -480,6 +480,7 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy) (remoteAddr string, err
GetWorkConnFn: ctl.GetWorkConn,
Configurer: pxyConf,
ServerCfg: ctl.serverCfg,
ClientAddr: ctl.conn.RemoteAddr().String(),
})
if err != nil {
return remoteAddr, err

View File

@ -199,6 +199,7 @@ func getConfByType(proxyType string) any {
type ProxyStatsInfo struct {
Name string `json:"name"`
Conf interface{} `json:"conf"`
ClientAddr string `json:"clientAddr,omitempty"`
ClientVersion string `json:"clientVersion,omitempty"`
TodayTrafficIn int64 `json:"todayTrafficIn"`
TodayTrafficOut int64 `json:"todayTrafficOut"`
@ -257,6 +258,7 @@ func (svr *Service) getProxyStatsByType(proxyType string) (proxyInfos []*ProxySt
if pxy.GetLoginMsg() != nil {
proxyInfo.ClientVersion = pxy.GetLoginMsg().Version
}
proxyInfo.ClientAddr = pxy.GetClientAddr()
} else {
proxyInfo.Status = "offline"
}

View File

@ -57,6 +57,7 @@ type Proxy interface {
GetUserInfo() plugin.UserInfo
GetLimiter() *rate.Limiter
GetLoginMsg() *msg.Login
GetClientAddr() string
Close()
}
@ -72,6 +73,7 @@ type BaseProxy struct {
userInfo plugin.UserInfo
loginMsg *msg.Login
configurer v1.ProxyConfigurer
clientAddr string
mu sync.RWMutex
xl *xlog.Logger
@ -110,6 +112,10 @@ func (pxy *BaseProxy) GetConfigurer() v1.ProxyConfigurer {
return pxy.configurer
}
func (pxy *BaseProxy) GetClientAddr() string {
return pxy.clientAddr
}
func (pxy *BaseProxy) Close() {
xl := xlog.FromContextSafe(pxy.ctx)
xl.Infof("proxy closing")
@ -279,6 +285,7 @@ type Options struct {
GetWorkConnFn GetWorkConnFn
Configurer v1.ProxyConfigurer
ServerCfg *v1.ServerConfig
ClientAddr string
}
func NewProxy(ctx context.Context, options *Options) (pxy Proxy, err error) {
@ -304,6 +311,7 @@ func NewProxy(ctx context.Context, options *Options) (pxy Proxy, err error) {
userInfo: options.UserInfo,
loginMsg: options.LoginMsg,
configurer: configurer,
clientAddr: options.ClientAddr,
}
factory := proxyFactoryRegistry[reflect.TypeOf(configurer)]

View File

@ -51,6 +51,8 @@
sortable
>
</el-table-column>
<el-table-column label="ClientAddress" prop="clientAddress" sortable>
</el-table-column>
<el-table-column label="ClientVersion" prop="clientVersion" sortable>
</el-table-column>
<el-table-column label="Status" prop="status" sortable>

View File

@ -10,6 +10,7 @@ class BaseProxy {
lastStartTime: string
lastCloseTime: string
status: string
clientAddress: string
clientVersion: string
addr: string
port: number
@ -41,6 +42,7 @@ class BaseProxy {
this.lastStartTime = proxyStats.lastStartTime
this.lastCloseTime = proxyStats.lastCloseTime
this.status = proxyStats.status
this.clientAddress = proxyStats.clientAddr
this.clientVersion = proxyStats.clientVersion
this.addr = ''