add clientIP to the dashboard

pull/4763/head
kinAtrrA 2025-04-22 22:40:01 -07:00
parent a23455a737
commit b1d326ef16
5 changed files with 11 additions and 3 deletions

View File

@ -84,6 +84,8 @@ type Login struct {
RunID string `json:"run_id,omitempty"`
Metas map[string]string `json:"metas,omitempty"`
// Filled out when connection established
ClientAddress string `json:"client_address,omitempty"`
// Currently only effective for VirtualClient.
ClientSpec ClientSpec `json:"client_spec,omitempty"`

View File

@ -66,6 +66,7 @@ func (m *Manager) Register(p Plugin) {
}
func (m *Manager) Login(content *LoginContent) (*LoginContent, error) {
content.Login.ClientAddress = content.ClientAddress
if len(m.loginPlugins) == 0 {
return content, nil
}

View File

@ -17,11 +17,11 @@ package server
import (
"cmp"
"encoding/json"
"net/http"
"slices"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
"slices"
"strings"
"github.com/fatedier/frp/pkg/config/types"
v1 "github.com/fatedier/frp/pkg/config/v1"
@ -199,6 +199,7 @@ type ProxyStatsInfo struct {
Name string `json:"name"`
Conf any `json:"conf"`
ClientVersion string `json:"clientVersion,omitempty"`
ClientIP string `json:"clientIP,omitempty"`
TodayTrafficIn int64 `json:"todayTrafficIn"`
TodayTrafficOut int64 `json:"todayTrafficOut"`
CurConns int64 `json:"curConns"`
@ -255,6 +256,7 @@ func (svr *Service) getProxyStatsByType(proxyType string) (proxyInfos []*ProxySt
proxyInfo.Status = "online"
if pxy.GetLoginMsg() != nil {
proxyInfo.ClientVersion = pxy.GetLoginMsg().Version
proxyInfo.ClientIP = strings.Split(pxy.GetLoginMsg().ClientAddress, ":")[0]
}
} else {
proxyInfo.Status = "offline"

View File

@ -34,6 +34,7 @@
</template>
</el-table-column>
<el-table-column label="Name" prop="name" sortable> </el-table-column>
<el-table-column label="IP" prop="clientIP" sortable> </el-table-column>
<el-table-column label="Port" prop="port" sortable> </el-table-column>
<el-table-column label="Connections" prop="conns" sortable>
</el-table-column>

View File

@ -11,6 +11,7 @@ class BaseProxy {
lastCloseTime: string
status: string
clientVersion: string
clientIP: string
addr: string
port: number
@ -42,6 +43,7 @@ class BaseProxy {
this.lastCloseTime = proxyStats.lastCloseTime
this.status = proxyStats.status
this.clientVersion = proxyStats.clientVersion
this.clientIP = proxyStats.clientIP
this.addr = ''
this.port = 0