mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 07:35:07 +00:00
code optimization (#3625)
This commit is contained in:
@@ -90,12 +90,12 @@ func StatusHandler(clientCfg *v1.ClientCommonConfig) error {
|
||||
|
||||
fmt.Printf("Proxy Status...\n\n")
|
||||
for _, typ := range proxyTypes {
|
||||
arrs := res[typ]
|
||||
arrs := res[string(typ)]
|
||||
if len(arrs) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Println(strings.ToUpper(typ))
|
||||
fmt.Println(strings.ToUpper(string(typ)))
|
||||
tbl := table.New("Name", "Status", "LocalAddr", "Plugin", "RemoteAddr", "Error")
|
||||
for _, ps := range arrs {
|
||||
tbl.AddRow(ps.Name, ps.Status, ps.LocalAddr, ps.Plugin, ps.RemoteAddr, ps.Err)
|
||||
|
@@ -23,24 +23,23 @@ import (
|
||||
|
||||
v1 "github.com/fatedier/frp/pkg/config/v1"
|
||||
"github.com/fatedier/frp/pkg/config/v1/validation"
|
||||
"github.com/fatedier/frp/pkg/consts"
|
||||
)
|
||||
|
||||
var proxyTypes = []string{
|
||||
consts.TCPProxy,
|
||||
consts.UDPProxy,
|
||||
consts.TCPMuxProxy,
|
||||
consts.HTTPProxy,
|
||||
consts.HTTPSProxy,
|
||||
consts.STCPProxy,
|
||||
consts.SUDPProxy,
|
||||
consts.XTCPProxy,
|
||||
var proxyTypes = []v1.ProxyType{
|
||||
v1.ProxyTypeTCP,
|
||||
v1.ProxyTypeUDP,
|
||||
v1.ProxyTypeTCPMUX,
|
||||
v1.ProxyTypeHTTP,
|
||||
v1.ProxyTypeHTTPS,
|
||||
v1.ProxyTypeSTCP,
|
||||
v1.ProxyTypeSUDP,
|
||||
v1.ProxyTypeXTCP,
|
||||
}
|
||||
|
||||
var visitorTypes = []string{
|
||||
consts.STCPProxy,
|
||||
consts.SUDPProxy,
|
||||
consts.XTCPProxy,
|
||||
var visitorTypes = []v1.VisitorType{
|
||||
v1.VisitorTypeSTCP,
|
||||
v1.VisitorTypeSUDP,
|
||||
v1.VisitorTypeXTCP,
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -50,17 +49,17 @@ func init() {
|
||||
panic("proxy type: " + typ + " not support")
|
||||
}
|
||||
clientCfg := v1.ClientCommonConfig{}
|
||||
cmd := NewProxyCommand(typ, c, &clientCfg)
|
||||
cmd := NewProxyCommand(string(typ), c, &clientCfg)
|
||||
RegisterClientCommonConfigFlags(cmd, &clientCfg)
|
||||
RegisterProxyFlags(cmd, c)
|
||||
|
||||
// add sub command for visitor
|
||||
if lo.Contains(visitorTypes, typ) {
|
||||
vc := v1.NewVisitorConfigurerByType(typ)
|
||||
if lo.Contains(visitorTypes, v1.VisitorType(typ)) {
|
||||
vc := v1.NewVisitorConfigurerByType(v1.VisitorType(typ))
|
||||
if vc == nil {
|
||||
panic("visitor type: " + typ + " not support")
|
||||
}
|
||||
visitorCmd := NewVisitorCommand(typ, vc, &clientCfg)
|
||||
visitorCmd := NewVisitorCommand(string(typ), vc, &clientCfg)
|
||||
RegisterVisitorFlags(visitorCmd, vc)
|
||||
cmd.AddCommand(visitorCmd)
|
||||
}
|
||||
|
Reference in New Issue
Block a user