From 268afb3438d481dd521e5d5c0da62ef92b275ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20=C4=8Cehovin=20Zajc?= Date: Mon, 31 Aug 2020 13:49:46 +0200 Subject: [PATCH] Sorting plugins so that execution order is deterministic (#1961) --- server/service.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/service.go b/server/service.go index 5ae18bb..77a3967 100644 --- a/server/service.go +++ b/server/service.go @@ -27,6 +27,7 @@ import ( "math/big" "net" "net/http" + "sort" "time" "github.com/fatedier/frp/assets" @@ -133,8 +134,14 @@ func NewService(cfg config.ServerCommonConf) (svr *Service, err error) { } // Init all plugins - for name, options := range cfg.HTTPPlugins { - svr.pluginManager.Register(plugin.NewHTTPPluginOptions(options)) + plugin_names := make([]string, 0, len(cfg.HTTPPlugins)) + for n := range cfg.HTTPPlugins { + plugin_names = append(plugin_names, n) + } + sort.Strings(plugin_names) + + for _, name := range plugin_names { + svr.pluginManager.Register(plugin.NewHTTPPluginOptions(cfg.HTTPPlugins[name])) log.Info("plugin [%s] has been registered", name) } svr.rc.PluginManager = svr.pluginManager