mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 07:35:07 +00:00
web: support sudp in dashboard (#2385)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
<el-menu-item index="/proxies/http">HTTP</el-menu-item>
|
||||
<el-menu-item index="/proxies/https">HTTPS</el-menu-item>
|
||||
<el-menu-item index="/proxies/stcp">STCP</el-menu-item>
|
||||
<el-menu-item index="/proxies/sudp">SUDP</el-menu-item>
|
||||
</el-submenu>
|
||||
<el-menu-item index="">Help</el-menu-item>
|
||||
</el-menu>
|
||||
|
@@ -122,6 +122,9 @@
|
||||
if (json.proxy_type_count.stcp != null) {
|
||||
this.proxy_counts += json.proxy_type_count.stcp
|
||||
}
|
||||
if (json.proxy_type_count.sudp != null) {
|
||||
this.proxy_counts += json.proxy_type_count.sudp
|
||||
}
|
||||
if (json.proxy_type_count.xtcp != null) {
|
||||
this.proxy_counts += json.proxy_type_count.xtcp
|
||||
}
|
||||
|
116
web/frps/src/components/ProxiesSudp.vue
Normal file
116
web/frps/src/components/ProxiesSudp.vue
Normal file
@@ -0,0 +1,116 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-table :data="proxies" :default-sort="{prop: 'name', order: 'ascending'}" style="width: 100%">
|
||||
<el-table-column type="expand">
|
||||
<template slot-scope="props">
|
||||
<el-popover
|
||||
ref="popover4"
|
||||
placement="right"
|
||||
width="600"
|
||||
style="margin-left:0px"
|
||||
trigger="click">
|
||||
<my-traffic-chart :proxy_name="props.row.name"></my-traffic-chart>
|
||||
</el-popover>
|
||||
|
||||
<el-button v-popover:popover4 type="primary" size="small" icon="view" :name="props.row.name" style="margin-bottom:10px" @click="fetchData2">Traffic Statistics</el-button>
|
||||
|
||||
<el-form label-position="left" inline class="demo-table-expand">
|
||||
<el-form-item label="Name">
|
||||
<span>{{ props.row.name }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Type">
|
||||
<span>{{ props.row.type }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Encryption">
|
||||
<span>{{ props.row.encryption }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Compression">
|
||||
<span>{{ props.row.compression }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Last Start">
|
||||
<span>{{ props.row.last_start_time }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Last Close">
|
||||
<span>{{ props.row.last_close_time }}</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="Name"
|
||||
prop="name"
|
||||
sortable>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="Connections"
|
||||
prop="conns"
|
||||
sortable>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="Traffic In"
|
||||
prop="traffic_in"
|
||||
:formatter="formatTrafficIn"
|
||||
sortable>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="Traffic Out"
|
||||
prop="traffic_out"
|
||||
:formatter="formatTrafficOut"
|
||||
sortable>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="status"
|
||||
prop="status"
|
||||
sortable>
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="success" v-if="scope.row.status === 'online'">{{ scope.row.status }}</el-tag>
|
||||
<el-tag type="danger" v-else>{{ scope.row.status }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Humanize from 'humanize-plus'
|
||||
import Traffic from './Traffic.vue'
|
||||
import { SudpProxy } from '../utils/proxy.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
proxies: null
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
watch: {
|
||||
'$route': 'fetchData'
|
||||
},
|
||||
methods: {
|
||||
formatTrafficIn(row, column) {
|
||||
return Humanize.fileSize(row.traffic_in)
|
||||
},
|
||||
formatTrafficOut(row, column) {
|
||||
return Humanize.fileSize(row.traffic_out)
|
||||
},
|
||||
fetchData() {
|
||||
fetch('../api/proxy/sudp', {credentials: 'include'})
|
||||
.then(res => {
|
||||
return res.json()
|
||||
}).then(json => {
|
||||
this.proxies = new Array()
|
||||
for (let proxyStats of json.proxies) {
|
||||
this.proxies.push(new SudpProxy(proxyStats))
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
components: {
|
||||
'my-traffic-chart': Traffic
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
@@ -6,6 +6,7 @@ import ProxiesUdp from '../components/ProxiesUdp.vue'
|
||||
import ProxiesHttp from '../components/ProxiesHttp.vue'
|
||||
import ProxiesHttps from '../components/ProxiesHttps.vue'
|
||||
import ProxiesStcp from '../components/ProxiesStcp.vue'
|
||||
import ProxiesSudp from '../components/ProxiesSudp.vue'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
@@ -34,5 +35,9 @@ export default new Router({
|
||||
path: '/proxies/stcp',
|
||||
name: 'ProxiesStcp',
|
||||
component: ProxiesStcp
|
||||
}, {
|
||||
path: '/proxies/sudp',
|
||||
name: 'ProxiesSudp',
|
||||
component: ProxiesSudp
|
||||
}]
|
||||
})
|
||||
|
@@ -48,24 +48,6 @@ function DrawTrafficChart(elementId, trafficIn, trafficOut) {
|
||||
}
|
||||
|
||||
function DrawProxyChart(elementId, serverInfo) {
|
||||
if (serverInfo.proxy_type_count.tcp == null) {
|
||||
serverInfo.proxy_type_count.tcp = 0
|
||||
}
|
||||
if (serverInfo.proxy_type_count.udp == null) {
|
||||
serverInfo.proxy_type_count.udp = 0
|
||||
}
|
||||
if (serverInfo.proxy_type_count.http == null) {
|
||||
serverInfo.proxy_type_count.http = 0
|
||||
}
|
||||
if (serverInfo.proxy_type_count.https == null) {
|
||||
serverInfo.proxy_type_count.https = 0
|
||||
}
|
||||
if (serverInfo.proxy_type_count.stcp == null) {
|
||||
serverInfo.proxy_type_count.stcp = 0
|
||||
}
|
||||
if (serverInfo.proxy_type_count.xtcp == null) {
|
||||
serverInfo.proxy_type_count.xtcp = 0
|
||||
}
|
||||
let myChart = echarts.init(document.getElementById(elementId), 'macarons')
|
||||
myChart.showLoading()
|
||||
|
||||
@@ -85,25 +67,7 @@ function DrawProxyChart(elementId, serverInfo) {
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
center: ['50%', '60%'],
|
||||
data: [{
|
||||
value: serverInfo.proxy_type_count.tcp,
|
||||
name: 'TCP'
|
||||
}, {
|
||||
value: serverInfo.proxy_type_count.udp,
|
||||
name: 'UDP'
|
||||
}, {
|
||||
value: serverInfo.proxy_type_count.http,
|
||||
name: 'HTTP'
|
||||
}, {
|
||||
value: serverInfo.proxy_type_count.https,
|
||||
name: 'HTTPS'
|
||||
}, {
|
||||
value: serverInfo.proxy_type_count.stcp,
|
||||
name: 'STCP'
|
||||
}, {
|
||||
value: serverInfo.proxy_type_count.xtcp,
|
||||
name: 'XTCP'
|
||||
}],
|
||||
data: [],
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
shadowBlur: 10,
|
||||
@@ -113,6 +77,29 @@ function DrawProxyChart(elementId, serverInfo) {
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
if (serverInfo.proxy_type_count.tcp != null && serverInfo.proxy_type_count.tcp != 0) {
|
||||
option.series[0].data.push({value: serverInfo.proxy_type_count.tcp, name: 'TCP'})
|
||||
}
|
||||
if (serverInfo.proxy_type_count.udp != null && serverInfo.proxy_type_count.udp != 0) {
|
||||
option.series[0].data.push({value: serverInfo.proxy_type_count.udp, name: 'UDP'})
|
||||
}
|
||||
if (serverInfo.proxy_type_count.http != null && serverInfo.proxy_type_count.http != 0) {
|
||||
option.series[0].data.push({value: serverInfo.proxy_type_count.http, name: 'HTTP'})
|
||||
}
|
||||
if (serverInfo.proxy_type_count.https != null && serverInfo.proxy_type_count.https != 0) {
|
||||
option.series[0].data.push({value: serverInfo.proxy_type_count.https, name: 'HTTPS'})
|
||||
}
|
||||
if (serverInfo.proxy_type_count.stcp != null && serverInfo.proxy_type_count.stcp != 0) {
|
||||
option.series[0].data.push({value: serverInfo.proxy_type_count.stcp, name: 'STCP'})
|
||||
}
|
||||
if (serverInfo.proxy_type_count.sudp != null && serverInfo.proxy_type_count.sudp != 0) {
|
||||
option.series[0].data.push({value: serverInfo.proxy_type_count.sudp, name: 'SUDP'})
|
||||
}
|
||||
if (serverInfo.proxy_type_count.xtcp != null && serverInfo.proxy_type_count.xtcp != 0) {
|
||||
option.series[0].data.push({value: serverInfo.proxy_type_count.xtcp, name: 'XTCP'})
|
||||
}
|
||||
|
||||
myChart.setOption(option);
|
||||
myChart.hideLoading()
|
||||
}
|
||||
|
@@ -94,4 +94,11 @@ class StcpProxy extends BaseProxy {
|
||||
}
|
||||
}
|
||||
|
||||
export {BaseProxy, TcpProxy, UdpProxy, HttpProxy, HttpsProxy, StcpProxy}
|
||||
class SudpProxy extends BaseProxy {
|
||||
constructor(proxyStats) {
|
||||
super(proxyStats)
|
||||
this.type = "sudp"
|
||||
}
|
||||
}
|
||||
|
||||
export {BaseProxy, TcpProxy, UdpProxy, HttpProxy, HttpsProxy, StcpProxy, SudpProxy}
|
||||
|
Reference in New Issue
Block a user