mirror of https://github.com/fatedier/frp
add clientIP to the dashboard
parent
a23455a737
commit
b1d326ef16
|
@ -84,6 +84,8 @@ type Login struct {
|
||||||
RunID string `json:"run_id,omitempty"`
|
RunID string `json:"run_id,omitempty"`
|
||||||
Metas map[string]string `json:"metas,omitempty"`
|
Metas map[string]string `json:"metas,omitempty"`
|
||||||
|
|
||||||
|
// Filled out when connection established
|
||||||
|
ClientAddress string `json:"client_address,omitempty"`
|
||||||
// Currently only effective for VirtualClient.
|
// Currently only effective for VirtualClient.
|
||||||
ClientSpec ClientSpec `json:"client_spec,omitempty"`
|
ClientSpec ClientSpec `json:"client_spec,omitempty"`
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ func (m *Manager) Register(p Plugin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Login(content *LoginContent) (*LoginContent, error) {
|
func (m *Manager) Login(content *LoginContent) (*LoginContent, error) {
|
||||||
|
content.Login.ClientAddress = content.ClientAddress
|
||||||
if len(m.loginPlugins) == 0 {
|
if len(m.loginPlugins) == 0 {
|
||||||
return content, nil
|
return content, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@ package server
|
||||||
import (
|
import (
|
||||||
"cmp"
|
"cmp"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
|
||||||
"slices"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
"net/http"
|
||||||
|
"slices"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/fatedier/frp/pkg/config/types"
|
"github.com/fatedier/frp/pkg/config/types"
|
||||||
v1 "github.com/fatedier/frp/pkg/config/v1"
|
v1 "github.com/fatedier/frp/pkg/config/v1"
|
||||||
|
@ -199,6 +199,7 @@ type ProxyStatsInfo struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Conf any `json:"conf"`
|
Conf any `json:"conf"`
|
||||||
ClientVersion string `json:"clientVersion,omitempty"`
|
ClientVersion string `json:"clientVersion,omitempty"`
|
||||||
|
ClientIP string `json:"clientIP,omitempty"`
|
||||||
TodayTrafficIn int64 `json:"todayTrafficIn"`
|
TodayTrafficIn int64 `json:"todayTrafficIn"`
|
||||||
TodayTrafficOut int64 `json:"todayTrafficOut"`
|
TodayTrafficOut int64 `json:"todayTrafficOut"`
|
||||||
CurConns int64 `json:"curConns"`
|
CurConns int64 `json:"curConns"`
|
||||||
|
@ -255,6 +256,7 @@ func (svr *Service) getProxyStatsByType(proxyType string) (proxyInfos []*ProxySt
|
||||||
proxyInfo.Status = "online"
|
proxyInfo.Status = "online"
|
||||||
if pxy.GetLoginMsg() != nil {
|
if pxy.GetLoginMsg() != nil {
|
||||||
proxyInfo.ClientVersion = pxy.GetLoginMsg().Version
|
proxyInfo.ClientVersion = pxy.GetLoginMsg().Version
|
||||||
|
proxyInfo.ClientIP = strings.Split(pxy.GetLoginMsg().ClientAddress, ":")[0]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
proxyInfo.Status = "offline"
|
proxyInfo.Status = "offline"
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="Name" prop="name" sortable> </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="Port" prop="port" sortable> </el-table-column>
|
||||||
<el-table-column label="Connections" prop="conns" sortable>
|
<el-table-column label="Connections" prop="conns" sortable>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
|
@ -11,6 +11,7 @@ class BaseProxy {
|
||||||
lastCloseTime: string
|
lastCloseTime: string
|
||||||
status: string
|
status: string
|
||||||
clientVersion: string
|
clientVersion: string
|
||||||
|
clientIP: string
|
||||||
addr: string
|
addr: string
|
||||||
port: number
|
port: number
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ class BaseProxy {
|
||||||
this.lastCloseTime = proxyStats.lastCloseTime
|
this.lastCloseTime = proxyStats.lastCloseTime
|
||||||
this.status = proxyStats.status
|
this.status = proxyStats.status
|
||||||
this.clientVersion = proxyStats.clientVersion
|
this.clientVersion = proxyStats.clientVersion
|
||||||
|
this.clientIP = proxyStats.clientIP
|
||||||
|
|
||||||
this.addr = ''
|
this.addr = ''
|
||||||
this.port = 0
|
this.port = 0
|
||||||
|
|
Loading…
Reference in New Issue