mirror of
https://github.com/gravitl/netmaker.git
synced 2025-02-27 17:42:57 +08:00
Merge pull request #576 from gravitl/feature_v0.9.3_optional_rce
Feature v0.9.3 optional rce
This commit is contained in:
commit
edc0488de5
6 changed files with 33 additions and 4 deletions
|
@ -69,6 +69,7 @@ type ServerConfig struct {
|
||||||
FrontendURL string `yaml:"frontendurl"`
|
FrontendURL string `yaml:"frontendurl"`
|
||||||
DisplayKeys string `yaml:"displaykeys"`
|
DisplayKeys string `yaml:"displaykeys"`
|
||||||
AzureTenant string `yaml:"azuretenant"`
|
AzureTenant string `yaml:"azuretenant"`
|
||||||
|
RCE string `yaml:"rce"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SQLConfig - Generic SQL Config
|
// SQLConfig - Generic SQL Config
|
||||||
|
|
|
@ -68,7 +68,7 @@ func getNetworks(w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(allnetworks)
|
json.NewEncoder(w).Encode(allnetworks)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Simple get network function
|
// Simple get network function
|
||||||
func getNetwork(w http.ResponseWriter, r *http.Request) {
|
func getNetwork(w http.ResponseWriter, r *http.Request) {
|
||||||
// set header.
|
// set header.
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
@ -101,7 +101,7 @@ func keyUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(network)
|
json.NewEncoder(w).Encode(network)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update a network
|
// Update a network
|
||||||
func updateNetwork(w http.ResponseWriter, r *http.Request) {
|
func updateNetwork(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
var params = mux.Vars(r)
|
var params = mux.Vars(r)
|
||||||
|
@ -119,6 +119,11 @@ func updateNetwork(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !servercfg.GetRce() {
|
||||||
|
newNetwork.DefaultPostDown = network.DefaultPostDown
|
||||||
|
newNetwork.DefaultPostUp = network.DefaultPostUp
|
||||||
|
}
|
||||||
|
|
||||||
rangeupdate, localrangeupdate, err := logic.UpdateNetwork(&network, &newNetwork)
|
rangeupdate, localrangeupdate, err := logic.UpdateNetwork(&network, &newNetwork)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnErrorResponse(w, r, formatError(err, "badrequest"))
|
returnErrorResponse(w, r, formatError(err, "badrequest"))
|
||||||
|
|
|
@ -524,6 +524,12 @@ func updateNode(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !servercfg.GetRce() {
|
||||||
|
newNode.PostDown = node.PostDown
|
||||||
|
newNode.PostUp = node.PostUp
|
||||||
|
}
|
||||||
|
|
||||||
err = logic.UpdateNode(&node, &newNode)
|
err = logic.UpdateNode(&node, &newNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnErrorResponse(w, r, formatError(err, "internal"))
|
returnErrorResponse(w, r, formatError(err, "internal"))
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/gravitl/netmaker/logger"
|
"github.com/gravitl/netmaker/logger"
|
||||||
"github.com/gravitl/netmaker/logic"
|
"github.com/gravitl/netmaker/logic"
|
||||||
"github.com/gravitl/netmaker/models"
|
"github.com/gravitl/netmaker/models"
|
||||||
|
"github.com/gravitl/netmaker/servercfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeServiceServer - represents the service server for gRPC
|
// NodeServiceServer - represents the service server for gRPC
|
||||||
|
@ -107,6 +108,12 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.Object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !servercfg.GetRce() {
|
||||||
|
newnode.PostDown = node.PostDown
|
||||||
|
newnode.PostUp = node.PostUp
|
||||||
|
}
|
||||||
|
|
||||||
err = logic.UpdateNode(&node, &newnode)
|
err = logic.UpdateNode(&node, &newnode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -18,7 +18,7 @@ func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "Netclient CLI"
|
app.Name = "Netclient CLI"
|
||||||
app.Usage = "Netmaker's netclient agent and CLI. Used to perform interactions with Netmaker server and set local WireGuard config."
|
app.Usage = "Netmaker's netclient agent and CLI. Used to perform interactions with Netmaker server and set local WireGuard config."
|
||||||
app.Version = "v0.9.2"
|
app.Version = "v0.9.3"
|
||||||
|
|
||||||
cliFlags := cli_options.GetFlags(ncutils.GetHostname())
|
cliFlags := cli_options.GetFlags(ncutils.GetHostname())
|
||||||
app.Commands = cli_options.GetCommands(cliFlags[:])
|
app.Commands = cli_options.GetCommands(cliFlags[:])
|
||||||
|
|
|
@ -80,6 +80,11 @@ func GetServerConfig() config.ServerConfig {
|
||||||
cfg.ClientID = authInfo[1]
|
cfg.ClientID = authInfo[1]
|
||||||
cfg.ClientSecret = authInfo[2]
|
cfg.ClientSecret = authInfo[2]
|
||||||
cfg.FrontendURL = GetFrontendURL()
|
cfg.FrontendURL = GetFrontendURL()
|
||||||
|
if GetRce() {
|
||||||
|
cfg.RCE = "on"
|
||||||
|
} else {
|
||||||
|
cfg.RCE = "off"
|
||||||
|
}
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
@ -108,7 +113,7 @@ func GetAPIConnString() string {
|
||||||
|
|
||||||
// GetVersion - version of netmaker
|
// GetVersion - version of netmaker
|
||||||
func GetVersion() string {
|
func GetVersion() string {
|
||||||
version := "0.9.2"
|
version := "0.9.3"
|
||||||
if config.Config.Server.Version != "" {
|
if config.Config.Server.Version != "" {
|
||||||
version = config.Config.Server.Version
|
version = config.Config.Server.Version
|
||||||
}
|
}
|
||||||
|
@ -528,3 +533,8 @@ func getMacAddr() string {
|
||||||
}
|
}
|
||||||
return as[0]
|
return as[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRce - sees if Rce is enabled, off by default
|
||||||
|
func GetRce() bool {
|
||||||
|
return os.Getenv("RCE") == "on" || config.Config.Server.RCE == "on"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue