misc
This commit is contained in:
parent
61175acc67
commit
3fb51d8f84
@ -1,5 +1,5 @@
|
|||||||
mtd:
|
mtd:
|
||||||
services: []
|
services: {}
|
||||||
aws:
|
aws:
|
||||||
regions: []
|
regions: []
|
||||||
credentials_path: ./mtdaws/.credentials
|
credentials_path: ./mtdaws/.credentials
|
||||||
|
27
main.go
27
main.go
@ -26,9 +26,11 @@ func main() {
|
|||||||
|
|
||||||
|
|
||||||
config = indexAllInstances(config)
|
config = indexAllInstances(config)
|
||||||
|
state.SaveConf(ConfigPath, config)
|
||||||
|
|
||||||
//TODO: figure out migration (MTD)
|
//TODO: figure out migration (MTD)
|
||||||
config = movingTargetDefense(config)
|
config = movingTargetDefense(config)
|
||||||
|
state.SaveConf(ConfigPath, config)
|
||||||
|
|
||||||
//TODO: proxy commands
|
//TODO: proxy commands
|
||||||
}
|
}
|
||||||
@ -54,13 +56,9 @@ func indexAllInstances(config state.Config) state.Config {
|
|||||||
fmt.Println("Error converting ip:\t", err)
|
fmt.Println("Error converting ip:\t", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newService, found := indexInstance(config, cloudID, ip)
|
var found bool
|
||||||
if !found {
|
config, found = indexInstance(config, cloudID, ip)
|
||||||
fmt.Println("New instance found:\t", newService.CloudID)
|
if !found {awsNewInstanceCounter++}
|
||||||
config.MTD.Services = append(config.MTD.Services, newService)
|
|
||||||
state.SaveConf(ConfigPath, config)
|
|
||||||
awsNewInstanceCounter++
|
|
||||||
}
|
|
||||||
awsInstanceCounter++
|
awsInstanceCounter++
|
||||||
}
|
}
|
||||||
// TODO: Purge instances in config that are not found in the cloud
|
// TODO: Purge instances in config that are not found in the cloud
|
||||||
@ -70,7 +68,7 @@ func indexAllInstances(config state.Config) state.Config {
|
|||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
func indexInstance(config state.Config, cloudID string, serviceIP netip.Addr) (state.Service, bool) {
|
func indexInstance(config state.Config, cloudID string, serviceIP netip.Addr) (state.Config, bool) {
|
||||||
found := false
|
found := false
|
||||||
for _, service := range config.MTD.Services {
|
for _, service := range config.MTD.Services {
|
||||||
if service.CloudID == cloudID {
|
if service.CloudID == cloudID {
|
||||||
@ -78,10 +76,13 @@ func indexInstance(config state.Config, cloudID string, serviceIP netip.Addr) (s
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
fmt.Println("New instance found:\t", cloudID)
|
||||||
u := uuid.New()
|
u := uuid.New()
|
||||||
newService := state.Service{
|
config.MTD.Services[state.CustomUUID(u)] = state.Service{CloudID: cloudID, ServiceIP: serviceIP}
|
||||||
ID: state.CustomUUID(u),
|
state.SaveConf(ConfigPath, config)
|
||||||
CloudID: cloudID,
|
|
||||||
ServiceIP: serviceIP}
|
}
|
||||||
return newService, found
|
return config, found
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user