88 "os"
99 "path/filepath"
1010 "regexp"
11+ "strings"
1112 "time"
1213
1314 "github.com/sdslabs/beastv4/core"
@@ -126,7 +127,6 @@ type BeastConfig struct {
126127 HealthProber bool `toml:"health_prober"`
127128 RemoteSyncPeriod time.Duration `toml:"-"`
128129 Rsp string `toml:"remote_sync_period"`
129- LocalHostPortRange string `toml:"local_host_port_range"`
130130 InstanceConfig InstanceConfig `toml:"instance_config"`
131131
132132 CPUShares int64 `toml:"default_cpu_shares"`
@@ -225,15 +225,23 @@ func (config *BeastConfig) ValidateConfig() error {
225225 log .Warn ("No available servers provided for challenges. Using default localhost" )
226226 config .AvailableServers = map [string ]AvailableServer {
227227 core .LOCALHOST : {
228+ Name : core .LOCALHOST ,
228229 Host : core .LOCALHOST ,
229230 Username : os .Getenv ("USER" ),
230231 SSHKeyPath : "" ,
231232 Active : true ,
233+ PortRange : fmt .Sprintf ("%v%s%v" , core .ALLOWED_MIN_PORT_VALUE , core .MappingDelimeter , core .ALLOWED_MAX_PORT_VALUE ),
232234 },
233235 }
234236 }
235237
236- for _ , server := range config .AvailableServers {
238+ for name , server := range config .AvailableServers {
239+ if strings .Contains (name , ":" ) {
240+ return fmt .Errorf ("server key %q contains invalid character ':'" , name )
241+ }
242+
243+ server .Name = name
244+ config .AvailableServers [name ] = server
237245 if server .Active {
238246 err := server .ValidateServerConfig ()
239247 if err != nil {
@@ -284,11 +292,6 @@ func (config *BeastConfig) ValidateConfig() error {
284292 }
285293 }
286294
287- err = ValidatePortRange (config .LocalHostPortRange )
288- if err != nil {
289- return fmt .Errorf ("error while validating port range in global beast config: %s" , err )
290- }
291-
292295 if config .CPUShares <= 0 {
293296 log .Debug ("Per container CPU shares not provided using default value" )
294297 config .CPUShares = core .DEFAULT_CPU_SHARE
@@ -314,6 +317,7 @@ func (config *BeastConfig) ValidateConfig() error {
314317}
315318
316319type AvailableServer struct {
320+ Name string `toml:"-"`
317321 Host string `toml:"host"`
318322 Username string `toml:"username"`
319323 SSHKeyPath string `toml:"ssh_key_path"`
0 commit comments