mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-24 16:58:05 +00:00
fixed issue #360
This commit is contained in:
parent
d6e1d10b12
commit
8be9e9655c
@ -24,6 +24,8 @@ func init() {
|
|||||||
enableRouteCmd.Flags().
|
enableRouteCmd.Flags().
|
||||||
StringSliceP("route", "r", []string{}, "List (or repeated flags) of routes to enable")
|
StringSliceP("route", "r", []string{}, "List (or repeated flags) of routes to enable")
|
||||||
enableRouteCmd.Flags().Uint64P("identifier", "i", 0, "Node identifier (ID)")
|
enableRouteCmd.Flags().Uint64P("identifier", "i", 0, "Node identifier (ID)")
|
||||||
|
enableRouteCmd.Flags().BoolP("all", "a", false, "All routes from host")
|
||||||
|
|
||||||
err = enableRouteCmd.MarkFlagRequired("identifier")
|
err = enableRouteCmd.MarkFlagRequired("identifier")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf(err.Error())
|
log.Fatalf(err.Error())
|
||||||
@ -125,21 +127,42 @@ omit the route you do not want to enable.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
routes, err := cmd.Flags().GetStringSlice("route")
|
|
||||||
if err != nil {
|
|
||||||
ErrorOutput(
|
|
||||||
err,
|
|
||||||
fmt.Sprintf("Error getting routes from flag: %s", err),
|
|
||||||
output,
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, client, conn, cancel := getHeadscaleCLIClient()
|
ctx, client, conn, cancel := getHeadscaleCLIClient()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
routes := []string{}
|
||||||
|
|
||||||
|
isAll, _ := cmd.Flags().GetBool("all")
|
||||||
|
if isAll == true {
|
||||||
|
// x := v1.NewHeadscaleServiceClient(conn)
|
||||||
|
// machine, err := x.GetMachineByID(machineID)
|
||||||
|
response, err := client.GetMachineRoute(ctx, &v1.GetMachineRouteRequest{
|
||||||
|
MachineId: machineID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
ErrorOutput(
|
||||||
|
err,
|
||||||
|
fmt.Sprintf(
|
||||||
|
"Cannot get machine routes: %s\n",
|
||||||
|
status.Convert(err).Message(),
|
||||||
|
),
|
||||||
|
output,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
routes = response.GetRoutes().GetAdvertisedRoutes()
|
||||||
|
} else {
|
||||||
|
routes, err = cmd.Flags().GetStringSlice("route")
|
||||||
|
if err != nil {
|
||||||
|
ErrorOutput(
|
||||||
|
err,
|
||||||
|
fmt.Sprintf("Error getting routes from flag: %s", err),
|
||||||
|
output,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
request := &v1.EnableMachineRoutesRequest{
|
request := &v1.EnableMachineRoutesRequest{
|
||||||
MachineId: machineID,
|
MachineId: machineID,
|
||||||
Routes: routes,
|
Routes: routes,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user