Adding aliases that automatically gets added

This commit is contained in:
Tim Beatham
2023-11-17 19:05:21 +00:00
parent 2c5289afb0
commit f6160fe138
16 changed files with 305 additions and 13 deletions

15
pkg/mesh/alias.go Normal file
View File

@@ -0,0 +1,15 @@
package mesh
import "github.com/tim-beatham/wgmesh/pkg/hosts"
func AddAliases(meshid string, snapshot MeshSnapshot) {
hosts := hosts.NewHostsManipulator(meshid)
for _, node := range snapshot.GetNodes() {
if node.GetAlias() != "" {
hosts.AddAddr(node.GetWgHost().IP, node.GetAlias())
}
}
hosts.Write()
}