Skip to content

Commit

Permalink
Added disablePlugins function
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-morlier committed Oct 11, 2024
1 parent 211e35b commit 87dd70a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ func NewServer(config *Config, opts ...serverOption) (*Server, error) {
}

//begin xplugeth injection
xplugeth.Initialize(pluginsConfig())
if !disablePlugins() {
xplugeth.Initialize(pluginsConfig())
}
//end xplugeth injection

// load the chain genesis
Expand Down
16 changes: 15 additions & 1 deletion internal/cli/server/xplugeth_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"os"
"path/filepath"
"strings"

"github.com/openrelayxyz/xplugeth"
"github.com/openrelayxyz/xplugeth/types"
Expand All @@ -24,6 +25,19 @@ func isValidPath(path string) bool {
return fileInfo.IsDir()
}

func disablePlugins() bool {
val := os.Getenv("DISABLE_PLUGINS")
if len(val) > 0 {
truthyValues := []string{"true", "1", "yes", "y"}
for _, truthy := range truthyValues {
if strings.EqualFold(val, truthy) {
return true
}
}
}
return false
}


func pluginsConfig() string {
pluginsConfigEnv := os.Getenv("PLUGINS_CONFIG")
Expand All @@ -32,7 +46,7 @@ func pluginsConfig() string {
log.Info("plugins config path provided", "path", pluginsConfigEnv)
return pluginsConfigEnv
}

log.Info("plugins config path not provided or invalid")
return ""
}
Expand Down

0 comments on commit 87dd70a

Please sign in to comment.