mirror of
https://github.com/fatedier/frp.git
synced 2024-11-27 12:39:09 +08:00
web/frps: more info (#3326)
This commit is contained in:
parent
fe8374e99b
commit
2f59e967a0
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>frps dashboard</title>
|
||||
<script type="module" crossorigin src="./index-cd02d3b4.js"></script>
|
||||
<script type="module" crossorigin src="./index-2a8cf2f5.js"></script>
|
||||
<link rel="stylesheet" href="./index-4ce77078.css">
|
||||
</head>
|
||||
|
||||
|
@ -154,6 +154,8 @@ type ServerCommonConf struct {
|
||||
// If the length of this value is 0, all ports are allowed. By default,
|
||||
// this value is an empty set.
|
||||
AllowPorts map[int]struct{} `ini:"-" json:"-"`
|
||||
// Original string.
|
||||
AllowPortsStr string `ini:"-" json:"-"`
|
||||
// MaxPoolCount specifies the maximum pool size for each proxy. By default,
|
||||
// this value is 5.
|
||||
MaxPoolCount int64 `ini:"max_pool_count" json:"max_pool_count"`
|
||||
@ -259,6 +261,7 @@ func UnmarshalServerConfFromIni(source interface{}) (ServerCommonConf, error) {
|
||||
for _, port := range allowPorts {
|
||||
common.AllowPorts[int(port)] = struct{}{}
|
||||
}
|
||||
common.AllowPortsStr = allowPortStr
|
||||
}
|
||||
|
||||
// plugin.xxx
|
||||
|
@ -134,6 +134,7 @@ func Test_LoadServerCommonConf(t *testing.T) {
|
||||
12: {},
|
||||
99: {},
|
||||
},
|
||||
AllowPortsStr: "10-12,99",
|
||||
MaxPoolCount: 59,
|
||||
MaxPortsPerClient: 9,
|
||||
TLSOnly: true,
|
||||
|
@ -514,7 +514,7 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy) (remoteAddr string, err
|
||||
|
||||
// NewProxy will return a interface Proxy.
|
||||
// In fact it create different proxies by different proxy type, we just call run() here.
|
||||
pxy, err := proxy.NewProxy(ctl.ctx, userInfo, ctl.rc, ctl.poolCount, ctl.GetWorkConn, pxyConf, ctl.serverCfg)
|
||||
pxy, err := proxy.NewProxy(ctl.ctx, userInfo, ctl.rc, ctl.poolCount, ctl.GetWorkConn, pxyConf, ctl.serverCfg, ctl.loginMsg)
|
||||
if err != nil {
|
||||
return remoteAddr, err
|
||||
}
|
||||
|
@ -33,16 +33,20 @@ type GeneralResponse struct {
|
||||
}
|
||||
|
||||
type serverInfoResp struct {
|
||||
Version string `json:"version"`
|
||||
BindPort int `json:"bind_port"`
|
||||
BindUDPPort int `json:"bind_udp_port"`
|
||||
VhostHTTPPort int `json:"vhost_http_port"`
|
||||
VhostHTTPSPort int `json:"vhost_https_port"`
|
||||
KCPBindPort int `json:"kcp_bind_port"`
|
||||
SubdomainHost string `json:"subdomain_host"`
|
||||
MaxPoolCount int64 `json:"max_pool_count"`
|
||||
MaxPortsPerClient int64 `json:"max_ports_per_client"`
|
||||
HeartBeatTimeout int64 `json:"heart_beat_timeout"`
|
||||
Version string `json:"version"`
|
||||
BindPort int `json:"bind_port"`
|
||||
BindUDPPort int `json:"bind_udp_port"`
|
||||
VhostHTTPPort int `json:"vhost_http_port"`
|
||||
VhostHTTPSPort int `json:"vhost_https_port"`
|
||||
TCPMuxHTTPConnectPort int `json:"tcpmux_httpconnect_port"`
|
||||
KCPBindPort int `json:"kcp_bind_port"`
|
||||
QUICBindPort int `json:"quic_bind_port"`
|
||||
SubdomainHost string `json:"subdomain_host"`
|
||||
MaxPoolCount int64 `json:"max_pool_count"`
|
||||
MaxPortsPerClient int64 `json:"max_ports_per_client"`
|
||||
HeartBeatTimeout int64 `json:"heart_beat_timeout"`
|
||||
AllowPortsStr string `json:"allow_ports_str,omitempty"`
|
||||
TLSOnly bool `json:"tls_only,omitempty"`
|
||||
|
||||
TotalTrafficIn int64 `json:"total_traffic_in"`
|
||||
TotalTrafficOut int64 `json:"total_traffic_out"`
|
||||
@ -70,16 +74,20 @@ func (svr *Service) APIServerInfo(w http.ResponseWriter, r *http.Request) {
|
||||
log.Info("Http request: [%s]", r.URL.Path)
|
||||
serverStats := mem.StatsCollector.GetServer()
|
||||
svrResp := serverInfoResp{
|
||||
Version: version.Full(),
|
||||
BindPort: svr.cfg.BindPort,
|
||||
BindUDPPort: svr.cfg.BindUDPPort,
|
||||
VhostHTTPPort: svr.cfg.VhostHTTPPort,
|
||||
VhostHTTPSPort: svr.cfg.VhostHTTPSPort,
|
||||
KCPBindPort: svr.cfg.KCPBindPort,
|
||||
SubdomainHost: svr.cfg.SubDomainHost,
|
||||
MaxPoolCount: svr.cfg.MaxPoolCount,
|
||||
MaxPortsPerClient: svr.cfg.MaxPortsPerClient,
|
||||
HeartBeatTimeout: svr.cfg.HeartbeatTimeout,
|
||||
Version: version.Full(),
|
||||
BindPort: svr.cfg.BindPort,
|
||||
BindUDPPort: svr.cfg.BindUDPPort,
|
||||
VhostHTTPPort: svr.cfg.VhostHTTPPort,
|
||||
VhostHTTPSPort: svr.cfg.VhostHTTPSPort,
|
||||
TCPMuxHTTPConnectPort: svr.cfg.TCPMuxHTTPConnectPort,
|
||||
KCPBindPort: svr.cfg.KCPBindPort,
|
||||
QUICBindPort: svr.cfg.QUICBindPort,
|
||||
SubdomainHost: svr.cfg.SubDomainHost,
|
||||
MaxPoolCount: svr.cfg.MaxPoolCount,
|
||||
MaxPortsPerClient: svr.cfg.MaxPortsPerClient,
|
||||
HeartBeatTimeout: svr.cfg.HeartbeatTimeout,
|
||||
AllowPortsStr: svr.cfg.AllowPortsStr,
|
||||
TLSOnly: svr.cfg.TLSOnly,
|
||||
|
||||
TotalTrafficIn: serverStats.TotalTrafficIn,
|
||||
TotalTrafficOut: serverStats.TotalTrafficOut,
|
||||
@ -157,6 +165,7 @@ func getConfByType(proxyType string) interface{} {
|
||||
type ProxyStatsInfo struct {
|
||||
Name string `json:"name"`
|
||||
Conf interface{} `json:"conf"`
|
||||
ClientVersion string `json:"client_version,omitempty"`
|
||||
TodayTrafficIn int64 `json:"today_traffic_in"`
|
||||
TodayTrafficOut int64 `json:"today_traffic_out"`
|
||||
CurConns int64 `json:"cur_conns"`
|
||||
@ -208,6 +217,9 @@ func (svr *Service) getProxyStatsByType(proxyType string) (proxyInfos []*ProxySt
|
||||
continue
|
||||
}
|
||||
proxyInfo.Status = consts.Online
|
||||
if pxy.GetLoginMsg() != nil {
|
||||
proxyInfo.ClientVersion = pxy.GetLoginMsg().Version
|
||||
}
|
||||
} else {
|
||||
proxyInfo.Status = consts.Offline
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ type Proxy interface {
|
||||
GetResourceController() *controller.ResourceController
|
||||
GetUserInfo() plugin.UserInfo
|
||||
GetLimiter() *rate.Limiter
|
||||
GetLoginMsg() *msg.Login
|
||||
Close()
|
||||
}
|
||||
|
||||
@ -61,6 +62,7 @@ type BaseProxy struct {
|
||||
serverCfg config.ServerCommonConf
|
||||
limiter *rate.Limiter
|
||||
userInfo plugin.UserInfo
|
||||
loginMsg *msg.Login
|
||||
|
||||
mu sync.RWMutex
|
||||
xl *xlog.Logger
|
||||
@ -87,6 +89,10 @@ func (pxy *BaseProxy) GetUserInfo() plugin.UserInfo {
|
||||
return pxy.userInfo
|
||||
}
|
||||
|
||||
func (pxy *BaseProxy) GetLoginMsg() *msg.Login {
|
||||
return pxy.loginMsg
|
||||
}
|
||||
|
||||
func (pxy *BaseProxy) Close() {
|
||||
xl := xlog.FromContextSafe(pxy.ctx)
|
||||
xl.Info("proxy closing")
|
||||
@ -188,7 +194,7 @@ func (pxy *BaseProxy) startListenHandler(p Proxy, handler func(Proxy, net.Conn,
|
||||
}
|
||||
|
||||
func NewProxy(ctx context.Context, userInfo plugin.UserInfo, rc *controller.ResourceController, poolCount int,
|
||||
getWorkConnFn GetWorkConnFn, pxyConf config.ProxyConf, serverCfg config.ServerCommonConf,
|
||||
getWorkConnFn GetWorkConnFn, pxyConf config.ProxyConf, serverCfg config.ServerCommonConf, loginMsg *msg.Login,
|
||||
) (pxy Proxy, err error) {
|
||||
xl := xlog.FromContextSafe(ctx).Spawn().AppendPrefix(pxyConf.GetBaseInfo().ProxyName)
|
||||
|
||||
@ -209,6 +215,7 @@ func NewProxy(ctx context.Context, userInfo plugin.UserInfo, rc *controller.Reso
|
||||
xl: xl,
|
||||
ctx: xlog.NewContext(ctx, xl),
|
||||
userInfo: userInfo,
|
||||
loginMsg: loginMsg,
|
||||
}
|
||||
switch cfg := pxyConf.(type) {
|
||||
case *config.TCPProxyConf:
|
||||
|
2
web/frps/components.d.ts
vendored
2
web/frps/components.d.ts
vendored
@ -19,6 +19,8 @@ declare module '@vue/runtime-core' {
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||
ElTag: typeof import('element-plus/es')['ElTag']
|
||||
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||
LongSpan: typeof import('./src/components/LongSpan.vue')['default']
|
||||
ProxiesHTTP: typeof import('./src/components/ProxiesHTTP.vue')['default']
|
||||
ProxiesHTTPS: typeof import('./src/components/ProxiesHTTPS.vue')['default']
|
||||
ProxiesSTCP: typeof import('./src/components/ProxiesSTCP.vue')['default']
|
||||
|
15
web/frps/src/components/LongSpan.vue
Normal file
15
web/frps/src/components/LongSpan.vue
Normal file
@ -0,0 +1,15 @@
|
||||
<template>
|
||||
<el-tooltip :content="content" placement="top">
|
||||
<span v-show="content.length > length"
|
||||
>{{ content.slice(0, length) }}...</span
|
||||
>
|
||||
</el-tooltip>
|
||||
<span v-show="content.length < 30">{{ content }}</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
content: string
|
||||
length: number
|
||||
}>()
|
||||
</script>
|
@ -50,7 +50,9 @@
|
||||
sortable
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column label="status" prop="status" sortable>
|
||||
<el-table-column label="ClientVersion" prop="client_version" sortable>
|
||||
</el-table-column>
|
||||
<el-table-column label="Status" prop="status" sortable>
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.status === 'online'" type="success">{{
|
||||
scope.row.status
|
||||
|
@ -5,7 +5,7 @@
|
||||
<div class="source">
|
||||
<el-form
|
||||
label-position="left"
|
||||
label-width="160px"
|
||||
label-width="220px"
|
||||
class="server_info"
|
||||
>
|
||||
<el-form-item label="Version">
|
||||
@ -14,17 +14,35 @@
|
||||
<el-form-item label="BindPort">
|
||||
<span>{{ data.bind_port }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="BindUdpPort">
|
||||
<el-form-item label="Bind UDP Port" v-if="data.bind_udp_port != 0">
|
||||
<span>{{ data.bind_udp_port }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Http Port">
|
||||
<el-form-item label="KCP Bind Port" v-if="data.kcp_bind_port != 0">
|
||||
<span>{{ data.kcp_bind_port }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="QUIC Bind Port"
|
||||
v-if="data.quic_bind_port != 0"
|
||||
>
|
||||
<span>{{ data.quic_bind_port }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Http Port" v-if="data.vhost_http_port != 0">
|
||||
<span>{{ data.vhost_http_port }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Https Port">
|
||||
<el-form-item label="Https Port" v-if="data.vhost_https_port != 0">
|
||||
<span>{{ data.vhost_https_port }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Subdomain Host">
|
||||
<span>{{ data.subdomain_host }}</span>
|
||||
<el-form-item
|
||||
label="TCPMux HTTPConnect Port"
|
||||
v-if="data.tcpmux_httpconnect_port != 0"
|
||||
>
|
||||
<span>{{ data.tcpmux_httpconnect_port }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="Subdomain Host"
|
||||
v-if="data.subdomain_host != ''"
|
||||
>
|
||||
<LongSpan :content="data.subdomain_host" :length="30"></LongSpan>
|
||||
</el-form-item>
|
||||
<el-form-item label="Max PoolCount">
|
||||
<span>{{ data.max_pool_count }}</span>
|
||||
@ -32,6 +50,12 @@
|
||||
<el-form-item label="Max Ports Per Client">
|
||||
<span>{{ data.max_ports_per_client }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Allow Ports" v-if="data.allow_ports_str != ''">
|
||||
<LongSpan :content="data.allow_ports_str" :length="30"></LongSpan>
|
||||
</el-form-item>
|
||||
<el-form-item label="TLS Only" v-if="data.tls_only === true">
|
||||
<span>{{ data.tls_only }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="HeartBeat Timeout">
|
||||
<span>{{ data.heart_beat_timeout }}</span>
|
||||
</el-form-item>
|
||||
@ -62,19 +86,25 @@
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { DrawTrafficChart, DrawProxyChart } from '../utils/chart'
|
||||
import LongSpan from './LongSpan.vue'
|
||||
|
||||
let data = ref({
|
||||
version: '',
|
||||
bind_port: '',
|
||||
bind_udp_port: '',
|
||||
vhost_http_port: '',
|
||||
vhost_https_port: '',
|
||||
bind_port: 0,
|
||||
bind_udp_port: 0,
|
||||
kcp_bind_port: 0,
|
||||
quic_bind_port: 0,
|
||||
vhost_http_port: 0,
|
||||
vhost_https_port: 0,
|
||||
tcpmux_httpconnect_port: 0,
|
||||
subdomain_host: '',
|
||||
max_pool_count: '',
|
||||
max_pool_count: 0,
|
||||
max_ports_per_client: '',
|
||||
heart_beat_timeout: '',
|
||||
client_counts: '',
|
||||
cur_conns: '',
|
||||
allow_ports_str: '',
|
||||
tls_only: false,
|
||||
heart_beat_timeout: 0,
|
||||
client_counts: 0,
|
||||
cur_conns: 0,
|
||||
proxy_counts: 0,
|
||||
})
|
||||
|
||||
@ -85,23 +115,19 @@ const fetchData = () => {
|
||||
data.value.version = json.version
|
||||
data.value.bind_port = json.bind_port
|
||||
data.value.bind_udp_port = json.bind_udp_port
|
||||
if (data.value.bind_udp_port == '0') {
|
||||
data.value.bind_udp_port = 'disable'
|
||||
}
|
||||
data.value.kcp_bind_port = json.kcp_bind_port
|
||||
data.value.quic_bind_port = json.quic_bind_port
|
||||
data.value.vhost_http_port = json.vhost_http_port
|
||||
if (data.value.vhost_http_port == '0') {
|
||||
data.value.vhost_http_port = 'disable'
|
||||
}
|
||||
data.value.vhost_https_port = json.vhost_https_port
|
||||
if (data.value.vhost_https_port == '0') {
|
||||
data.value.vhost_https_port = 'disable'
|
||||
}
|
||||
data.value.tcpmux_httpconnect_port = json.tcpmux_httpconnect_port
|
||||
data.value.subdomain_host = json.subdomain_host
|
||||
data.value.max_pool_count = json.max_pool_count
|
||||
data.value.max_ports_per_client = json.max_ports_per_client
|
||||
if (data.value.max_ports_per_client == '0') {
|
||||
data.value.max_ports_per_client = 'no limit'
|
||||
}
|
||||
data.value.allow_ports_str = json.allow_ports_str
|
||||
data.value.tls_only = json.tls_only
|
||||
data.value.heart_beat_timeout = json.heart_beat_timeout
|
||||
data.value.client_counts = json.client_counts
|
||||
data.value.cur_conns = json.cur_conns
|
||||
|
@ -9,6 +9,7 @@ class BaseProxy {
|
||||
last_start_time: string
|
||||
last_close_time: string
|
||||
status: string
|
||||
client_version: string
|
||||
addr: string
|
||||
port: number
|
||||
|
||||
@ -33,6 +34,7 @@ class BaseProxy {
|
||||
this.last_start_time = proxyStats.last_start_time
|
||||
this.last_close_time = proxyStats.last_close_time
|
||||
this.status = proxyStats.status
|
||||
this.client_version = proxyStats.client_version
|
||||
|
||||
this.addr = ''
|
||||
this.port = 0
|
||||
|
Loading…
Reference in New Issue
Block a user