support show proxy config of frpc 0.53

This commit is contained in:
2023-12-27 10:58:45 +08:00
parent a37952a292
commit 91c15936ee
4 changed files with 158 additions and 90 deletions

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/fatedier/frp/pkg/config"
v1 "github.com/fatedier/frp/pkg/config/v1"
"github.com/pelletier/go-toml/v2"
"github.com/vaughan0/go-ini"
"io"
"log"
@@ -155,51 +154,11 @@ func (c *HandleController) parseConfigure(content, proxyType string) (interface{
}
allProxies := clientConfig.Proxies
var filterProxies = make([]MyProxy, 0)
var filterProxies = make([]v1.TypedProxyConfig, 0)
for i := range allProxies {
if equalIgnoreCase(allProxies[i].Type, proxyType) {
baseConfig := allProxies[i].GetBaseConfig()
marshal, _ := toml.Marshal(allProxies[i].ProxyConfigurer)
proxy := MyProxy{
string(marshal),
baseConfig,
}
filterProxies = append(filterProxies, proxy)
filterProxies = append(filterProxies, allProxies[i])
}
}
var ss = `
Name = 'ssh_random'
Type = 'tcp'
LocalIP = '192.168.31.100'
LocalPort = 22
RemotePort = 0
[Transport]
UseEncryption = false
UseCompression = false
BandwidthLimitMode = ''
ProxyProtocolVersion = ''
[Transport.BandwidthLimit]
[LoadBalancer]
Group = ''
GroupKey = ''
[HealthCheck]
Type = ''
TimeoutSeconds = 0
MaxFailed = 0
IntervalSeconds = 0
Path = ''
[Plugin]
Type = ''
`
v := v1.ProxyType("tcp")
r := v1.NewProxyConfigurerByType(v)
toml.Unmarshal([]byte(ss), r)
return filterProxies, nil
}