mirror of
				https://github.com/fatedier/frp.git
				synced 2025-10-31 21:02:33 +08:00 
			
		
		
		
	support yaml/json/toml configuration format, make ini deprecated (#3599)
This commit is contained in:
		| @@ -21,8 +21,10 @@ import ( | ||||
| 	"reflect" | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/samber/lo" | ||||
|  | ||||
| 	"github.com/fatedier/frp/client/event" | ||||
| 	"github.com/fatedier/frp/pkg/config" | ||||
| 	v1 "github.com/fatedier/frp/pkg/config/v1" | ||||
| 	"github.com/fatedier/frp/pkg/msg" | ||||
| 	"github.com/fatedier/frp/pkg/transport" | ||||
| 	"github.com/fatedier/frp/pkg/util/xlog" | ||||
| @@ -35,14 +37,14 @@ type Manager struct { | ||||
| 	closed bool | ||||
| 	mu     sync.RWMutex | ||||
|  | ||||
| 	clientCfg config.ClientCommonConf | ||||
| 	clientCfg *v1.ClientCommonConfig | ||||
|  | ||||
| 	ctx context.Context | ||||
| } | ||||
|  | ||||
| func NewManager( | ||||
| 	ctx context.Context, | ||||
| 	clientCfg config.ClientCommonConf, | ||||
| 	clientCfg *v1.ClientCommonConfig, | ||||
| 	msgTransporter transport.MessageTransporter, | ||||
| ) *Manager { | ||||
| 	return &Manager{ | ||||
| @@ -113,15 +115,18 @@ func (pm *Manager) GetAllProxyStatus() []*WorkingStatus { | ||||
| 	return ps | ||||
| } | ||||
|  | ||||
| func (pm *Manager) Reload(pxyCfgs map[string]config.ProxyConf) { | ||||
| func (pm *Manager) Reload(pxyCfgs []v1.ProxyConfigurer) { | ||||
| 	xl := xlog.FromContextSafe(pm.ctx) | ||||
| 	pxyCfgsMap := lo.KeyBy(pxyCfgs, func(c v1.ProxyConfigurer) string { | ||||
| 		return c.GetBaseConfig().Name | ||||
| 	}) | ||||
| 	pm.mu.Lock() | ||||
| 	defer pm.mu.Unlock() | ||||
|  | ||||
| 	delPxyNames := make([]string, 0) | ||||
| 	for name, pxy := range pm.proxies { | ||||
| 		del := false | ||||
| 		cfg, ok := pxyCfgs[name] | ||||
| 		cfg, ok := pxyCfgsMap[name] | ||||
| 		if !ok || !reflect.DeepEqual(pxy.Cfg, cfg) { | ||||
| 			del = true | ||||
| 		} | ||||
| @@ -137,7 +142,8 @@ func (pm *Manager) Reload(pxyCfgs map[string]config.ProxyConf) { | ||||
| 	} | ||||
|  | ||||
| 	addPxyNames := make([]string, 0) | ||||
| 	for name, cfg := range pxyCfgs { | ||||
| 	for _, cfg := range pxyCfgs { | ||||
| 		name := cfg.GetBaseConfig().Name | ||||
| 		if _, ok := pm.proxies[name]; !ok { | ||||
| 			pxy := NewWrapper(pm.ctx, cfg, pm.clientCfg, pm.HandleEvent, pm.msgTransporter) | ||||
| 			pm.proxies[name] = pxy | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 fatedier
					fatedier