mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 06:17:00 +08:00
serialize config sections to string;
add and update with different url
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/fatedier/frp/pkg/config"
|
||||
"github.com/vaughan0/go-ini"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -21,6 +23,33 @@ func stringContains(element string, data []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *HandleController) reloadFrpc() error {
|
||||
return nil
|
||||
func (c *HandleController) parseConfigure(content, proxyType string) (interface{}, error) {
|
||||
currentProxies := make(map[string]ini.Section)
|
||||
clientProxies = make(map[string]ini.Section)
|
||||
common, err := config.UnmarshalClientConfFromIni(content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg, err := ini.Load(strings.NewReader(content))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for name, section := range cfg {
|
||||
if name == "common" {
|
||||
clientCommon = section
|
||||
continue
|
||||
}
|
||||
if strings.ToLower(section["type"]) == strings.ToLower(proxyType) {
|
||||
currentProxies[name] = section
|
||||
}
|
||||
clientProxies[name] = section
|
||||
delete(clientProxies[name], "name")
|
||||
}
|
||||
|
||||
if proxyType == "none" {
|
||||
return common, nil
|
||||
}
|
||||
|
||||
return currentProxies, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user