diff --git a/pkg/msg/msg.go b/pkg/msg/msg.go index d466f231..f53a667e 100644 --- a/pkg/msg/msg.go +++ b/pkg/msg/msg.go @@ -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"` diff --git a/pkg/plugin/server/manager.go b/pkg/plugin/server/manager.go index dabfb46c..6b4edee2 100644 --- a/pkg/plugin/server/manager.go +++ b/pkg/plugin/server/manager.go @@ -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 } diff --git a/server/dashboard_api.go b/server/dashboard_api.go index a29433a6..0dc85ef6 100644 --- a/server/dashboard_api.go +++ b/server/dashboard_api.go @@ -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" diff --git a/web/frps/src/components/ProxyView.vue b/web/frps/src/components/ProxyView.vue index 97a6e071..e70f27d4 100644 --- a/web/frps/src/components/ProxyView.vue +++ b/web/frps/src/components/ProxyView.vue @@ -34,6 +34,7 @@ + diff --git a/web/frps/src/utils/proxy.ts b/web/frps/src/utils/proxy.ts index 3baf9274..a1267d47 100644 --- a/web/frps/src/utils/proxy.ts +++ b/web/frps/src/utils/proxy.ts @@ -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