Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show client address in server dashboard #4087

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/frps/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
1 change: 1 addition & 0 deletions server/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions server/dashboard_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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"
}
Expand Down
8 changes: 8 additions & 0 deletions server/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Proxy interface {
GetUserInfo() plugin.UserInfo
GetLimiter() *rate.Limiter
GetLoginMsg() *msg.Login
GetClientAddr() string
Close()
}

Expand All @@ -72,6 +73,7 @@ type BaseProxy struct {
userInfo plugin.UserInfo
loginMsg *msg.Login
configurer v1.ProxyConfigurer
clientAddr string

mu sync.RWMutex
xl *xlog.Logger
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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) {
Expand All @@ -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)]
Expand Down
2 changes: 2 additions & 0 deletions web/frps/src/components/ProxyView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions web/frps/src/utils/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class BaseProxy {
lastStartTime: string
lastCloseTime: string
status: string
clientAddress: string
clientVersion: string
addr: string
port: number
Expand Down Expand Up @@ -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 = ''
Expand Down