mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2025-08-18 08:59:45 +02:00
Ability to specify aliases
Ability to specify aliases that automatically append to /etc/hosts
This commit is contained in:
@@ -185,6 +185,37 @@ func putAlias(client *ipcRpc.Client, alias string) {
|
||||
fmt.Println(reply)
|
||||
}
|
||||
|
||||
func setService(client *ipcRpc.Client, service, value string) {
|
||||
var reply string
|
||||
|
||||
serviceArgs := &ipc.PutServiceArgs{
|
||||
Service: service,
|
||||
Value: value,
|
||||
}
|
||||
|
||||
err := client.Call("IpcHandler.PutService", serviceArgs, &reply)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(reply)
|
||||
}
|
||||
|
||||
func deleteService(client *ipcRpc.Client, service string) {
|
||||
var reply string
|
||||
|
||||
err := client.Call("IpcHandler.PutService", &service, &reply)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(reply)
|
||||
}
|
||||
|
||||
func main() {
|
||||
parser := argparse.NewParser("wg-mesh",
|
||||
"wg-mesh Manipulate WireGuard meshes")
|
||||
@@ -199,6 +230,8 @@ func main() {
|
||||
queryMeshCmd := parser.NewCommand("query-mesh", "Query a mesh network using JMESPath")
|
||||
putDescriptionCmd := parser.NewCommand("put-description", "Place a description for the node")
|
||||
putAliasCmd := parser.NewCommand("put-alias", "Place an alias for the node")
|
||||
setServiceCmd := parser.NewCommand("set-service", "Place a service into your advertisements")
|
||||
deleteServiceCmd := parser.NewCommand("delete-service", "Remove a service from your advertisements")
|
||||
|
||||
var newMeshIfName *string = newMeshCmd.String("f", "ifname", &argparse.Options{Required: true})
|
||||
var newMeshPort *int = newMeshCmd.Int("p", "wgport", &argparse.Options{Required: true})
|
||||
@@ -210,8 +243,6 @@ func main() {
|
||||
var joinMeshPort *int = joinMeshCmd.Int("p", "wgport", &argparse.Options{Required: true})
|
||||
var joinMeshEndpoint *string = joinMeshCmd.String("e", "endpoint", &argparse.Options{})
|
||||
|
||||
// var getMeshId *string = getMeshCmd.String("m", "mesh", &argparse.Options{Required: true})
|
||||
|
||||
var enableInterfaceMeshId *string = enableInterfaceCmd.String("m", "mesh", &argparse.Options{Required: true})
|
||||
|
||||
var getGraphMeshId *string = getGraphCmd.String("m", "mesh", &argparse.Options{Required: true})
|
||||
@@ -225,6 +256,11 @@ func main() {
|
||||
|
||||
var alias *string = putAliasCmd.String("a", "alias", &argparse.Options{Required: true})
|
||||
|
||||
var serviceKey *string = setServiceCmd.String("s", "service", &argparse.Options{Required: true})
|
||||
var serviceValue *string = setServiceCmd.String("v", "value", &argparse.Options{Required: true})
|
||||
|
||||
var deleteServiceKey *string = deleteServiceCmd.String("s", "service", &argparse.Options{Required: true})
|
||||
|
||||
err := parser.Parse(os.Args)
|
||||
|
||||
if err != nil {
|
||||
@@ -285,4 +321,12 @@ func main() {
|
||||
if putAliasCmd.Happened() {
|
||||
putAlias(client, *alias)
|
||||
}
|
||||
|
||||
if setServiceCmd.Happened() {
|
||||
setService(client, *serviceKey, *serviceValue)
|
||||
}
|
||||
|
||||
if deleteServiceCmd.Happened() {
|
||||
deleteService(client, *deleteServiceKey)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user