Skip to content

Commit

Permalink
Sorting plugins so that execution order is deterministic (fatedier#1961)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukacu authored Aug 31, 2020
1 parent b1181fd commit 268afb3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"math/big"
"net"
"net/http"
"sort"
"time"

"github.com/fatedier/frp/assets"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 268afb3

Please sign in to comment.