mirror of
https://github.com/juanfont/headscale.git
synced 2026-01-16 05:56:44 +01:00
Compare commits
18 Commits
rerouting
...
ssh-change
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51fb014e58 | ||
|
|
1acf5e5791 | ||
|
|
fc00cb3aa4 | ||
|
|
b4c63a7e0a | ||
|
|
1297616a65 | ||
|
|
5038761eca | ||
|
|
5b25c4c3d5 | ||
|
|
f9ade5ea37 | ||
|
|
10feae2d4b | ||
|
|
1ecb3e4c2a | ||
|
|
f72de09cd9 | ||
|
|
794e57f1c2 | ||
|
|
37bc8f364f | ||
|
|
5e0ba8c70f | ||
|
|
d4a51b0d2a | ||
|
|
44e37e21c2 | ||
|
|
93d03029e4 | ||
|
|
cd6df097ad |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -7,20 +7,9 @@
|
|||||||
- Log level option `log_level` was moved to a distinct `log` config section and renamed to `level` [#768](https://github.com/juanfont/headscale/pull/768)
|
- Log level option `log_level` was moved to a distinct `log` config section and renamed to `level` [#768](https://github.com/juanfont/headscale/pull/768)
|
||||||
- Removed Alpine Linux container image [#962](https://github.com/juanfont/headscale/pull/962)
|
- Removed Alpine Linux container image [#962](https://github.com/juanfont/headscale/pull/962)
|
||||||
|
|
||||||
### Important Changes
|
|
||||||
|
|
||||||
- Added support for Tailscale TS2021 protocol [#738](https://github.com/juanfont/headscale/pull/738)
|
|
||||||
- Add experimental support for [SSH ACL](https://tailscale.com/kb/1018/acls/#tailscale-ssh) (see docs for limitations) [#847](https://github.com/juanfont/headscale/pull/847)
|
|
||||||
- Please note that this support should be considered _partially_ implemented
|
|
||||||
- SSH ACLs status:
|
|
||||||
- Support `accept` and `check` (SSH can be enabled and used for connecting and authentication)
|
|
||||||
- Rejecting connections **are not supported**, meaning that if you enable SSH, then assume that _all_ `ssh` connections **will be allowed**.
|
|
||||||
- If you decied to try this feature, please carefully managed permissions by blocking port `22` with regular ACLs or do _not_ set `--ssh` on your clients.
|
|
||||||
- We are currently improving our testing of the SSH ACLs, help us get an overview by testing and giving feedback.
|
|
||||||
- This feature should be considered dangerous and it is disabled by default. Enable by setting `HEADSCALE_EXPERIMENTAL_FEATURE_SSH=1`.
|
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
|
- Added support for Tailscale TS2021 protocol [#738](https://github.com/juanfont/headscale/pull/738)
|
||||||
- Add ability to specify config location via env var `HEADSCALE_CONFIG` [#674](https://github.com/juanfont/headscale/issues/674)
|
- Add ability to specify config location via env var `HEADSCALE_CONFIG` [#674](https://github.com/juanfont/headscale/issues/674)
|
||||||
- Target Go 1.19 for Headscale [#778](https://github.com/juanfont/headscale/pull/778)
|
- Target Go 1.19 for Headscale [#778](https://github.com/juanfont/headscale/pull/778)
|
||||||
- Target Tailscale v1.30.0 to build Headscale [#780](https://github.com/juanfont/headscale/pull/780)
|
- Target Tailscale v1.30.0 to build Headscale [#780](https://github.com/juanfont/headscale/pull/780)
|
||||||
@@ -40,6 +29,14 @@
|
|||||||
- Fix OIDC registration issues [#960](https://github.com/juanfont/headscale/pull/960) and [#971](https://github.com/juanfont/headscale/pull/971)
|
- Fix OIDC registration issues [#960](https://github.com/juanfont/headscale/pull/960) and [#971](https://github.com/juanfont/headscale/pull/971)
|
||||||
- Add support for specifying NextDNS DNS-over-HTTPS resolver [#940](https://github.com/juanfont/headscale/pull/940)
|
- Add support for specifying NextDNS DNS-over-HTTPS resolver [#940](https://github.com/juanfont/headscale/pull/940)
|
||||||
- Make more sslmode available for postgresql connection [#927](https://github.com/juanfont/headscale/pull/927)
|
- Make more sslmode available for postgresql connection [#927](https://github.com/juanfont/headscale/pull/927)
|
||||||
|
- Add experimental support for [SSH ACL](https://tailscale.com/kb/1018/acls/#tailscale-ssh) (see docs for limitations) [#847](https://github.com/juanfont/headscale/pull/847)
|
||||||
|
- Please note that this support should be considered _partially_ implemented
|
||||||
|
- SSH ACLs status:
|
||||||
|
- Support `accept` and `check` (SSH can be enabled and used for connecting and authentication)
|
||||||
|
- Rejecting connections **are not supported**, meaning that if you enable SSH, then assume that _all_ `ssh` connections **will be allowed**.
|
||||||
|
- If you decied to try this feature, please carefully managed permissions by blocking port `22` with regular ACLs or do _not_ set `--ssh` on your clients.
|
||||||
|
- We are currently improving our testing of the SSH ACLs, help us get an overview by testing and giving feedback.
|
||||||
|
- This feature should be considered dangerous and it is disabled by default. Enable by setting `HEADSCALE_EXPERIMENTAL_FEATURE_SSH=1`.
|
||||||
|
|
||||||
## 0.16.4 (2022-08-21)
|
## 0.16.4 (2022-08-21)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func (h *Headscale) generateMapResponse(
|
|||||||
Str("func", "generateMapResponse").
|
Str("func", "generateMapResponse").
|
||||||
Str("machine", mapRequest.Hostinfo.Hostname).
|
Str("machine", mapRequest.Hostinfo.Hostname).
|
||||||
Msg("Creating Map response")
|
Msg("Creating Map response")
|
||||||
node, err := h.toNode(*machine, h.cfg.BaseDomain, h.cfg.DNSConfig)
|
node, err := machine.toNode(h.cfg.BaseDomain, h.cfg.DNSConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Caller().
|
Caller().
|
||||||
@@ -37,7 +37,7 @@ func (h *Headscale) generateMapResponse(
|
|||||||
|
|
||||||
profiles := h.getMapResponseUserProfiles(*machine, peers)
|
profiles := h.getMapResponseUserProfiles(*machine, peers)
|
||||||
|
|
||||||
nodePeers, err := h.toNodes(peers, h.cfg.BaseDomain, h.cfg.DNSConfig)
|
nodePeers, err := peers.toNodes(h.cfg.BaseDomain, h.cfg.DNSConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Caller().
|
Caller().
|
||||||
|
|||||||
12
app.go
12
app.go
@@ -219,16 +219,6 @@ func (h *Headscale) expireEphemeralNodes(milliSeconds int64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) failoverSubnetRoutes(milliSeconds int64) {
|
|
||||||
ticker := time.NewTicker(time.Duration(milliSeconds) * time.Millisecond)
|
|
||||||
for range ticker.C {
|
|
||||||
err := h.handlePrimarySubnetFailover()
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Msg("failed to handle primary subnet failover")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Headscale) expireEphemeralNodesWorker() {
|
func (h *Headscale) expireEphemeralNodesWorker() {
|
||||||
namespaces, err := h.ListNamespaces()
|
namespaces, err := h.ListNamespaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -507,8 +497,6 @@ func (h *Headscale) Serve() error {
|
|||||||
|
|
||||||
go h.expireEphemeralNodes(updateInterval)
|
go h.expireEphemeralNodes(updateInterval)
|
||||||
|
|
||||||
go h.failoverSubnetRoutes(updateInterval)
|
|
||||||
|
|
||||||
if zl.GlobalLevel() == zl.TraceLevel {
|
if zl.GlobalLevel() == zl.TraceLevel {
|
||||||
zerolog.RespLog = true
|
zerolog.RespLog = true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,28 +11,29 @@ import (
|
|||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
Base10 = 10
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(routesCmd)
|
rootCmd.AddCommand(routesCmd)
|
||||||
|
|
||||||
listRoutesCmd.Flags().Uint64P("identifier", "i", 0, "Node identifier (ID)")
|
listRoutesCmd.Flags().Uint64P("identifier", "i", 0, "Node identifier (ID)")
|
||||||
|
err := listRoutesCmd.MarkFlagRequired("identifier")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf(err.Error())
|
||||||
|
}
|
||||||
routesCmd.AddCommand(listRoutesCmd)
|
routesCmd.AddCommand(listRoutesCmd)
|
||||||
|
|
||||||
enableRouteCmd.Flags().Uint64P("route", "r", 0, "Route identifier (ID)")
|
enableRouteCmd.Flags().
|
||||||
err := enableRouteCmd.MarkFlagRequired("route")
|
StringSliceP("route", "r", []string{}, "List (or repeated flags) of routes to enable")
|
||||||
|
enableRouteCmd.Flags().Uint64P("identifier", "i", 0, "Node identifier (ID)")
|
||||||
|
enableRouteCmd.Flags().BoolP("all", "a", false, "All routes from host")
|
||||||
|
|
||||||
|
err = enableRouteCmd.MarkFlagRequired("identifier")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf(err.Error())
|
log.Fatalf(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
routesCmd.AddCommand(enableRouteCmd)
|
routesCmd.AddCommand(enableRouteCmd)
|
||||||
|
|
||||||
disableRouteCmd.Flags().Uint64P("route", "r", 0, "Route identifier (ID)")
|
nodeCmd.AddCommand(routesCmd)
|
||||||
err = disableRouteCmd.MarkFlagRequired("route")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf(err.Error())
|
|
||||||
}
|
|
||||||
routesCmd.AddCommand(disableRouteCmd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var routesCmd = &cobra.Command{
|
var routesCmd = &cobra.Command{
|
||||||
@@ -43,7 +44,7 @@ var routesCmd = &cobra.Command{
|
|||||||
|
|
||||||
var listRoutesCmd = &cobra.Command{
|
var listRoutesCmd = &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "List all routes",
|
Short: "List routes advertised and enabled by a given node",
|
||||||
Aliases: []string{"ls", "show"},
|
Aliases: []string{"ls", "show"},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
output, _ := cmd.Flags().GetString("output")
|
output, _ := cmd.Flags().GetString("output")
|
||||||
@@ -63,51 +64,28 @@ var listRoutesCmd = &cobra.Command{
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
var routes []*v1.Route
|
request := &v1.GetMachineRouteRequest{
|
||||||
|
MachineId: machineID,
|
||||||
if machineID == 0 {
|
|
||||||
response, err := client.GetRoutes(ctx, &v1.GetRoutesRequest{})
|
|
||||||
if err != nil {
|
|
||||||
ErrorOutput(
|
|
||||||
err,
|
|
||||||
fmt.Sprintf("Cannot get nodes: %s", status.Convert(err).Message()),
|
|
||||||
output,
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if output != "" {
|
|
||||||
SuccessOutput(response.Routes, "", output)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
routes = response.Routes
|
|
||||||
} else {
|
|
||||||
response, err := client.GetMachineRoutes(ctx, &v1.GetMachineRoutesRequest{
|
|
||||||
MachineId: machineID,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
ErrorOutput(
|
|
||||||
err,
|
|
||||||
fmt.Sprintf("Cannot get routes for machine %d: %s", machineID, status.Convert(err).Message()),
|
|
||||||
output,
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if output != "" {
|
|
||||||
SuccessOutput(response.Routes, "", output)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
routes = response.Routes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tableData := routesToPtables(routes)
|
response, err := client.GetMachineRoute(ctx, request)
|
||||||
|
if err != nil {
|
||||||
|
ErrorOutput(
|
||||||
|
err,
|
||||||
|
fmt.Sprintf("Cannot get nodes: %s", status.Convert(err).Message()),
|
||||||
|
output,
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if output != "" {
|
||||||
|
SuccessOutput(response.Routes, "", output)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tableData := routesToPtables(response.Routes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrorOutput(err, fmt.Sprintf("Error converting to table: %s", err), output)
|
ErrorOutput(err, fmt.Sprintf("Error converting to table: %s", err), output)
|
||||||
|
|
||||||
@@ -129,12 +107,16 @@ var listRoutesCmd = &cobra.Command{
|
|||||||
|
|
||||||
var enableRouteCmd = &cobra.Command{
|
var enableRouteCmd = &cobra.Command{
|
||||||
Use: "enable",
|
Use: "enable",
|
||||||
Short: "Set a route as enabled",
|
Short: "Set the enabled routes for a given node",
|
||||||
Long: `This command will make as enabled a given route.`,
|
Long: `This command will take a list of routes that will _replace_
|
||||||
|
the current set of routes on a given node.
|
||||||
|
If you would like to disable a route, simply run the command again, but
|
||||||
|
omit the route you do not want to enable.
|
||||||
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
output, _ := cmd.Flags().GetString("output")
|
output, _ := cmd.Flags().GetString("output")
|
||||||
|
|
||||||
routeID, err := cmd.Flags().GetUint64("route")
|
machineID, err := cmd.Flags().GetUint64("identifier")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrorOutput(
|
ErrorOutput(
|
||||||
err,
|
err,
|
||||||
@@ -149,13 +131,52 @@ var enableRouteCmd = &cobra.Command{
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
response, err := client.EnableRoute(ctx, &v1.EnableRouteRequest{
|
var routes []string
|
||||||
RouteId: routeID,
|
|
||||||
})
|
isAll, _ := cmd.Flags().GetBool("all")
|
||||||
|
if isAll {
|
||||||
|
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,
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
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{
|
||||||
|
MachineId: machineID,
|
||||||
|
Routes: routes,
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := client.EnableMachineRoutes(ctx, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrorOutput(
|
ErrorOutput(
|
||||||
err,
|
err,
|
||||||
fmt.Sprintf("Cannot enable route %d: %s", routeID, status.Convert(err).Message()),
|
fmt.Sprintf(
|
||||||
|
"Cannot register machine: %s\n",
|
||||||
|
status.Convert(err).Message(),
|
||||||
|
),
|
||||||
output,
|
output,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -163,71 +184,50 @@ var enableRouteCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if output != "" {
|
if output != "" {
|
||||||
SuccessOutput(response, "", output)
|
SuccessOutput(response.Routes, "", output)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
var disableRouteCmd = &cobra.Command{
|
tableData := routesToPtables(response.Routes)
|
||||||
Use: "disable",
|
if err != nil {
|
||||||
Short: "Set as disabled a given route",
|
ErrorOutput(err, fmt.Sprintf("Error converting to table: %s", err), output)
|
||||||
Long: `This command will make as disabled a given route.`,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
output, _ := cmd.Flags().GetString("output")
|
|
||||||
|
|
||||||
routeID, err := cmd.Flags().GetUint64("route")
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = pterm.DefaultTable.WithHasHeader().WithData(tableData).Render()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrorOutput(
|
ErrorOutput(
|
||||||
err,
|
err,
|
||||||
fmt.Sprintf("Error getting machine id from flag: %s", err),
|
fmt.Sprintf("Failed to render pterm table: %s", err),
|
||||||
output,
|
output,
|
||||||
)
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, client, conn, cancel := getHeadscaleCLIClient()
|
|
||||||
defer cancel()
|
|
||||||
defer conn.Close()
|
|
||||||
|
|
||||||
response, err := client.DisableRoute(ctx, &v1.DisableRouteRequest{
|
|
||||||
RouteId: routeID,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
ErrorOutput(
|
|
||||||
err,
|
|
||||||
fmt.Sprintf("Cannot enable route %d: %s", routeID, status.Convert(err).Message()),
|
|
||||||
output,
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if output != "" {
|
|
||||||
SuccessOutput(response, "", output)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// routesToPtables converts the list of routes to a nice table.
|
// routesToPtables converts the list of routes to a nice table.
|
||||||
func routesToPtables(routes []*v1.Route) pterm.TableData {
|
func routesToPtables(routes *v1.Routes) pterm.TableData {
|
||||||
tableData := pterm.TableData{{"ID", "Machine", "Prefix", "Advertised", "Enabled", "Primary"}}
|
tableData := pterm.TableData{{"Route", "Enabled"}}
|
||||||
|
|
||||||
for _, route := range routes {
|
for _, route := range routes.GetAdvertisedRoutes() {
|
||||||
tableData = append(tableData,
|
enabled := isStringInSlice(routes.EnabledRoutes, route)
|
||||||
[]string{
|
|
||||||
strconv.FormatUint(route.Id, Base10),
|
tableData = append(tableData, []string{route, strconv.FormatBool(enabled)})
|
||||||
route.Machine.GivenName,
|
|
||||||
route.Prefix,
|
|
||||||
strconv.FormatBool(route.Advertised),
|
|
||||||
strconv.FormatBool(route.Enabled),
|
|
||||||
strconv.FormatBool(route.IsPrimary),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tableData
|
return tableData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isStringInSlice(strs []string, s string) bool {
|
||||||
|
for _, s2 := range strs {
|
||||||
|
if s == s2 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
91
db.go
91
db.go
@@ -18,10 +18,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
dbVersion = "1"
|
dbVersion = "1"
|
||||||
|
errValueNotFound = Error("not found")
|
||||||
errValueNotFound = Error("not found")
|
|
||||||
ErrCannotParsePrefix = Error("cannot parse prefix")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// KV is a key-value store in a psql table. For future use...
|
// KV is a key-value store in a psql table. For future use...
|
||||||
@@ -81,67 +79,6 @@ func (h *Headscale) initDB() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = db.AutoMigrate(&Route{})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if db.Migrator().HasColumn(&Machine{}, "enabled_routes") {
|
|
||||||
log.Info().Msgf("Database has legacy enabled_routes column in machine, migrating...")
|
|
||||||
|
|
||||||
type MachineAux struct {
|
|
||||||
ID uint64
|
|
||||||
EnabledRoutes IPPrefixes
|
|
||||||
}
|
|
||||||
|
|
||||||
machinesAux := []MachineAux{}
|
|
||||||
err := db.Table("machines").Select("id, enabled_routes").Scan(&machinesAux).Error
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal().Err(err).Msg("Error accessing db")
|
|
||||||
}
|
|
||||||
for _, machine := range machinesAux {
|
|
||||||
for _, prefix := range machine.EnabledRoutes {
|
|
||||||
if err != nil {
|
|
||||||
log.Error().
|
|
||||||
Err(err).
|
|
||||||
Str("enabled_route", prefix.String()).
|
|
||||||
Msg("Error parsing enabled_route")
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
err = db.Preload("Machine").Where("machine_id = ? AND prefix = ?", machine.ID, IPPrefix(prefix)).First(&Route{}).Error
|
|
||||||
if err == nil {
|
|
||||||
log.Info().
|
|
||||||
Str("enabled_route", prefix.String()).
|
|
||||||
Msg("Route already migrated to new table, skipping")
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
route := Route{
|
|
||||||
MachineID: machine.ID,
|
|
||||||
Advertised: true,
|
|
||||||
Enabled: true,
|
|
||||||
Prefix: IPPrefix(prefix),
|
|
||||||
}
|
|
||||||
if err := h.db.Create(&route).Error; err != nil {
|
|
||||||
log.Error().Err(err).Msg("Error creating route")
|
|
||||||
} else {
|
|
||||||
log.Info().
|
|
||||||
Uint64("machine_id", route.MachineID).
|
|
||||||
Str("prefix", prefix.String()).
|
|
||||||
Msg("Route migrated")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = db.Migrator().DropColumn(&Machine{}, "enabled_routes")
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Msg("Error dropping enabled_routes column")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = db.AutoMigrate(&Machine{})
|
err = db.AutoMigrate(&Machine{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -327,30 +264,6 @@ func (hi HostInfo) Value() (driver.Value, error) {
|
|||||||
return string(bytes), err
|
return string(bytes), err
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPPrefix netip.Prefix
|
|
||||||
|
|
||||||
func (i *IPPrefix) Scan(destination interface{}) error {
|
|
||||||
switch value := destination.(type) {
|
|
||||||
case string:
|
|
||||||
prefix, err := netip.ParsePrefix(value)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*i = IPPrefix(prefix)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("%w: unexpected data type %T", ErrCannotParsePrefix, destination)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value return json value, implement driver.Valuer interface.
|
|
||||||
func (i IPPrefix) Value() (driver.Value, error) {
|
|
||||||
prefixStr := netip.Prefix(i).String()
|
|
||||||
|
|
||||||
return prefixStr, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type IPPrefixes []netip.Prefix
|
type IPPrefixes []netip.Prefix
|
||||||
|
|
||||||
func (i *IPPrefixes) Scan(destination interface{}) error {
|
func (i *IPPrefixes) Scan(destination interface{}) error {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ var file_headscale_v1_headscale_proto_rawDesc = []byte{
|
|||||||
0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76,
|
0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76,
|
||||||
0x31, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19,
|
0x31, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19,
|
||||||
0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x70, 0x69,
|
0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x70, 0x69,
|
||||||
0x6b, 0x65, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x81, 0x18, 0x0a, 0x10, 0x48, 0x65,
|
0x6b, 0x65, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xb1, 0x16, 0x0a, 0x10, 0x48, 0x65,
|
||||||
0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x77,
|
0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x77,
|
||||||
0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x21,
|
0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x21,
|
||||||
0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65,
|
0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65,
|
||||||
@@ -51,9 +51,9 @@ var file_headscale_v1_headscale_proto_rawDesc = []byte{
|
|||||||
0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||||
0x1a, 0x25, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e,
|
0x1a, 0x25, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e,
|
||||||
0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52,
|
0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52,
|
||||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x3a,
|
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22,
|
||||||
0x01, 0x2a, 0x22, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6e, 0x61, 0x6d, 0x65,
|
0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61,
|
||||||
0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x96, 0x01, 0x0a, 0x0f, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65,
|
0x63, 0x65, 0x3a, 0x01, 0x2a, 0x12, 0x96, 0x01, 0x0a, 0x0f, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65,
|
||||||
0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x24, 0x2e, 0x68, 0x65, 0x61, 0x64,
|
0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x24, 0x2e, 0x68, 0x65, 0x61, 0x64,
|
||||||
0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x4e,
|
0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x4e,
|
||||||
0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||||
@@ -85,17 +85,17 @@ var file_headscale_v1_headscale_proto_rawDesc = []byte{
|
|||||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c,
|
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c,
|
||||||
0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x65, 0x41, 0x75,
|
0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x65, 0x41, 0x75,
|
||||||
0x74, 0x68, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82,
|
0x74, 0x68, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82,
|
||||||
0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, 0x01, 0x2a, 0x22, 0x12, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76,
|
0xd3, 0xe4, 0x93, 0x02, 0x17, 0x22, 0x12, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x70,
|
||||||
0x31, 0x2f, 0x70, 0x72, 0x65, 0x61, 0x75, 0x74, 0x68, 0x6b, 0x65, 0x79, 0x12, 0x87, 0x01, 0x0a,
|
0x72, 0x65, 0x61, 0x75, 0x74, 0x68, 0x6b, 0x65, 0x79, 0x3a, 0x01, 0x2a, 0x12, 0x87, 0x01, 0x0a,
|
||||||
0x10, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x50, 0x72, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4b, 0x65,
|
0x10, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x50, 0x72, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4b, 0x65,
|
||||||
0x79, 0x12, 0x25, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31,
|
0x79, 0x12, 0x25, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31,
|
||||||
0x2e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x50, 0x72, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4b, 0x65,
|
0x2e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x50, 0x72, 0x65, 0x41, 0x75, 0x74, 0x68, 0x4b, 0x65,
|
||||||
0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73,
|
0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73,
|
||||||
0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x50, 0x72,
|
0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x50, 0x72,
|
||||||
0x65, 0x41, 0x75, 0x74, 0x68, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
0x65, 0x41, 0x75, 0x74, 0x68, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||||
0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x3a, 0x01, 0x2a, 0x22, 0x19, 0x2f, 0x61, 0x70,
|
0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x22, 0x19, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76,
|
||||||
0x69, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x72, 0x65, 0x61, 0x75, 0x74, 0x68, 0x6b, 0x65, 0x79, 0x2f,
|
0x31, 0x2f, 0x70, 0x72, 0x65, 0x61, 0x75, 0x74, 0x68, 0x6b, 0x65, 0x79, 0x2f, 0x65, 0x78, 0x70,
|
||||||
0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x12, 0x7a, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72,
|
0x69, 0x72, 0x65, 0x3a, 0x01, 0x2a, 0x12, 0x7a, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72,
|
||||||
0x65, 0x41, 0x75, 0x74, 0x68, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x24, 0x2e, 0x68, 0x65, 0x61, 0x64,
|
0x65, 0x41, 0x75, 0x74, 0x68, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x24, 0x2e, 0x68, 0x65, 0x61, 0x64,
|
||||||
0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x65,
|
0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x65,
|
||||||
0x41, 0x75, 0x74, 0x68, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
0x41, 0x75, 0x74, 0x68, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||||
@@ -110,8 +110,8 @@ var file_headscale_v1_headscale_proto_rawDesc = []byte{
|
|||||||
0x73, 0x74, 0x1a, 0x28, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76,
|
0x73, 0x74, 0x1a, 0x28, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76,
|
||||||
0x31, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63,
|
0x31, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63,
|
||||||
0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3,
|
0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3,
|
||||||
0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, 0x2a, 0x22, 0x15, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31,
|
0xe4, 0x93, 0x02, 0x1a, 0x22, 0x15, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x65,
|
||||||
0x2f, 0x64, 0x65, 0x62, 0x75, 0x67, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x75,
|
0x62, 0x75, 0x67, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x3a, 0x01, 0x2a, 0x12, 0x75,
|
||||||
0x0a, 0x0a, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x1f, 0x2e, 0x68,
|
0x0a, 0x0a, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x1f, 0x2e, 0x68,
|
||||||
0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4d,
|
0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4d,
|
||||||
0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e,
|
0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e,
|
||||||
@@ -124,9 +124,9 @@ var file_headscale_v1_headscale_proto_rawDesc = []byte{
|
|||||||
0x53, 0x65, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d,
|
0x53, 0x65, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d,
|
||||||
0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65,
|
0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65,
|
||||||
0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x82,
|
0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x82,
|
||||||
0xd3, 0xe4, 0x93, 0x02, 0x26, 0x3a, 0x01, 0x2a, 0x22, 0x21, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76,
|
0xd3, 0xe4, 0x93, 0x02, 0x26, 0x22, 0x21, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6d,
|
||||||
0x31, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x7b, 0x6d, 0x61, 0x63, 0x68, 0x69,
|
0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x7b, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f,
|
||||||
0x6e, 0x65, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x74, 0x61, 0x67, 0x73, 0x12, 0x80, 0x01, 0x0a, 0x0f,
|
0x69, 0x64, 0x7d, 0x2f, 0x74, 0x61, 0x67, 0x73, 0x3a, 0x01, 0x2a, 0x12, 0x80, 0x01, 0x0a, 0x0f,
|
||||||
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12,
|
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12,
|
||||||
0x24, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52,
|
0x24, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52,
|
||||||
0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65,
|
0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65,
|
||||||
@@ -175,37 +175,24 @@ var file_headscale_v1_headscale_proto_rawDesc = []byte{
|
|||||||
0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e,
|
0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e,
|
||||||
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x22, 0x26, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f,
|
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x22, 0x26, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f,
|
||||||
0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x7b, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65,
|
0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x7b, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65,
|
||||||
0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x64,
|
0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x8b,
|
||||||
0x0a, 0x09, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x12, 0x1e, 0x2e, 0x68, 0x65,
|
0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75,
|
||||||
0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x6f,
|
0x74, 0x65, 0x12, 0x24, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76,
|
||||||
0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x68, 0x65,
|
0x31, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74,
|
||||||
0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x6f,
|
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73,
|
||||||
0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3,
|
0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69,
|
||||||
0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x6f,
|
0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
||||||
0x75, 0x74, 0x65, 0x73, 0x12, 0x7c, 0x0a, 0x0b, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x6f,
|
0x2b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x25, 0x12, 0x23, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31,
|
||||||
0x75, 0x74, 0x65, 0x12, 0x20, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e,
|
0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x7b, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e,
|
||||||
0x76, 0x31, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65,
|
0x65, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x12, 0x97, 0x01, 0x0a,
|
||||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c,
|
0x13, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f,
|
||||||
0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65,
|
0x75, 0x74, 0x65, 0x73, 0x12, 0x28, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65,
|
||||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x22,
|
0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e,
|
||||||
0x22, 0x20, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73,
|
0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29,
|
||||||
0x2f, 0x7b, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x65, 0x6e, 0x61, 0x62,
|
0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6e,
|
||||||
0x6c, 0x65, 0x12, 0x80, 0x01, 0x0a, 0x0c, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x6f,
|
0x61, 0x62, 0x6c, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65,
|
||||||
0x75, 0x74, 0x65, 0x12, 0x21, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e,
|
|
||||||
0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52,
|
|
||||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61,
|
|
||||||
0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x6f, 0x75,
|
|
||||||
0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93,
|
|
||||||
0x02, 0x23, 0x22, 0x21, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x6f, 0x75, 0x74,
|
|
||||||
0x65, 0x73, 0x2f, 0x7b, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x64, 0x69,
|
|
||||||
0x73, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x8e, 0x01, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63,
|
|
||||||
0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x2e, 0x68, 0x65, 0x61,
|
|
||||||
0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63,
|
|
||||||
0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
|
||||||
0x74, 0x1a, 0x26, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31,
|
|
||||||
0x2e, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65,
|
|
||||||
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x82, 0xd3, 0xe4, 0x93, 0x02,
|
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x82, 0xd3, 0xe4, 0x93, 0x02,
|
||||||
0x25, 0x12, 0x23, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69,
|
0x25, 0x22, 0x23, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69,
|
||||||
0x6e, 0x65, 0x2f, 0x7b, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x7d, 0x2f,
|
0x6e, 0x65, 0x2f, 0x7b, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x7d, 0x2f,
|
||||||
0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x12, 0x70, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
|
0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x12, 0x70, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
|
||||||
0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61,
|
0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61,
|
||||||
@@ -213,16 +200,16 @@ var file_headscale_v1_headscale_proto_rawDesc = []byte{
|
|||||||
0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x68, 0x65, 0x61, 0x64,
|
0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x68, 0x65, 0x61, 0x64,
|
||||||
0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41,
|
0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41,
|
||||||
0x70, 0x69, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82,
|
0x70, 0x69, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82,
|
||||||
0xd3, 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76,
|
0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x61,
|
||||||
0x31, 0x2f, 0x61, 0x70, 0x69, 0x6b, 0x65, 0x79, 0x12, 0x77, 0x0a, 0x0c, 0x45, 0x78, 0x70, 0x69,
|
0x70, 0x69, 0x6b, 0x65, 0x79, 0x3a, 0x01, 0x2a, 0x12, 0x77, 0x0a, 0x0c, 0x45, 0x78, 0x70, 0x69,
|
||||||
0x72, 0x65, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73,
|
0x72, 0x65, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73,
|
||||||
0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x41, 0x70,
|
0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x41, 0x70,
|
||||||
0x69, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x68, 0x65,
|
0x69, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x68, 0x65,
|
||||||
0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x69, 0x72,
|
0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x69, 0x72,
|
||||||
0x65, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
0x65, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
||||||
0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, 0x2a, 0x22, 0x15, 0x2f, 0x61, 0x70, 0x69,
|
0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x22, 0x15, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31,
|
||||||
0x2f, 0x76, 0x31, 0x2f, 0x61, 0x70, 0x69, 0x6b, 0x65, 0x79, 0x2f, 0x65, 0x78, 0x70, 0x69, 0x72,
|
0x2f, 0x61, 0x70, 0x69, 0x6b, 0x65, 0x79, 0x2f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x3a, 0x01,
|
||||||
0x65, 0x12, 0x6a, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x73,
|
0x2a, 0x12, 0x6a, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x73,
|
||||||
0x12, 0x20, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e,
|
0x12, 0x20, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e,
|
||||||
0x4c, 0x69, 0x73, 0x74, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
0x4c, 0x69, 0x73, 0x74, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||||
0x73, 0x74, 0x1a, 0x21, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76,
|
0x73, 0x74, 0x1a, 0x21, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76,
|
||||||
@@ -235,54 +222,50 @@ var file_headscale_v1_headscale_proto_rawDesc = []byte{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var file_headscale_v1_headscale_proto_goTypes = []interface{}{
|
var file_headscale_v1_headscale_proto_goTypes = []interface{}{
|
||||||
(*GetNamespaceRequest)(nil), // 0: headscale.v1.GetNamespaceRequest
|
(*GetNamespaceRequest)(nil), // 0: headscale.v1.GetNamespaceRequest
|
||||||
(*CreateNamespaceRequest)(nil), // 1: headscale.v1.CreateNamespaceRequest
|
(*CreateNamespaceRequest)(nil), // 1: headscale.v1.CreateNamespaceRequest
|
||||||
(*RenameNamespaceRequest)(nil), // 2: headscale.v1.RenameNamespaceRequest
|
(*RenameNamespaceRequest)(nil), // 2: headscale.v1.RenameNamespaceRequest
|
||||||
(*DeleteNamespaceRequest)(nil), // 3: headscale.v1.DeleteNamespaceRequest
|
(*DeleteNamespaceRequest)(nil), // 3: headscale.v1.DeleteNamespaceRequest
|
||||||
(*ListNamespacesRequest)(nil), // 4: headscale.v1.ListNamespacesRequest
|
(*ListNamespacesRequest)(nil), // 4: headscale.v1.ListNamespacesRequest
|
||||||
(*CreatePreAuthKeyRequest)(nil), // 5: headscale.v1.CreatePreAuthKeyRequest
|
(*CreatePreAuthKeyRequest)(nil), // 5: headscale.v1.CreatePreAuthKeyRequest
|
||||||
(*ExpirePreAuthKeyRequest)(nil), // 6: headscale.v1.ExpirePreAuthKeyRequest
|
(*ExpirePreAuthKeyRequest)(nil), // 6: headscale.v1.ExpirePreAuthKeyRequest
|
||||||
(*ListPreAuthKeysRequest)(nil), // 7: headscale.v1.ListPreAuthKeysRequest
|
(*ListPreAuthKeysRequest)(nil), // 7: headscale.v1.ListPreAuthKeysRequest
|
||||||
(*DebugCreateMachineRequest)(nil), // 8: headscale.v1.DebugCreateMachineRequest
|
(*DebugCreateMachineRequest)(nil), // 8: headscale.v1.DebugCreateMachineRequest
|
||||||
(*GetMachineRequest)(nil), // 9: headscale.v1.GetMachineRequest
|
(*GetMachineRequest)(nil), // 9: headscale.v1.GetMachineRequest
|
||||||
(*SetTagsRequest)(nil), // 10: headscale.v1.SetTagsRequest
|
(*SetTagsRequest)(nil), // 10: headscale.v1.SetTagsRequest
|
||||||
(*RegisterMachineRequest)(nil), // 11: headscale.v1.RegisterMachineRequest
|
(*RegisterMachineRequest)(nil), // 11: headscale.v1.RegisterMachineRequest
|
||||||
(*DeleteMachineRequest)(nil), // 12: headscale.v1.DeleteMachineRequest
|
(*DeleteMachineRequest)(nil), // 12: headscale.v1.DeleteMachineRequest
|
||||||
(*ExpireMachineRequest)(nil), // 13: headscale.v1.ExpireMachineRequest
|
(*ExpireMachineRequest)(nil), // 13: headscale.v1.ExpireMachineRequest
|
||||||
(*RenameMachineRequest)(nil), // 14: headscale.v1.RenameMachineRequest
|
(*RenameMachineRequest)(nil), // 14: headscale.v1.RenameMachineRequest
|
||||||
(*ListMachinesRequest)(nil), // 15: headscale.v1.ListMachinesRequest
|
(*ListMachinesRequest)(nil), // 15: headscale.v1.ListMachinesRequest
|
||||||
(*MoveMachineRequest)(nil), // 16: headscale.v1.MoveMachineRequest
|
(*MoveMachineRequest)(nil), // 16: headscale.v1.MoveMachineRequest
|
||||||
(*GetRoutesRequest)(nil), // 17: headscale.v1.GetRoutesRequest
|
(*GetMachineRouteRequest)(nil), // 17: headscale.v1.GetMachineRouteRequest
|
||||||
(*EnableRouteRequest)(nil), // 18: headscale.v1.EnableRouteRequest
|
(*EnableMachineRoutesRequest)(nil), // 18: headscale.v1.EnableMachineRoutesRequest
|
||||||
(*DisableRouteRequest)(nil), // 19: headscale.v1.DisableRouteRequest
|
(*CreateApiKeyRequest)(nil), // 19: headscale.v1.CreateApiKeyRequest
|
||||||
(*GetMachineRoutesRequest)(nil), // 20: headscale.v1.GetMachineRoutesRequest
|
(*ExpireApiKeyRequest)(nil), // 20: headscale.v1.ExpireApiKeyRequest
|
||||||
(*CreateApiKeyRequest)(nil), // 21: headscale.v1.CreateApiKeyRequest
|
(*ListApiKeysRequest)(nil), // 21: headscale.v1.ListApiKeysRequest
|
||||||
(*ExpireApiKeyRequest)(nil), // 22: headscale.v1.ExpireApiKeyRequest
|
(*GetNamespaceResponse)(nil), // 22: headscale.v1.GetNamespaceResponse
|
||||||
(*ListApiKeysRequest)(nil), // 23: headscale.v1.ListApiKeysRequest
|
(*CreateNamespaceResponse)(nil), // 23: headscale.v1.CreateNamespaceResponse
|
||||||
(*GetNamespaceResponse)(nil), // 24: headscale.v1.GetNamespaceResponse
|
(*RenameNamespaceResponse)(nil), // 24: headscale.v1.RenameNamespaceResponse
|
||||||
(*CreateNamespaceResponse)(nil), // 25: headscale.v1.CreateNamespaceResponse
|
(*DeleteNamespaceResponse)(nil), // 25: headscale.v1.DeleteNamespaceResponse
|
||||||
(*RenameNamespaceResponse)(nil), // 26: headscale.v1.RenameNamespaceResponse
|
(*ListNamespacesResponse)(nil), // 26: headscale.v1.ListNamespacesResponse
|
||||||
(*DeleteNamespaceResponse)(nil), // 27: headscale.v1.DeleteNamespaceResponse
|
(*CreatePreAuthKeyResponse)(nil), // 27: headscale.v1.CreatePreAuthKeyResponse
|
||||||
(*ListNamespacesResponse)(nil), // 28: headscale.v1.ListNamespacesResponse
|
(*ExpirePreAuthKeyResponse)(nil), // 28: headscale.v1.ExpirePreAuthKeyResponse
|
||||||
(*CreatePreAuthKeyResponse)(nil), // 29: headscale.v1.CreatePreAuthKeyResponse
|
(*ListPreAuthKeysResponse)(nil), // 29: headscale.v1.ListPreAuthKeysResponse
|
||||||
(*ExpirePreAuthKeyResponse)(nil), // 30: headscale.v1.ExpirePreAuthKeyResponse
|
(*DebugCreateMachineResponse)(nil), // 30: headscale.v1.DebugCreateMachineResponse
|
||||||
(*ListPreAuthKeysResponse)(nil), // 31: headscale.v1.ListPreAuthKeysResponse
|
(*GetMachineResponse)(nil), // 31: headscale.v1.GetMachineResponse
|
||||||
(*DebugCreateMachineResponse)(nil), // 32: headscale.v1.DebugCreateMachineResponse
|
(*SetTagsResponse)(nil), // 32: headscale.v1.SetTagsResponse
|
||||||
(*GetMachineResponse)(nil), // 33: headscale.v1.GetMachineResponse
|
(*RegisterMachineResponse)(nil), // 33: headscale.v1.RegisterMachineResponse
|
||||||
(*SetTagsResponse)(nil), // 34: headscale.v1.SetTagsResponse
|
(*DeleteMachineResponse)(nil), // 34: headscale.v1.DeleteMachineResponse
|
||||||
(*RegisterMachineResponse)(nil), // 35: headscale.v1.RegisterMachineResponse
|
(*ExpireMachineResponse)(nil), // 35: headscale.v1.ExpireMachineResponse
|
||||||
(*DeleteMachineResponse)(nil), // 36: headscale.v1.DeleteMachineResponse
|
(*RenameMachineResponse)(nil), // 36: headscale.v1.RenameMachineResponse
|
||||||
(*ExpireMachineResponse)(nil), // 37: headscale.v1.ExpireMachineResponse
|
(*ListMachinesResponse)(nil), // 37: headscale.v1.ListMachinesResponse
|
||||||
(*RenameMachineResponse)(nil), // 38: headscale.v1.RenameMachineResponse
|
(*MoveMachineResponse)(nil), // 38: headscale.v1.MoveMachineResponse
|
||||||
(*ListMachinesResponse)(nil), // 39: headscale.v1.ListMachinesResponse
|
(*GetMachineRouteResponse)(nil), // 39: headscale.v1.GetMachineRouteResponse
|
||||||
(*MoveMachineResponse)(nil), // 40: headscale.v1.MoveMachineResponse
|
(*EnableMachineRoutesResponse)(nil), // 40: headscale.v1.EnableMachineRoutesResponse
|
||||||
(*GetRoutesResponse)(nil), // 41: headscale.v1.GetRoutesResponse
|
(*CreateApiKeyResponse)(nil), // 41: headscale.v1.CreateApiKeyResponse
|
||||||
(*EnableRouteResponse)(nil), // 42: headscale.v1.EnableRouteResponse
|
(*ExpireApiKeyResponse)(nil), // 42: headscale.v1.ExpireApiKeyResponse
|
||||||
(*DisableRouteResponse)(nil), // 43: headscale.v1.DisableRouteResponse
|
(*ListApiKeysResponse)(nil), // 43: headscale.v1.ListApiKeysResponse
|
||||||
(*GetMachineRoutesResponse)(nil), // 44: headscale.v1.GetMachineRoutesResponse
|
|
||||||
(*CreateApiKeyResponse)(nil), // 45: headscale.v1.CreateApiKeyResponse
|
|
||||||
(*ExpireApiKeyResponse)(nil), // 46: headscale.v1.ExpireApiKeyResponse
|
|
||||||
(*ListApiKeysResponse)(nil), // 47: headscale.v1.ListApiKeysResponse
|
|
||||||
}
|
}
|
||||||
var file_headscale_v1_headscale_proto_depIdxs = []int32{
|
var file_headscale_v1_headscale_proto_depIdxs = []int32{
|
||||||
0, // 0: headscale.v1.HeadscaleService.GetNamespace:input_type -> headscale.v1.GetNamespaceRequest
|
0, // 0: headscale.v1.HeadscaleService.GetNamespace:input_type -> headscale.v1.GetNamespaceRequest
|
||||||
@@ -302,39 +285,35 @@ var file_headscale_v1_headscale_proto_depIdxs = []int32{
|
|||||||
14, // 14: headscale.v1.HeadscaleService.RenameMachine:input_type -> headscale.v1.RenameMachineRequest
|
14, // 14: headscale.v1.HeadscaleService.RenameMachine:input_type -> headscale.v1.RenameMachineRequest
|
||||||
15, // 15: headscale.v1.HeadscaleService.ListMachines:input_type -> headscale.v1.ListMachinesRequest
|
15, // 15: headscale.v1.HeadscaleService.ListMachines:input_type -> headscale.v1.ListMachinesRequest
|
||||||
16, // 16: headscale.v1.HeadscaleService.MoveMachine:input_type -> headscale.v1.MoveMachineRequest
|
16, // 16: headscale.v1.HeadscaleService.MoveMachine:input_type -> headscale.v1.MoveMachineRequest
|
||||||
17, // 17: headscale.v1.HeadscaleService.GetRoutes:input_type -> headscale.v1.GetRoutesRequest
|
17, // 17: headscale.v1.HeadscaleService.GetMachineRoute:input_type -> headscale.v1.GetMachineRouteRequest
|
||||||
18, // 18: headscale.v1.HeadscaleService.EnableRoute:input_type -> headscale.v1.EnableRouteRequest
|
18, // 18: headscale.v1.HeadscaleService.EnableMachineRoutes:input_type -> headscale.v1.EnableMachineRoutesRequest
|
||||||
19, // 19: headscale.v1.HeadscaleService.DisableRoute:input_type -> headscale.v1.DisableRouteRequest
|
19, // 19: headscale.v1.HeadscaleService.CreateApiKey:input_type -> headscale.v1.CreateApiKeyRequest
|
||||||
20, // 20: headscale.v1.HeadscaleService.GetMachineRoutes:input_type -> headscale.v1.GetMachineRoutesRequest
|
20, // 20: headscale.v1.HeadscaleService.ExpireApiKey:input_type -> headscale.v1.ExpireApiKeyRequest
|
||||||
21, // 21: headscale.v1.HeadscaleService.CreateApiKey:input_type -> headscale.v1.CreateApiKeyRequest
|
21, // 21: headscale.v1.HeadscaleService.ListApiKeys:input_type -> headscale.v1.ListApiKeysRequest
|
||||||
22, // 22: headscale.v1.HeadscaleService.ExpireApiKey:input_type -> headscale.v1.ExpireApiKeyRequest
|
22, // 22: headscale.v1.HeadscaleService.GetNamespace:output_type -> headscale.v1.GetNamespaceResponse
|
||||||
23, // 23: headscale.v1.HeadscaleService.ListApiKeys:input_type -> headscale.v1.ListApiKeysRequest
|
23, // 23: headscale.v1.HeadscaleService.CreateNamespace:output_type -> headscale.v1.CreateNamespaceResponse
|
||||||
24, // 24: headscale.v1.HeadscaleService.GetNamespace:output_type -> headscale.v1.GetNamespaceResponse
|
24, // 24: headscale.v1.HeadscaleService.RenameNamespace:output_type -> headscale.v1.RenameNamespaceResponse
|
||||||
25, // 25: headscale.v1.HeadscaleService.CreateNamespace:output_type -> headscale.v1.CreateNamespaceResponse
|
25, // 25: headscale.v1.HeadscaleService.DeleteNamespace:output_type -> headscale.v1.DeleteNamespaceResponse
|
||||||
26, // 26: headscale.v1.HeadscaleService.RenameNamespace:output_type -> headscale.v1.RenameNamespaceResponse
|
26, // 26: headscale.v1.HeadscaleService.ListNamespaces:output_type -> headscale.v1.ListNamespacesResponse
|
||||||
27, // 27: headscale.v1.HeadscaleService.DeleteNamespace:output_type -> headscale.v1.DeleteNamespaceResponse
|
27, // 27: headscale.v1.HeadscaleService.CreatePreAuthKey:output_type -> headscale.v1.CreatePreAuthKeyResponse
|
||||||
28, // 28: headscale.v1.HeadscaleService.ListNamespaces:output_type -> headscale.v1.ListNamespacesResponse
|
28, // 28: headscale.v1.HeadscaleService.ExpirePreAuthKey:output_type -> headscale.v1.ExpirePreAuthKeyResponse
|
||||||
29, // 29: headscale.v1.HeadscaleService.CreatePreAuthKey:output_type -> headscale.v1.CreatePreAuthKeyResponse
|
29, // 29: headscale.v1.HeadscaleService.ListPreAuthKeys:output_type -> headscale.v1.ListPreAuthKeysResponse
|
||||||
30, // 30: headscale.v1.HeadscaleService.ExpirePreAuthKey:output_type -> headscale.v1.ExpirePreAuthKeyResponse
|
30, // 30: headscale.v1.HeadscaleService.DebugCreateMachine:output_type -> headscale.v1.DebugCreateMachineResponse
|
||||||
31, // 31: headscale.v1.HeadscaleService.ListPreAuthKeys:output_type -> headscale.v1.ListPreAuthKeysResponse
|
31, // 31: headscale.v1.HeadscaleService.GetMachine:output_type -> headscale.v1.GetMachineResponse
|
||||||
32, // 32: headscale.v1.HeadscaleService.DebugCreateMachine:output_type -> headscale.v1.DebugCreateMachineResponse
|
32, // 32: headscale.v1.HeadscaleService.SetTags:output_type -> headscale.v1.SetTagsResponse
|
||||||
33, // 33: headscale.v1.HeadscaleService.GetMachine:output_type -> headscale.v1.GetMachineResponse
|
33, // 33: headscale.v1.HeadscaleService.RegisterMachine:output_type -> headscale.v1.RegisterMachineResponse
|
||||||
34, // 34: headscale.v1.HeadscaleService.SetTags:output_type -> headscale.v1.SetTagsResponse
|
34, // 34: headscale.v1.HeadscaleService.DeleteMachine:output_type -> headscale.v1.DeleteMachineResponse
|
||||||
35, // 35: headscale.v1.HeadscaleService.RegisterMachine:output_type -> headscale.v1.RegisterMachineResponse
|
35, // 35: headscale.v1.HeadscaleService.ExpireMachine:output_type -> headscale.v1.ExpireMachineResponse
|
||||||
36, // 36: headscale.v1.HeadscaleService.DeleteMachine:output_type -> headscale.v1.DeleteMachineResponse
|
36, // 36: headscale.v1.HeadscaleService.RenameMachine:output_type -> headscale.v1.RenameMachineResponse
|
||||||
37, // 37: headscale.v1.HeadscaleService.ExpireMachine:output_type -> headscale.v1.ExpireMachineResponse
|
37, // 37: headscale.v1.HeadscaleService.ListMachines:output_type -> headscale.v1.ListMachinesResponse
|
||||||
38, // 38: headscale.v1.HeadscaleService.RenameMachine:output_type -> headscale.v1.RenameMachineResponse
|
38, // 38: headscale.v1.HeadscaleService.MoveMachine:output_type -> headscale.v1.MoveMachineResponse
|
||||||
39, // 39: headscale.v1.HeadscaleService.ListMachines:output_type -> headscale.v1.ListMachinesResponse
|
39, // 39: headscale.v1.HeadscaleService.GetMachineRoute:output_type -> headscale.v1.GetMachineRouteResponse
|
||||||
40, // 40: headscale.v1.HeadscaleService.MoveMachine:output_type -> headscale.v1.MoveMachineResponse
|
40, // 40: headscale.v1.HeadscaleService.EnableMachineRoutes:output_type -> headscale.v1.EnableMachineRoutesResponse
|
||||||
41, // 41: headscale.v1.HeadscaleService.GetRoutes:output_type -> headscale.v1.GetRoutesResponse
|
41, // 41: headscale.v1.HeadscaleService.CreateApiKey:output_type -> headscale.v1.CreateApiKeyResponse
|
||||||
42, // 42: headscale.v1.HeadscaleService.EnableRoute:output_type -> headscale.v1.EnableRouteResponse
|
42, // 42: headscale.v1.HeadscaleService.ExpireApiKey:output_type -> headscale.v1.ExpireApiKeyResponse
|
||||||
43, // 43: headscale.v1.HeadscaleService.DisableRoute:output_type -> headscale.v1.DisableRouteResponse
|
43, // 43: headscale.v1.HeadscaleService.ListApiKeys:output_type -> headscale.v1.ListApiKeysResponse
|
||||||
44, // 44: headscale.v1.HeadscaleService.GetMachineRoutes:output_type -> headscale.v1.GetMachineRoutesResponse
|
22, // [22:44] is the sub-list for method output_type
|
||||||
45, // 45: headscale.v1.HeadscaleService.CreateApiKey:output_type -> headscale.v1.CreateApiKeyResponse
|
0, // [0:22] is the sub-list for method input_type
|
||||||
46, // 46: headscale.v1.HeadscaleService.ExpireApiKey:output_type -> headscale.v1.ExpireApiKeyResponse
|
|
||||||
47, // 47: headscale.v1.HeadscaleService.ListApiKeys:output_type -> headscale.v1.ListApiKeysResponse
|
|
||||||
24, // [24:48] is the sub-list for method output_type
|
|
||||||
0, // [0:24] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
0, // [0:0] is the sub-list for extension extendee
|
||||||
0, // [0:0] is the sub-list for field type_name
|
0, // [0:0] is the sub-list for field type_name
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -43,10 +43,8 @@ type HeadscaleServiceClient interface {
|
|||||||
ListMachines(ctx context.Context, in *ListMachinesRequest, opts ...grpc.CallOption) (*ListMachinesResponse, error)
|
ListMachines(ctx context.Context, in *ListMachinesRequest, opts ...grpc.CallOption) (*ListMachinesResponse, error)
|
||||||
MoveMachine(ctx context.Context, in *MoveMachineRequest, opts ...grpc.CallOption) (*MoveMachineResponse, error)
|
MoveMachine(ctx context.Context, in *MoveMachineRequest, opts ...grpc.CallOption) (*MoveMachineResponse, error)
|
||||||
// --- Route start ---
|
// --- Route start ---
|
||||||
GetRoutes(ctx context.Context, in *GetRoutesRequest, opts ...grpc.CallOption) (*GetRoutesResponse, error)
|
GetMachineRoute(ctx context.Context, in *GetMachineRouteRequest, opts ...grpc.CallOption) (*GetMachineRouteResponse, error)
|
||||||
EnableRoute(ctx context.Context, in *EnableRouteRequest, opts ...grpc.CallOption) (*EnableRouteResponse, error)
|
EnableMachineRoutes(ctx context.Context, in *EnableMachineRoutesRequest, opts ...grpc.CallOption) (*EnableMachineRoutesResponse, error)
|
||||||
DisableRoute(ctx context.Context, in *DisableRouteRequest, opts ...grpc.CallOption) (*DisableRouteResponse, error)
|
|
||||||
GetMachineRoutes(ctx context.Context, in *GetMachineRoutesRequest, opts ...grpc.CallOption) (*GetMachineRoutesResponse, error)
|
|
||||||
// --- ApiKeys start ---
|
// --- ApiKeys start ---
|
||||||
CreateApiKey(ctx context.Context, in *CreateApiKeyRequest, opts ...grpc.CallOption) (*CreateApiKeyResponse, error)
|
CreateApiKey(ctx context.Context, in *CreateApiKeyRequest, opts ...grpc.CallOption) (*CreateApiKeyResponse, error)
|
||||||
ExpireApiKey(ctx context.Context, in *ExpireApiKeyRequest, opts ...grpc.CallOption) (*ExpireApiKeyResponse, error)
|
ExpireApiKey(ctx context.Context, in *ExpireApiKeyRequest, opts ...grpc.CallOption) (*ExpireApiKeyResponse, error)
|
||||||
@@ -214,36 +212,18 @@ func (c *headscaleServiceClient) MoveMachine(ctx context.Context, in *MoveMachin
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *headscaleServiceClient) GetRoutes(ctx context.Context, in *GetRoutesRequest, opts ...grpc.CallOption) (*GetRoutesResponse, error) {
|
func (c *headscaleServiceClient) GetMachineRoute(ctx context.Context, in *GetMachineRouteRequest, opts ...grpc.CallOption) (*GetMachineRouteResponse, error) {
|
||||||
out := new(GetRoutesResponse)
|
out := new(GetMachineRouteResponse)
|
||||||
err := c.cc.Invoke(ctx, "/headscale.v1.HeadscaleService/GetRoutes", in, out, opts...)
|
err := c.cc.Invoke(ctx, "/headscale.v1.HeadscaleService/GetMachineRoute", in, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *headscaleServiceClient) EnableRoute(ctx context.Context, in *EnableRouteRequest, opts ...grpc.CallOption) (*EnableRouteResponse, error) {
|
func (c *headscaleServiceClient) EnableMachineRoutes(ctx context.Context, in *EnableMachineRoutesRequest, opts ...grpc.CallOption) (*EnableMachineRoutesResponse, error) {
|
||||||
out := new(EnableRouteResponse)
|
out := new(EnableMachineRoutesResponse)
|
||||||
err := c.cc.Invoke(ctx, "/headscale.v1.HeadscaleService/EnableRoute", in, out, opts...)
|
err := c.cc.Invoke(ctx, "/headscale.v1.HeadscaleService/EnableMachineRoutes", in, out, opts...)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *headscaleServiceClient) DisableRoute(ctx context.Context, in *DisableRouteRequest, opts ...grpc.CallOption) (*DisableRouteResponse, error) {
|
|
||||||
out := new(DisableRouteResponse)
|
|
||||||
err := c.cc.Invoke(ctx, "/headscale.v1.HeadscaleService/DisableRoute", in, out, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *headscaleServiceClient) GetMachineRoutes(ctx context.Context, in *GetMachineRoutesRequest, opts ...grpc.CallOption) (*GetMachineRoutesResponse, error) {
|
|
||||||
out := new(GetMachineRoutesResponse)
|
|
||||||
err := c.cc.Invoke(ctx, "/headscale.v1.HeadscaleService/GetMachineRoutes", in, out, opts...)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -302,10 +282,8 @@ type HeadscaleServiceServer interface {
|
|||||||
ListMachines(context.Context, *ListMachinesRequest) (*ListMachinesResponse, error)
|
ListMachines(context.Context, *ListMachinesRequest) (*ListMachinesResponse, error)
|
||||||
MoveMachine(context.Context, *MoveMachineRequest) (*MoveMachineResponse, error)
|
MoveMachine(context.Context, *MoveMachineRequest) (*MoveMachineResponse, error)
|
||||||
// --- Route start ---
|
// --- Route start ---
|
||||||
GetRoutes(context.Context, *GetRoutesRequest) (*GetRoutesResponse, error)
|
GetMachineRoute(context.Context, *GetMachineRouteRequest) (*GetMachineRouteResponse, error)
|
||||||
EnableRoute(context.Context, *EnableRouteRequest) (*EnableRouteResponse, error)
|
EnableMachineRoutes(context.Context, *EnableMachineRoutesRequest) (*EnableMachineRoutesResponse, error)
|
||||||
DisableRoute(context.Context, *DisableRouteRequest) (*DisableRouteResponse, error)
|
|
||||||
GetMachineRoutes(context.Context, *GetMachineRoutesRequest) (*GetMachineRoutesResponse, error)
|
|
||||||
// --- ApiKeys start ---
|
// --- ApiKeys start ---
|
||||||
CreateApiKey(context.Context, *CreateApiKeyRequest) (*CreateApiKeyResponse, error)
|
CreateApiKey(context.Context, *CreateApiKeyRequest) (*CreateApiKeyResponse, error)
|
||||||
ExpireApiKey(context.Context, *ExpireApiKeyRequest) (*ExpireApiKeyResponse, error)
|
ExpireApiKey(context.Context, *ExpireApiKeyRequest) (*ExpireApiKeyResponse, error)
|
||||||
@@ -368,17 +346,11 @@ func (UnimplementedHeadscaleServiceServer) ListMachines(context.Context, *ListMa
|
|||||||
func (UnimplementedHeadscaleServiceServer) MoveMachine(context.Context, *MoveMachineRequest) (*MoveMachineResponse, error) {
|
func (UnimplementedHeadscaleServiceServer) MoveMachine(context.Context, *MoveMachineRequest) (*MoveMachineResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method MoveMachine not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method MoveMachine not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedHeadscaleServiceServer) GetRoutes(context.Context, *GetRoutesRequest) (*GetRoutesResponse, error) {
|
func (UnimplementedHeadscaleServiceServer) GetMachineRoute(context.Context, *GetMachineRouteRequest) (*GetMachineRouteResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GetRoutes not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method GetMachineRoute not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedHeadscaleServiceServer) EnableRoute(context.Context, *EnableRouteRequest) (*EnableRouteResponse, error) {
|
func (UnimplementedHeadscaleServiceServer) EnableMachineRoutes(context.Context, *EnableMachineRoutesRequest) (*EnableMachineRoutesResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method EnableRoute not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method EnableMachineRoutes not implemented")
|
||||||
}
|
|
||||||
func (UnimplementedHeadscaleServiceServer) DisableRoute(context.Context, *DisableRouteRequest) (*DisableRouteResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method DisableRoute not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedHeadscaleServiceServer) GetMachineRoutes(context.Context, *GetMachineRoutesRequest) (*GetMachineRoutesResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GetMachineRoutes not implemented")
|
|
||||||
}
|
}
|
||||||
func (UnimplementedHeadscaleServiceServer) CreateApiKey(context.Context, *CreateApiKeyRequest) (*CreateApiKeyResponse, error) {
|
func (UnimplementedHeadscaleServiceServer) CreateApiKey(context.Context, *CreateApiKeyRequest) (*CreateApiKeyResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method CreateApiKey not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method CreateApiKey not implemented")
|
||||||
@@ -708,74 +680,38 @@ func _HeadscaleService_MoveMachine_Handler(srv interface{}, ctx context.Context,
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _HeadscaleService_GetRoutes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _HeadscaleService_GetMachineRoute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(GetRoutesRequest)
|
in := new(GetMachineRouteRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if interceptor == nil {
|
if interceptor == nil {
|
||||||
return srv.(HeadscaleServiceServer).GetRoutes(ctx, in)
|
return srv.(HeadscaleServiceServer).GetMachineRoute(ctx, in)
|
||||||
}
|
}
|
||||||
info := &grpc.UnaryServerInfo{
|
info := &grpc.UnaryServerInfo{
|
||||||
Server: srv,
|
Server: srv,
|
||||||
FullMethod: "/headscale.v1.HeadscaleService/GetRoutes",
|
FullMethod: "/headscale.v1.HeadscaleService/GetMachineRoute",
|
||||||
}
|
}
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return srv.(HeadscaleServiceServer).GetRoutes(ctx, req.(*GetRoutesRequest))
|
return srv.(HeadscaleServiceServer).GetMachineRoute(ctx, req.(*GetMachineRouteRequest))
|
||||||
}
|
}
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _HeadscaleService_EnableRoute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _HeadscaleService_EnableMachineRoutes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(EnableRouteRequest)
|
in := new(EnableMachineRoutesRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if interceptor == nil {
|
if interceptor == nil {
|
||||||
return srv.(HeadscaleServiceServer).EnableRoute(ctx, in)
|
return srv.(HeadscaleServiceServer).EnableMachineRoutes(ctx, in)
|
||||||
}
|
}
|
||||||
info := &grpc.UnaryServerInfo{
|
info := &grpc.UnaryServerInfo{
|
||||||
Server: srv,
|
Server: srv,
|
||||||
FullMethod: "/headscale.v1.HeadscaleService/EnableRoute",
|
FullMethod: "/headscale.v1.HeadscaleService/EnableMachineRoutes",
|
||||||
}
|
}
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return srv.(HeadscaleServiceServer).EnableRoute(ctx, req.(*EnableRouteRequest))
|
return srv.(HeadscaleServiceServer).EnableMachineRoutes(ctx, req.(*EnableMachineRoutesRequest))
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _HeadscaleService_DisableRoute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(DisableRouteRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(HeadscaleServiceServer).DisableRoute(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: "/headscale.v1.HeadscaleService/DisableRoute",
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(HeadscaleServiceServer).DisableRoute(ctx, req.(*DisableRouteRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _HeadscaleService_GetMachineRoutes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(GetMachineRoutesRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(HeadscaleServiceServer).GetMachineRoutes(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: "/headscale.v1.HeadscaleService/GetMachineRoutes",
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(HeadscaleServiceServer).GetMachineRoutes(ctx, req.(*GetMachineRoutesRequest))
|
|
||||||
}
|
}
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
@@ -910,20 +846,12 @@ var HeadscaleService_ServiceDesc = grpc.ServiceDesc{
|
|||||||
Handler: _HeadscaleService_MoveMachine_Handler,
|
Handler: _HeadscaleService_MoveMachine_Handler,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MethodName: "GetRoutes",
|
MethodName: "GetMachineRoute",
|
||||||
Handler: _HeadscaleService_GetRoutes_Handler,
|
Handler: _HeadscaleService_GetMachineRoute_Handler,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MethodName: "EnableRoute",
|
MethodName: "EnableMachineRoutes",
|
||||||
Handler: _HeadscaleService_EnableRoute_Handler,
|
Handler: _HeadscaleService_EnableMachineRoutes_Handler,
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "DisableRoute",
|
|
||||||
Handler: _HeadscaleService_DisableRoute_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "GetMachineRoutes",
|
|
||||||
Handler: _HeadscaleService_GetMachineRoutes_Handler,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MethodName: "CreateApiKey",
|
MethodName: "CreateApiKey",
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ package v1
|
|||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
)
|
)
|
||||||
@@ -21,24 +20,17 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
)
|
)
|
||||||
|
|
||||||
type Route struct {
|
type Routes struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
AdvertisedRoutes []string `protobuf:"bytes,1,rep,name=advertised_routes,json=advertisedRoutes,proto3" json:"advertised_routes,omitempty"`
|
||||||
Machine *Machine `protobuf:"bytes,2,opt,name=machine,proto3" json:"machine,omitempty"`
|
EnabledRoutes []string `protobuf:"bytes,2,rep,name=enabled_routes,json=enabledRoutes,proto3" json:"enabled_routes,omitempty"`
|
||||||
Prefix string `protobuf:"bytes,3,opt,name=prefix,proto3" json:"prefix,omitempty"`
|
|
||||||
Advertised bool `protobuf:"varint,4,opt,name=advertised,proto3" json:"advertised,omitempty"`
|
|
||||||
Enabled bool `protobuf:"varint,5,opt,name=enabled,proto3" json:"enabled,omitempty"`
|
|
||||||
IsPrimary bool `protobuf:"varint,6,opt,name=is_primary,json=isPrimary,proto3" json:"is_primary,omitempty"`
|
|
||||||
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
|
|
||||||
UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
|
|
||||||
DeletedAt *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=deleted_at,json=deletedAt,proto3" json:"deleted_at,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Route) Reset() {
|
func (x *Routes) Reset() {
|
||||||
*x = Route{}
|
*x = Routes{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[0]
|
mi := &file_headscale_v1_routes_proto_msgTypes[0]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -46,13 +38,13 @@ func (x *Route) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Route) String() string {
|
func (x *Routes) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Route) ProtoMessage() {}
|
func (*Routes) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *Route) ProtoReflect() protoreflect.Message {
|
func (x *Routes) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[0]
|
mi := &file_headscale_v1_routes_proto_msgTypes[0]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -64,82 +56,35 @@ func (x *Route) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use Route.ProtoReflect.Descriptor instead.
|
// Deprecated: Use Routes.ProtoReflect.Descriptor instead.
|
||||||
func (*Route) Descriptor() ([]byte, []int) {
|
func (*Routes) Descriptor() ([]byte, []int) {
|
||||||
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{0}
|
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Route) GetId() uint64 {
|
func (x *Routes) GetAdvertisedRoutes() []string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Id
|
return x.AdvertisedRoutes
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Route) GetMachine() *Machine {
|
|
||||||
if x != nil {
|
|
||||||
return x.Machine
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Route) GetPrefix() string {
|
func (x *Routes) GetEnabledRoutes() []string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Prefix
|
return x.EnabledRoutes
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Route) GetAdvertised() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Advertised
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Route) GetEnabled() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Enabled
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Route) GetIsPrimary() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.IsPrimary
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Route) GetCreatedAt() *timestamppb.Timestamp {
|
|
||||||
if x != nil {
|
|
||||||
return x.CreatedAt
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Route) GetUpdatedAt() *timestamppb.Timestamp {
|
type GetMachineRouteRequest struct {
|
||||||
if x != nil {
|
|
||||||
return x.UpdatedAt
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Route) GetDeletedAt() *timestamppb.Timestamp {
|
|
||||||
if x != nil {
|
|
||||||
return x.DeletedAt
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetRoutesRequest struct {
|
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
MachineId uint64 `protobuf:"varint,1,opt,name=machine_id,json=machineId,proto3" json:"machine_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GetRoutesRequest) Reset() {
|
func (x *GetMachineRouteRequest) Reset() {
|
||||||
*x = GetRoutesRequest{}
|
*x = GetMachineRouteRequest{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[1]
|
mi := &file_headscale_v1_routes_proto_msgTypes[1]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -147,13 +92,13 @@ func (x *GetRoutesRequest) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GetRoutesRequest) String() string {
|
func (x *GetMachineRouteRequest) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*GetRoutesRequest) ProtoMessage() {}
|
func (*GetMachineRouteRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *GetRoutesRequest) ProtoReflect() protoreflect.Message {
|
func (x *GetMachineRouteRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[1]
|
mi := &file_headscale_v1_routes_proto_msgTypes[1]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -165,21 +110,28 @@ func (x *GetRoutesRequest) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use GetRoutesRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use GetMachineRouteRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*GetRoutesRequest) Descriptor() ([]byte, []int) {
|
func (*GetMachineRouteRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{1}
|
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetRoutesResponse struct {
|
func (x *GetMachineRouteRequest) GetMachineId() uint64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.MachineId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetMachineRouteResponse struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Routes []*Route `protobuf:"bytes,1,rep,name=routes,proto3" json:"routes,omitempty"`
|
Routes *Routes `protobuf:"bytes,1,opt,name=routes,proto3" json:"routes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GetRoutesResponse) Reset() {
|
func (x *GetMachineRouteResponse) Reset() {
|
||||||
*x = GetRoutesResponse{}
|
*x = GetMachineRouteResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[2]
|
mi := &file_headscale_v1_routes_proto_msgTypes[2]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -187,13 +139,13 @@ func (x *GetRoutesResponse) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GetRoutesResponse) String() string {
|
func (x *GetMachineRouteResponse) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*GetRoutesResponse) ProtoMessage() {}
|
func (*GetMachineRouteResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *GetRoutesResponse) ProtoReflect() protoreflect.Message {
|
func (x *GetMachineRouteResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[2]
|
mi := &file_headscale_v1_routes_proto_msgTypes[2]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -205,28 +157,29 @@ func (x *GetRoutesResponse) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use GetRoutesResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use GetMachineRouteResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*GetRoutesResponse) Descriptor() ([]byte, []int) {
|
func (*GetMachineRouteResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{2}
|
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GetRoutesResponse) GetRoutes() []*Route {
|
func (x *GetMachineRouteResponse) GetRoutes() *Routes {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Routes
|
return x.Routes
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type EnableRouteRequest struct {
|
type EnableMachineRoutesRequest struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
RouteId uint64 `protobuf:"varint,1,opt,name=route_id,json=routeId,proto3" json:"route_id,omitempty"`
|
MachineId uint64 `protobuf:"varint,1,opt,name=machine_id,json=machineId,proto3" json:"machine_id,omitempty"`
|
||||||
|
Routes []string `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *EnableRouteRequest) Reset() {
|
func (x *EnableMachineRoutesRequest) Reset() {
|
||||||
*x = EnableRouteRequest{}
|
*x = EnableMachineRoutesRequest{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[3]
|
mi := &file_headscale_v1_routes_proto_msgTypes[3]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -234,13 +187,13 @@ func (x *EnableRouteRequest) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *EnableRouteRequest) String() string {
|
func (x *EnableMachineRoutesRequest) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*EnableRouteRequest) ProtoMessage() {}
|
func (*EnableMachineRoutesRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *EnableRouteRequest) ProtoReflect() protoreflect.Message {
|
func (x *EnableMachineRoutesRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[3]
|
mi := &file_headscale_v1_routes_proto_msgTypes[3]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -252,26 +205,35 @@ func (x *EnableRouteRequest) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use EnableRouteRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use EnableMachineRoutesRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*EnableRouteRequest) Descriptor() ([]byte, []int) {
|
func (*EnableMachineRoutesRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{3}
|
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *EnableRouteRequest) GetRouteId() uint64 {
|
func (x *EnableMachineRoutesRequest) GetMachineId() uint64 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.RouteId
|
return x.MachineId
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
type EnableRouteResponse struct {
|
func (x *EnableMachineRoutesRequest) GetRoutes() []string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Routes
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnableMachineRoutesResponse struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Routes *Routes `protobuf:"bytes,1,opt,name=routes,proto3" json:"routes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *EnableRouteResponse) Reset() {
|
func (x *EnableMachineRoutesResponse) Reset() {
|
||||||
*x = EnableRouteResponse{}
|
*x = EnableMachineRoutesResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[4]
|
mi := &file_headscale_v1_routes_proto_msgTypes[4]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -279,13 +241,13 @@ func (x *EnableRouteResponse) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *EnableRouteResponse) String() string {
|
func (x *EnableMachineRoutesResponse) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*EnableRouteResponse) ProtoMessage() {}
|
func (*EnableMachineRoutesResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *EnableRouteResponse) ProtoReflect() protoreflect.Message {
|
func (x *EnableMachineRoutesResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[4]
|
mi := &file_headscale_v1_routes_proto_msgTypes[4]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@@ -297,184 +259,12 @@ func (x *EnableRouteResponse) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use EnableRouteResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use EnableMachineRoutesResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*EnableRouteResponse) Descriptor() ([]byte, []int) {
|
func (*EnableMachineRoutesResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{4}
|
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{4}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DisableRouteRequest struct {
|
func (x *EnableMachineRoutesResponse) GetRoutes() *Routes {
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
RouteId uint64 `protobuf:"varint,1,opt,name=route_id,json=routeId,proto3" json:"route_id,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DisableRouteRequest) Reset() {
|
|
||||||
*x = DisableRouteRequest{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[5]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DisableRouteRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*DisableRouteRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *DisableRouteRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[5]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use DisableRouteRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*DisableRouteRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{5}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DisableRouteRequest) GetRouteId() uint64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.RouteId
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type DisableRouteResponse struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DisableRouteResponse) Reset() {
|
|
||||||
*x = DisableRouteResponse{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[6]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DisableRouteResponse) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*DisableRouteResponse) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *DisableRouteResponse) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[6]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use DisableRouteResponse.ProtoReflect.Descriptor instead.
|
|
||||||
func (*DisableRouteResponse) Descriptor() ([]byte, []int) {
|
|
||||||
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{6}
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetMachineRoutesRequest struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
MachineId uint64 `protobuf:"varint,1,opt,name=machine_id,json=machineId,proto3" json:"machine_id,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetMachineRoutesRequest) Reset() {
|
|
||||||
*x = GetMachineRoutesRequest{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[7]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetMachineRoutesRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*GetMachineRoutesRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *GetMachineRoutesRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[7]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use GetMachineRoutesRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*GetMachineRoutesRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{7}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetMachineRoutesRequest) GetMachineId() uint64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.MachineId
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetMachineRoutesResponse struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Routes []*Route `protobuf:"bytes,1,rep,name=routes,proto3" json:"routes,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetMachineRoutesResponse) Reset() {
|
|
||||||
*x = GetMachineRoutesResponse{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[8]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetMachineRoutesResponse) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*GetMachineRoutesResponse) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *GetMachineRoutesResponse) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_headscale_v1_routes_proto_msgTypes[8]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use GetMachineRoutesResponse.ProtoReflect.Descriptor instead.
|
|
||||||
func (*GetMachineRoutesResponse) Descriptor() ([]byte, []int) {
|
|
||||||
return file_headscale_v1_routes_proto_rawDescGZIP(), []int{8}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *GetMachineRoutesResponse) GetRoutes() []*Route {
|
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Routes
|
return x.Routes
|
||||||
}
|
}
|
||||||
@@ -486,60 +276,34 @@ var File_headscale_v1_routes_proto protoreflect.FileDescriptor
|
|||||||
var file_headscale_v1_routes_proto_rawDesc = []byte{
|
var file_headscale_v1_routes_proto_rawDesc = []byte{
|
||||||
0x0a, 0x19, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x72,
|
0x0a, 0x19, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x72,
|
||||||
0x6f, 0x75, 0x74, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x68, 0x65, 0x61,
|
0x6f, 0x75, 0x74, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x68, 0x65, 0x61,
|
||||||
0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x22, 0x5c, 0x0a, 0x06, 0x52, 0x6f, 0x75,
|
||||||
0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73,
|
0x74, 0x65, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65,
|
||||||
0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x68, 0x65, 0x61, 0x64,
|
0x64, 0x5f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10,
|
||||||
0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65,
|
0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73,
|
||||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xea, 0x02, 0x0a, 0x05, 0x52, 0x6f, 0x75, 0x74, 0x65,
|
0x12, 0x25, 0x0a, 0x0e, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x5f, 0x72, 0x6f, 0x75, 0x74,
|
||||||
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64,
|
0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65,
|
||||||
0x12, 0x2f, 0x0a, 0x07, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
0x64, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x22, 0x37, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4d, 0x61,
|
||||||
0x0b, 0x32, 0x15, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31,
|
0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||||
0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x07, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e,
|
0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18,
|
||||||
0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28,
|
0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x64,
|
||||||
0x09, 0x52, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x64, 0x76,
|
0x22, 0x47, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f,
|
||||||
0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x61,
|
0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x72,
|
||||||
0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61,
|
0x6f, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x68, 0x65,
|
||||||
0x62, 0x6c, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62,
|
0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65,
|
||||||
0x6c, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72,
|
0x73, 0x52, 0x06, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x22, 0x53, 0x0a, 0x1a, 0x45, 0x6e, 0x61,
|
||||||
0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x50, 0x72, 0x69, 0x6d, 0x61,
|
0x62, 0x6c, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73,
|
||||||
0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74,
|
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x61, 0x63, 0x68, 0x69,
|
||||||
0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6d, 0x61, 0x63,
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
|
0x68, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73,
|
||||||
0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a,
|
0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x22, 0x4b,
|
||||||
0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28,
|
0x0a, 0x1b, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52,
|
||||||
0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x6f, 0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a,
|
||||||
0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75,
|
0x06, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
|
||||||
0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x64, 0x65, 0x6c, 0x65,
|
0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x6f, 0x75,
|
||||||
0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67,
|
0x74, 0x65, 0x73, 0x52, 0x06, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x42, 0x29, 0x5a, 0x27, 0x67,
|
||||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54,
|
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6a, 0x75, 0x61, 0x6e, 0x66, 0x6f,
|
||||||
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65,
|
0x6e, 0x74, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x67, 0x65, 0x6e,
|
||||||
0x64, 0x41, 0x74, 0x22, 0x12, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73,
|
0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x40, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x52, 0x6f,
|
|
||||||
0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x06,
|
|
||||||
0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x68,
|
|
||||||
0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x6f, 0x75, 0x74,
|
|
||||||
0x65, 0x52, 0x06, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x22, 0x2f, 0x0a, 0x12, 0x45, 0x6e, 0x61,
|
|
||||||
0x62, 0x6c, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
|
||||||
0x19, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
|
||||||
0x04, 0x52, 0x07, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x49, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x45, 0x6e,
|
|
||||||
0x61, 0x62, 0x6c, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
|
||||||
0x65, 0x22, 0x30, 0x0a, 0x13, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x6f, 0x75, 0x74,
|
|
||||||
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x74,
|
|
||||||
0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x72, 0x6f, 0x75, 0x74,
|
|
||||||
0x65, 0x49, 0x64, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x6f,
|
|
||||||
0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x38, 0x0a, 0x17, 0x47,
|
|
||||||
0x65, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x52,
|
|
||||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e,
|
|
||||||
0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6d, 0x61, 0x63, 0x68,
|
|
||||||
0x69, 0x6e, 0x65, 0x49, 0x64, 0x22, 0x47, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x63, 0x68,
|
|
||||||
0x69, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
|
||||||
0x65, 0x12, 0x2b, 0x0a, 0x06, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
|
|
||||||
0x0b, 0x32, 0x13, 0x2e, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2e, 0x76, 0x31,
|
|
||||||
0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x06, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x73, 0x42, 0x29,
|
|
||||||
0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6a, 0x75, 0x61,
|
|
||||||
0x6e, 0x66, 0x6f, 0x6e, 0x74, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f,
|
|
||||||
0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
|
||||||
0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -554,32 +318,22 @@ func file_headscale_v1_routes_proto_rawDescGZIP() []byte {
|
|||||||
return file_headscale_v1_routes_proto_rawDescData
|
return file_headscale_v1_routes_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_headscale_v1_routes_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
var file_headscale_v1_routes_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||||
var file_headscale_v1_routes_proto_goTypes = []interface{}{
|
var file_headscale_v1_routes_proto_goTypes = []interface{}{
|
||||||
(*Route)(nil), // 0: headscale.v1.Route
|
(*Routes)(nil), // 0: headscale.v1.Routes
|
||||||
(*GetRoutesRequest)(nil), // 1: headscale.v1.GetRoutesRequest
|
(*GetMachineRouteRequest)(nil), // 1: headscale.v1.GetMachineRouteRequest
|
||||||
(*GetRoutesResponse)(nil), // 2: headscale.v1.GetRoutesResponse
|
(*GetMachineRouteResponse)(nil), // 2: headscale.v1.GetMachineRouteResponse
|
||||||
(*EnableRouteRequest)(nil), // 3: headscale.v1.EnableRouteRequest
|
(*EnableMachineRoutesRequest)(nil), // 3: headscale.v1.EnableMachineRoutesRequest
|
||||||
(*EnableRouteResponse)(nil), // 4: headscale.v1.EnableRouteResponse
|
(*EnableMachineRoutesResponse)(nil), // 4: headscale.v1.EnableMachineRoutesResponse
|
||||||
(*DisableRouteRequest)(nil), // 5: headscale.v1.DisableRouteRequest
|
|
||||||
(*DisableRouteResponse)(nil), // 6: headscale.v1.DisableRouteResponse
|
|
||||||
(*GetMachineRoutesRequest)(nil), // 7: headscale.v1.GetMachineRoutesRequest
|
|
||||||
(*GetMachineRoutesResponse)(nil), // 8: headscale.v1.GetMachineRoutesResponse
|
|
||||||
(*Machine)(nil), // 9: headscale.v1.Machine
|
|
||||||
(*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp
|
|
||||||
}
|
}
|
||||||
var file_headscale_v1_routes_proto_depIdxs = []int32{
|
var file_headscale_v1_routes_proto_depIdxs = []int32{
|
||||||
9, // 0: headscale.v1.Route.machine:type_name -> headscale.v1.Machine
|
0, // 0: headscale.v1.GetMachineRouteResponse.routes:type_name -> headscale.v1.Routes
|
||||||
10, // 1: headscale.v1.Route.created_at:type_name -> google.protobuf.Timestamp
|
0, // 1: headscale.v1.EnableMachineRoutesResponse.routes:type_name -> headscale.v1.Routes
|
||||||
10, // 2: headscale.v1.Route.updated_at:type_name -> google.protobuf.Timestamp
|
2, // [2:2] is the sub-list for method output_type
|
||||||
10, // 3: headscale.v1.Route.deleted_at:type_name -> google.protobuf.Timestamp
|
2, // [2:2] is the sub-list for method input_type
|
||||||
0, // 4: headscale.v1.GetRoutesResponse.routes:type_name -> headscale.v1.Route
|
2, // [2:2] is the sub-list for extension type_name
|
||||||
0, // 5: headscale.v1.GetMachineRoutesResponse.routes:type_name -> headscale.v1.Route
|
2, // [2:2] is the sub-list for extension extendee
|
||||||
6, // [6:6] is the sub-list for method output_type
|
0, // [0:2] is the sub-list for field type_name
|
||||||
6, // [6:6] is the sub-list for method input_type
|
|
||||||
6, // [6:6] is the sub-list for extension type_name
|
|
||||||
6, // [6:6] is the sub-list for extension extendee
|
|
||||||
0, // [0:6] is the sub-list for field type_name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_headscale_v1_routes_proto_init() }
|
func init() { file_headscale_v1_routes_proto_init() }
|
||||||
@@ -587,10 +341,9 @@ func file_headscale_v1_routes_proto_init() {
|
|||||||
if File_headscale_v1_routes_proto != nil {
|
if File_headscale_v1_routes_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
file_headscale_v1_machine_proto_init()
|
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_headscale_v1_routes_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
file_headscale_v1_routes_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*Route); i {
|
switch v := v.(*Routes); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@@ -602,7 +355,7 @@ func file_headscale_v1_routes_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_headscale_v1_routes_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
file_headscale_v1_routes_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*GetRoutesRequest); i {
|
switch v := v.(*GetMachineRouteRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@@ -614,7 +367,7 @@ func file_headscale_v1_routes_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_headscale_v1_routes_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
file_headscale_v1_routes_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*GetRoutesResponse); i {
|
switch v := v.(*GetMachineRouteResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@@ -626,7 +379,7 @@ func file_headscale_v1_routes_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_headscale_v1_routes_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
file_headscale_v1_routes_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*EnableRouteRequest); i {
|
switch v := v.(*EnableMachineRoutesRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@@ -638,55 +391,7 @@ func file_headscale_v1_routes_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_headscale_v1_routes_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
file_headscale_v1_routes_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*EnableRouteResponse); i {
|
switch v := v.(*EnableMachineRoutesResponse); i {
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_headscale_v1_routes_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*DisableRouteRequest); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_headscale_v1_routes_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*DisableRouteResponse); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_headscale_v1_routes_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*GetMachineRoutesRequest); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_headscale_v1_routes_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*GetMachineRoutesResponse); i {
|
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@@ -704,7 +409,7 @@ func file_headscale_v1_routes_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_headscale_v1_routes_proto_rawDesc,
|
RawDescriptor: file_headscale_v1_routes_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 9,
|
NumMessages: 5,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -367,12 +367,13 @@
|
|||||||
},
|
},
|
||||||
"/api/v1/machine/{machineId}/routes": {
|
"/api/v1/machine/{machineId}/routes": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "HeadscaleService_GetMachineRoutes",
|
"summary": "--- Route start ---",
|
||||||
|
"operationId": "HeadscaleService_GetMachineRoute",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "A successful response.",
|
"description": "A successful response.",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/v1GetMachineRoutesResponse"
|
"$ref": "#/definitions/v1GetMachineRouteResponse"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"default": {
|
"default": {
|
||||||
@@ -394,6 +395,45 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
"HeadscaleService"
|
"HeadscaleService"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"operationId": "HeadscaleService_EnableMachineRoutes",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/v1EnableMachineRoutesResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"description": "An unexpected error response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/rpcStatus"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "machineId",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "routes",
|
||||||
|
"in": "query",
|
||||||
|
"required": false,
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"collectionFormat": "multi"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"HeadscaleService"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/api/v1/machine/{machineId}/tags": {
|
"/api/v1/machine/{machineId}/tags": {
|
||||||
@@ -682,91 +722,6 @@
|
|||||||
"HeadscaleService"
|
"HeadscaleService"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"/api/v1/routes": {
|
|
||||||
"get": {
|
|
||||||
"summary": "--- Route start ---",
|
|
||||||
"operationId": "HeadscaleService_GetRoutes",
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "A successful response.",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/v1GetRoutesResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"default": {
|
|
||||||
"description": "An unexpected error response.",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/rpcStatus"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"HeadscaleService"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/api/v1/routes/{routeId}/disable": {
|
|
||||||
"post": {
|
|
||||||
"operationId": "HeadscaleService_DisableRoute",
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "A successful response.",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/v1DisableRouteResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"default": {
|
|
||||||
"description": "An unexpected error response.",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/rpcStatus"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "routeId",
|
|
||||||
"in": "path",
|
|
||||||
"required": true,
|
|
||||||
"type": "string",
|
|
||||||
"format": "uint64"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"HeadscaleService"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/api/v1/routes/{routeId}/enable": {
|
|
||||||
"post": {
|
|
||||||
"operationId": "HeadscaleService_EnableRoute",
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "A successful response.",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/v1EnableRouteResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"default": {
|
|
||||||
"description": "An unexpected error response.",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/rpcStatus"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "routeId",
|
|
||||||
"in": "path",
|
|
||||||
"required": true,
|
|
||||||
"type": "string",
|
|
||||||
"format": "uint64"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"HeadscaleService"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
@@ -920,11 +875,13 @@
|
|||||||
"v1DeleteNamespaceResponse": {
|
"v1DeleteNamespaceResponse": {
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"v1DisableRouteResponse": {
|
"v1EnableMachineRoutesResponse": {
|
||||||
"type": "object"
|
"type": "object",
|
||||||
},
|
"properties": {
|
||||||
"v1EnableRouteResponse": {
|
"routes": {
|
||||||
"type": "object"
|
"$ref": "#/definitions/v1Routes"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"v1ExpireApiKeyRequest": {
|
"v1ExpireApiKeyRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -967,14 +924,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"v1GetMachineRoutesResponse": {
|
"v1GetMachineRouteResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"routes": {
|
"routes": {
|
||||||
"type": "array",
|
"$ref": "#/definitions/v1Routes"
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/v1Route"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -986,17 +940,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"v1GetRoutesResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"routes": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/v1Route"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"v1ListApiKeysResponse": {
|
"v1ListApiKeysResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -1208,39 +1151,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"v1Route": {
|
"v1Routes": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"advertisedRoutes": {
|
||||||
"type": "string",
|
"type": "array",
|
||||||
"format": "uint64"
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"machine": {
|
"enabledRoutes": {
|
||||||
"$ref": "#/definitions/v1Machine"
|
"type": "array",
|
||||||
},
|
"items": {
|
||||||
"prefix": {
|
"type": "string"
|
||||||
"type": "string"
|
}
|
||||||
},
|
|
||||||
"advertised": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"enabled": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"isPrimary": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"createdAt": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "date-time"
|
|
||||||
},
|
|
||||||
"updatedAt": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "date-time"
|
|
||||||
},
|
|
||||||
"deletedAt": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "date-time"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
65
grpcv1.go
65
grpcv1.go
@@ -364,60 +364,36 @@ func (api headscaleV1APIServer) MoveMachine(
|
|||||||
return &v1.MoveMachineResponse{Machine: machine.toProto()}, nil
|
return &v1.MoveMachineResponse{Machine: machine.toProto()}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api headscaleV1APIServer) GetRoutes(
|
func (api headscaleV1APIServer) GetMachineRoute(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
request *v1.GetRoutesRequest,
|
request *v1.GetMachineRouteRequest,
|
||||||
) (*v1.GetRoutesResponse, error) {
|
) (*v1.GetMachineRouteResponse, error) {
|
||||||
routes, err := api.h.GetRoutes()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &v1.GetRoutesResponse{
|
|
||||||
Routes: Routes(routes).toProto(),
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (api headscaleV1APIServer) EnableRoute(
|
|
||||||
ctx context.Context,
|
|
||||||
request *v1.EnableRouteRequest,
|
|
||||||
) (*v1.EnableRouteResponse, error) {
|
|
||||||
err := api.h.EnableRoute(request.GetRouteId())
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &v1.EnableRouteResponse{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (api headscaleV1APIServer) DisableRoute(
|
|
||||||
ctx context.Context,
|
|
||||||
request *v1.DisableRouteRequest,
|
|
||||||
) (*v1.DisableRouteResponse, error) {
|
|
||||||
err := api.h.DisableRoute(request.GetRouteId())
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &v1.DisableRouteResponse{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (api headscaleV1APIServer) GetMachineRoutes(
|
|
||||||
ctx context.Context,
|
|
||||||
request *v1.GetMachineRoutesRequest,
|
|
||||||
) (*v1.GetMachineRoutesResponse, error) {
|
|
||||||
machine, err := api.h.GetMachineByID(request.GetMachineId())
|
machine, err := api.h.GetMachineByID(request.GetMachineId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
routes, err := api.h.GetMachineRoutes(machine)
|
return &v1.GetMachineRouteResponse{
|
||||||
|
Routes: machine.RoutesToProto(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api headscaleV1APIServer) EnableMachineRoutes(
|
||||||
|
ctx context.Context,
|
||||||
|
request *v1.EnableMachineRoutesRequest,
|
||||||
|
) (*v1.EnableMachineRoutesResponse, error) {
|
||||||
|
machine, err := api.h.GetMachineByID(request.GetMachineId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &v1.GetMachineRoutesResponse{
|
err = api.h.EnableRoutes(machine, request.GetRoutes()...)
|
||||||
Routes: Routes(routes).toProto(),
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &v1.EnableMachineRoutesResponse{
|
||||||
|
Routes: machine.RoutesToProto(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,7 +497,6 @@ func (api headscaleV1APIServer) DebugCreateMachine(
|
|||||||
|
|
||||||
HostInfo: HostInfo(hostinfo),
|
HostInfo: HostInfo(hostinfo),
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeKey := key.NodePublic{}
|
nodeKey := key.NodePublic{}
|
||||||
err = nodeKey.UnmarshalText([]byte(request.GetKey()))
|
err = nodeKey.UnmarshalText([]byte(request.GetKey()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package integration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -391,144 +389,3 @@ func TestPreAuthKeyCommandReusableEphemeral(t *testing.T) {
|
|||||||
err = scenario.Shutdown()
|
err = scenario.Shutdown()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnablingRoutes(t *testing.T) {
|
|
||||||
IntegrationSkip(t)
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
namespace := "enable-routing"
|
|
||||||
|
|
||||||
scenario, err := NewScenario()
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
spec := map[string]int{
|
|
||||||
namespace: 3,
|
|
||||||
}
|
|
||||||
|
|
||||||
err = scenario.CreateHeadscaleEnv(spec, []tsic.Option{}, hsic.WithTestName("clienableroute"))
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
allClients, err := scenario.ListTailscaleClients()
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed to get clients: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = scenario.WaitForTailscaleSync()
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed wait for tailscale clients to be in sync: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
headscale, err := scenario.Headscale()
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
// advertise routes using the up command
|
|
||||||
for i, client := range allClients {
|
|
||||||
routeStr := fmt.Sprintf("10.0.%d.0/24", i)
|
|
||||||
hostname, _ := client.FQDN()
|
|
||||||
_, _, err = client.Execute([]string{
|
|
||||||
"tailscale",
|
|
||||||
"up",
|
|
||||||
fmt.Sprintf("--advertise-routes=%s", routeStr),
|
|
||||||
"-login-server", headscale.GetEndpoint(),
|
|
||||||
"--hostname", hostname,
|
|
||||||
})
|
|
||||||
assert.NoError(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = scenario.WaitForTailscaleSync()
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed wait for tailscale clients to be in sync: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var routes []*v1.Route
|
|
||||||
err = executeAndUnmarshal(
|
|
||||||
headscale,
|
|
||||||
[]string{
|
|
||||||
"headscale",
|
|
||||||
"routes",
|
|
||||||
"list",
|
|
||||||
"--output",
|
|
||||||
"json",
|
|
||||||
},
|
|
||||||
&routes,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.Len(t, routes, 3)
|
|
||||||
|
|
||||||
for _, route := range routes {
|
|
||||||
assert.Equal(t, route.Advertised, true)
|
|
||||||
assert.Equal(t, route.Enabled, false)
|
|
||||||
assert.Equal(t, route.IsPrimary, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, route := range routes {
|
|
||||||
_, err = headscale.Execute(
|
|
||||||
[]string{
|
|
||||||
"headscale",
|
|
||||||
"routes",
|
|
||||||
"enable",
|
|
||||||
"--route",
|
|
||||||
strconv.Itoa(int(route.Id)),
|
|
||||||
})
|
|
||||||
assert.NoError(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var enablingRoutes []*v1.Route
|
|
||||||
err = executeAndUnmarshal(
|
|
||||||
headscale,
|
|
||||||
[]string{
|
|
||||||
"headscale",
|
|
||||||
"routes",
|
|
||||||
"list",
|
|
||||||
"--output",
|
|
||||||
"json",
|
|
||||||
},
|
|
||||||
&enablingRoutes,
|
|
||||||
)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
for _, route := range enablingRoutes {
|
|
||||||
assert.Equal(t, route.Advertised, true)
|
|
||||||
assert.Equal(t, route.Enabled, true)
|
|
||||||
assert.Equal(t, route.IsPrimary, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
routeIDToBeDisabled := enablingRoutes[0].Id
|
|
||||||
|
|
||||||
_, err = headscale.Execute(
|
|
||||||
[]string{
|
|
||||||
"headscale",
|
|
||||||
"routes",
|
|
||||||
"disable",
|
|
||||||
"--route",
|
|
||||||
strconv.Itoa(int(routeIDToBeDisabled)),
|
|
||||||
})
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
var disablingRoutes []*v1.Route
|
|
||||||
err = executeAndUnmarshal(
|
|
||||||
headscale,
|
|
||||||
[]string{
|
|
||||||
"headscale",
|
|
||||||
"routes",
|
|
||||||
"list",
|
|
||||||
"--output",
|
|
||||||
"json",
|
|
||||||
},
|
|
||||||
&disablingRoutes,
|
|
||||||
)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
for _, route := range disablingRoutes {
|
|
||||||
assert.Equal(t, true, route.Advertised)
|
|
||||||
|
|
||||||
if route.Id == routeIDToBeDisabled {
|
|
||||||
assert.Equal(t, route.Enabled, false)
|
|
||||||
assert.Equal(t, route.IsPrimary, false)
|
|
||||||
} else {
|
|
||||||
assert.Equal(t, route.Enabled, true)
|
|
||||||
assert.Equal(t, route.IsPrimary, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1243,6 +1243,199 @@ func (s *IntegrationCLITestSuite) TestNodeRenameCommand() {
|
|||||||
assert.Contains(s.T(), listAllAfterRenameAttempt[4].GetGivenName(), "machine-5")
|
assert.Contains(s.T(), listAllAfterRenameAttempt[4].GetGivenName(), "machine-5")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *IntegrationCLITestSuite) TestRouteCommand() {
|
||||||
|
namespace, err := s.createNamespace("routes-namespace")
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
// Randomly generated machine keys
|
||||||
|
machineKey := "nodekey:9b2ffa7e08cc421a3d2cca9012280f6a236fd0de0b4ce005b30a98ad930306fe"
|
||||||
|
|
||||||
|
_, _, err = ExecuteCommand(
|
||||||
|
&s.headscale,
|
||||||
|
[]string{
|
||||||
|
"headscale",
|
||||||
|
"debug",
|
||||||
|
"create-node",
|
||||||
|
"--name",
|
||||||
|
"route-machine",
|
||||||
|
"--namespace",
|
||||||
|
namespace.Name,
|
||||||
|
"--key",
|
||||||
|
machineKey,
|
||||||
|
"--route",
|
||||||
|
"10.0.0.0/8",
|
||||||
|
"--route",
|
||||||
|
"192.168.1.0/24",
|
||||||
|
"--output",
|
||||||
|
"json",
|
||||||
|
},
|
||||||
|
[]string{},
|
||||||
|
)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
machineResult, _, err := ExecuteCommand(
|
||||||
|
&s.headscale,
|
||||||
|
[]string{
|
||||||
|
"headscale",
|
||||||
|
"nodes",
|
||||||
|
"--namespace",
|
||||||
|
namespace.Name,
|
||||||
|
"register",
|
||||||
|
"--key",
|
||||||
|
machineKey,
|
||||||
|
"--output",
|
||||||
|
"json",
|
||||||
|
},
|
||||||
|
[]string{},
|
||||||
|
)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
var machine v1.Machine
|
||||||
|
err = json.Unmarshal([]byte(machineResult), &machine)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
assert.Equal(s.T(), uint64(1), machine.Id)
|
||||||
|
assert.Equal(s.T(), "route-machine", machine.Name)
|
||||||
|
|
||||||
|
listAllResult, _, err := ExecuteCommand(
|
||||||
|
&s.headscale,
|
||||||
|
[]string{
|
||||||
|
"headscale",
|
||||||
|
"routes",
|
||||||
|
"list",
|
||||||
|
"--output",
|
||||||
|
"json",
|
||||||
|
"--identifier",
|
||||||
|
"0",
|
||||||
|
},
|
||||||
|
[]string{},
|
||||||
|
)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
var listAll v1.Routes
|
||||||
|
err = json.Unmarshal([]byte(listAllResult), &listAll)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
assert.Len(s.T(), listAll.AdvertisedRoutes, 2)
|
||||||
|
assert.Contains(s.T(), listAll.AdvertisedRoutes, "10.0.0.0/8")
|
||||||
|
assert.Contains(s.T(), listAll.AdvertisedRoutes, "192.168.1.0/24")
|
||||||
|
|
||||||
|
assert.Empty(s.T(), listAll.EnabledRoutes)
|
||||||
|
|
||||||
|
enableTwoRoutesResult, _, err := ExecuteCommand(
|
||||||
|
&s.headscale,
|
||||||
|
[]string{
|
||||||
|
"headscale",
|
||||||
|
"routes",
|
||||||
|
"enable",
|
||||||
|
"--output",
|
||||||
|
"json",
|
||||||
|
"--identifier",
|
||||||
|
"0",
|
||||||
|
"--route",
|
||||||
|
"10.0.0.0/8",
|
||||||
|
"--route",
|
||||||
|
"192.168.1.0/24",
|
||||||
|
},
|
||||||
|
[]string{},
|
||||||
|
)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
var enableTwoRoutes v1.Routes
|
||||||
|
err = json.Unmarshal([]byte(enableTwoRoutesResult), &enableTwoRoutes)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
assert.Len(s.T(), enableTwoRoutes.AdvertisedRoutes, 2)
|
||||||
|
assert.Contains(s.T(), enableTwoRoutes.AdvertisedRoutes, "10.0.0.0/8")
|
||||||
|
assert.Contains(s.T(), enableTwoRoutes.AdvertisedRoutes, "192.168.1.0/24")
|
||||||
|
|
||||||
|
assert.Len(s.T(), enableTwoRoutes.EnabledRoutes, 2)
|
||||||
|
assert.Contains(s.T(), enableTwoRoutes.EnabledRoutes, "10.0.0.0/8")
|
||||||
|
assert.Contains(s.T(), enableTwoRoutes.EnabledRoutes, "192.168.1.0/24")
|
||||||
|
|
||||||
|
// Enable only one route, effectively disabling one of the routes
|
||||||
|
enableOneRouteResult, _, err := ExecuteCommand(
|
||||||
|
&s.headscale,
|
||||||
|
[]string{
|
||||||
|
"headscale",
|
||||||
|
"routes",
|
||||||
|
"enable",
|
||||||
|
"--output",
|
||||||
|
"json",
|
||||||
|
"--identifier",
|
||||||
|
"0",
|
||||||
|
"--route",
|
||||||
|
"10.0.0.0/8",
|
||||||
|
},
|
||||||
|
[]string{},
|
||||||
|
)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
var enableOneRoute v1.Routes
|
||||||
|
err = json.Unmarshal([]byte(enableOneRouteResult), &enableOneRoute)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
assert.Len(s.T(), enableOneRoute.AdvertisedRoutes, 2)
|
||||||
|
assert.Contains(s.T(), enableOneRoute.AdvertisedRoutes, "10.0.0.0/8")
|
||||||
|
assert.Contains(s.T(), enableOneRoute.AdvertisedRoutes, "192.168.1.0/24")
|
||||||
|
|
||||||
|
assert.Len(s.T(), enableOneRoute.EnabledRoutes, 1)
|
||||||
|
assert.Contains(s.T(), enableOneRoute.EnabledRoutes, "10.0.0.0/8")
|
||||||
|
|
||||||
|
// Enable only one route, effectively disabling one of the routes
|
||||||
|
failEnableNonAdvertisedRoute, _, err := ExecuteCommand(
|
||||||
|
&s.headscale,
|
||||||
|
[]string{
|
||||||
|
"headscale",
|
||||||
|
"routes",
|
||||||
|
"enable",
|
||||||
|
"--output",
|
||||||
|
"json",
|
||||||
|
"--identifier",
|
||||||
|
"0",
|
||||||
|
"--route",
|
||||||
|
"11.0.0.0/8",
|
||||||
|
},
|
||||||
|
[]string{},
|
||||||
|
)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
assert.Contains(
|
||||||
|
s.T(),
|
||||||
|
string(failEnableNonAdvertisedRoute),
|
||||||
|
"route (route-machine) is not available on node",
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enable all routes on host
|
||||||
|
enableAllRouteResult, _, err := ExecuteCommand(
|
||||||
|
&s.headscale,
|
||||||
|
[]string{
|
||||||
|
"headscale",
|
||||||
|
"routes",
|
||||||
|
"enable",
|
||||||
|
"--output",
|
||||||
|
"json",
|
||||||
|
"--identifier",
|
||||||
|
"0",
|
||||||
|
"--all",
|
||||||
|
},
|
||||||
|
[]string{},
|
||||||
|
)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
var enableAllRoute v1.Routes
|
||||||
|
err = json.Unmarshal([]byte(enableAllRouteResult), &enableAllRoute)
|
||||||
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
|
assert.Len(s.T(), enableAllRoute.AdvertisedRoutes, 2)
|
||||||
|
assert.Contains(s.T(), enableAllRoute.AdvertisedRoutes, "10.0.0.0/8")
|
||||||
|
assert.Contains(s.T(), enableAllRoute.AdvertisedRoutes, "192.168.1.0/24")
|
||||||
|
|
||||||
|
assert.Len(s.T(), enableAllRoute.EnabledRoutes, 2)
|
||||||
|
assert.Contains(s.T(), enableAllRoute.EnabledRoutes, "10.0.0.0/8")
|
||||||
|
assert.Contains(s.T(), enableAllRoute.EnabledRoutes, "192.168.1.0/24")
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationCLITestSuite) TestApiKeyCommand() {
|
func (s *IntegrationCLITestSuite) TestApiKeyCommand() {
|
||||||
count := 5
|
count := 5
|
||||||
|
|
||||||
|
|||||||
218
machine.go
218
machine.go
@@ -13,7 +13,6 @@ import (
|
|||||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
"gorm.io/gorm"
|
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
)
|
)
|
||||||
@@ -38,6 +37,11 @@ const (
|
|||||||
maxHostnameLength = 255
|
maxHostnameLength = 255
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ExitRouteV4 = netip.MustParsePrefix("0.0.0.0/0")
|
||||||
|
ExitRouteV6 = netip.MustParsePrefix("::/0")
|
||||||
|
)
|
||||||
|
|
||||||
// Machine is a Headscale client.
|
// Machine is a Headscale client.
|
||||||
type Machine struct {
|
type Machine struct {
|
||||||
ID uint64 `gorm:"primary_key"`
|
ID uint64 `gorm:"primary_key"`
|
||||||
@@ -72,8 +76,9 @@ type Machine struct {
|
|||||||
LastSuccessfulUpdate *time.Time
|
LastSuccessfulUpdate *time.Time
|
||||||
Expiry *time.Time
|
Expiry *time.Time
|
||||||
|
|
||||||
HostInfo HostInfo
|
HostInfo HostInfo
|
||||||
Endpoints StringList
|
Endpoints StringList
|
||||||
|
EnabledRoutes IPPrefixes
|
||||||
|
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
@@ -138,17 +143,6 @@ func (machine Machine) isExpired() bool {
|
|||||||
return time.Now().UTC().After(*machine.Expiry)
|
return time.Now().UTC().After(*machine.Expiry)
|
||||||
}
|
}
|
||||||
|
|
||||||
// isOnline returns if the machine is connected to Headscale.
|
|
||||||
// This is really a naive implementation, as we don't really see
|
|
||||||
// if there is a working connection between the client and the server.
|
|
||||||
func (machine *Machine) isOnline() bool {
|
|
||||||
if machine.LastSeen == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return machine.LastSeen.After(time.Now().Add(-keepAliveInterval))
|
|
||||||
}
|
|
||||||
|
|
||||||
func containsAddresses(inputs []string, addrs []string) bool {
|
func containsAddresses(inputs []string, addrs []string) bool {
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
if contains(inputs, addr) {
|
if contains(inputs, addr) {
|
||||||
@@ -601,15 +595,14 @@ func (machines MachinesP) String() string {
|
|||||||
return fmt.Sprintf("[ %s ](%d)", strings.Join(temp, ", "), len(temp))
|
return fmt.Sprintf("[ %s ](%d)", strings.Join(temp, ", "), len(temp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) toNodes(
|
func (machines Machines) toNodes(
|
||||||
machines Machines,
|
|
||||||
baseDomain string,
|
baseDomain string,
|
||||||
dnsConfig *tailcfg.DNSConfig,
|
dnsConfig *tailcfg.DNSConfig,
|
||||||
) ([]*tailcfg.Node, error) {
|
) ([]*tailcfg.Node, error) {
|
||||||
nodes := make([]*tailcfg.Node, len(machines))
|
nodes := make([]*tailcfg.Node, len(machines))
|
||||||
|
|
||||||
for index, machine := range machines {
|
for index, machine := range machines {
|
||||||
node, err := h.toNode(machine, baseDomain, dnsConfig)
|
node, err := machine.toNode(baseDomain, dnsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -622,8 +615,7 @@ func (h *Headscale) toNodes(
|
|||||||
|
|
||||||
// toNode converts a Machine into a Tailscale Node. includeRoutes is false for shared nodes
|
// toNode converts a Machine into a Tailscale Node. includeRoutes is false for shared nodes
|
||||||
// as per the expected behaviour in the official SaaS.
|
// as per the expected behaviour in the official SaaS.
|
||||||
func (h *Headscale) toNode(
|
func (machine Machine) toNode(
|
||||||
machine Machine,
|
|
||||||
baseDomain string,
|
baseDomain string,
|
||||||
dnsConfig *tailcfg.DNSConfig,
|
dnsConfig *tailcfg.DNSConfig,
|
||||||
) (*tailcfg.Node, error) {
|
) (*tailcfg.Node, error) {
|
||||||
@@ -671,18 +663,23 @@ func (h *Headscale) toNode(
|
|||||||
[]netip.Prefix{},
|
[]netip.Prefix{},
|
||||||
addrs...) // we append the node own IP, as it is required by the clients
|
addrs...) // we append the node own IP, as it is required by the clients
|
||||||
|
|
||||||
enabledRoutes, err := h.GetEnabledRoutes(&machine)
|
allowedIPs = append(allowedIPs, machine.EnabledRoutes...)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
allowedIPs = append(allowedIPs, enabledRoutes...)
|
// TODO(kradalby): This is kind of a hack where we say that
|
||||||
|
// all the announced routes (except exit), is presented as primary
|
||||||
|
// routes. This might be problematic if two nodes expose the same route.
|
||||||
|
// This was added to address an issue where subnet routers stopped working
|
||||||
|
// when we only populated AllowedIPs.
|
||||||
|
primaryRoutes := []netip.Prefix{}
|
||||||
|
if len(machine.EnabledRoutes) > 0 {
|
||||||
|
for _, route := range machine.EnabledRoutes {
|
||||||
|
if route == ExitRouteV4 || route == ExitRouteV6 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
primaryRoutes, err := h.getMachinePrimaryRoutes(&machine)
|
primaryRoutes = append(primaryRoutes, route)
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
primaryPrefixes := Routes(primaryRoutes).toPrefixes()
|
|
||||||
|
|
||||||
var derp string
|
var derp string
|
||||||
if machine.HostInfo.NetInfo != nil {
|
if machine.HostInfo.NetInfo != nil {
|
||||||
@@ -719,7 +716,9 @@ func (h *Headscale) toNode(
|
|||||||
|
|
||||||
hostInfo := machine.GetHostInfo()
|
hostInfo := machine.GetHostInfo()
|
||||||
|
|
||||||
online := machine.isOnline()
|
// A node is Online if it is connected to the control server,
|
||||||
|
// and we now we update LastSeen every keepAliveInterval duration at least.
|
||||||
|
online := machine.LastSeen.After(time.Now().Add(-keepAliveInterval))
|
||||||
|
|
||||||
node := tailcfg.Node{
|
node := tailcfg.Node{
|
||||||
ID: tailcfg.NodeID(machine.ID), // this is the actual ID
|
ID: tailcfg.NodeID(machine.ID), // this is the actual ID
|
||||||
@@ -734,7 +733,7 @@ func (h *Headscale) toNode(
|
|||||||
DiscoKey: discoKey,
|
DiscoKey: discoKey,
|
||||||
Addresses: addrs,
|
Addresses: addrs,
|
||||||
AllowedIPs: allowedIPs,
|
AllowedIPs: allowedIPs,
|
||||||
PrimaryRoutes: primaryPrefixes,
|
PrimaryRoutes: primaryRoutes,
|
||||||
Endpoints: machine.Endpoints,
|
Endpoints: machine.Endpoints,
|
||||||
DERP: derp,
|
DERP: derp,
|
||||||
|
|
||||||
@@ -928,69 +927,21 @@ func (h *Headscale) RegisterMachine(machine Machine,
|
|||||||
return &machine, nil
|
return &machine, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAdvertisedRoutes returns the routes that are be advertised by the given machine.
|
func (machine *Machine) GetAdvertisedRoutes() []netip.Prefix {
|
||||||
func (h *Headscale) GetAdvertisedRoutes(machine *Machine) ([]netip.Prefix, error) {
|
return machine.HostInfo.RoutableIPs
|
||||||
routes := []Route{}
|
|
||||||
|
|
||||||
err := h.db.
|
|
||||||
Preload("Machine").
|
|
||||||
Where("machine_id = ? AND advertised = ?", machine.ID, true).Find(&routes).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
log.Error().
|
|
||||||
Caller().
|
|
||||||
Err(err).
|
|
||||||
Str("machine", machine.Hostname).
|
|
||||||
Msg("Could not get advertised routes for machine")
|
|
||||||
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
prefixes := []netip.Prefix{}
|
|
||||||
for _, route := range routes {
|
|
||||||
prefixes = append(prefixes, netip.Prefix(route.Prefix))
|
|
||||||
}
|
|
||||||
|
|
||||||
return prefixes, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetEnabledRoutes returns the routes that are enabled for the machine.
|
func (machine *Machine) GetEnabledRoutes() []netip.Prefix {
|
||||||
func (h *Headscale) GetEnabledRoutes(machine *Machine) ([]netip.Prefix, error) {
|
return machine.EnabledRoutes
|
||||||
routes := []Route{}
|
|
||||||
|
|
||||||
err := h.db.
|
|
||||||
Preload("Machine").
|
|
||||||
Where("machine_id = ? AND advertised = ? AND enabled = ?", machine.ID, true, true).
|
|
||||||
Find(&routes).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
log.Error().
|
|
||||||
Caller().
|
|
||||||
Err(err).
|
|
||||||
Str("machine", machine.Hostname).
|
|
||||||
Msg("Could not get enabled routes for machine")
|
|
||||||
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
prefixes := []netip.Prefix{}
|
|
||||||
for _, route := range routes {
|
|
||||||
prefixes = append(prefixes, netip.Prefix(route.Prefix))
|
|
||||||
}
|
|
||||||
|
|
||||||
return prefixes, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) IsRoutesEnabled(machine *Machine, routeStr string) bool {
|
func (machine *Machine) IsRoutesEnabled(routeStr string) bool {
|
||||||
route, err := netip.ParsePrefix(routeStr)
|
route, err := netip.ParsePrefix(routeStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
enabledRoutes, err := h.GetEnabledRoutes(machine)
|
enabledRoutes := machine.GetEnabledRoutes()
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Msg("Could not get enabled routes")
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, enabledRoute := range enabledRoutes {
|
for _, enabledRoute := range enabledRoutes {
|
||||||
if route == enabledRoute {
|
if route == enabledRoute {
|
||||||
@@ -1001,7 +952,8 @@ func (h *Headscale) IsRoutesEnabled(machine *Machine, routeStr string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnableRoutes enables new routes based on a list of new routes.
|
// EnableNodeRoute enables new routes based on a list of new routes. It will _replace_ the
|
||||||
|
// previous list of routes.
|
||||||
func (h *Headscale) EnableRoutes(machine *Machine, routeStrs ...string) error {
|
func (h *Headscale) EnableRoutes(machine *Machine, routeStrs ...string) error {
|
||||||
newRoutes := make([]netip.Prefix, len(routeStrs))
|
newRoutes := make([]netip.Prefix, len(routeStrs))
|
||||||
for index, routeStr := range routeStrs {
|
for index, routeStr := range routeStrs {
|
||||||
@@ -1013,13 +965,8 @@ func (h *Headscale) EnableRoutes(machine *Machine, routeStrs ...string) error {
|
|||||||
newRoutes[index] = route
|
newRoutes[index] = route
|
||||||
}
|
}
|
||||||
|
|
||||||
advertisedRoutes, err := h.GetAdvertisedRoutes(machine)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, newRoute := range newRoutes {
|
for _, newRoute := range newRoutes {
|
||||||
if !contains(advertisedRoutes, newRoute) {
|
if !contains(machine.GetAdvertisedRoutes(), newRoute) {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"route (%s) is not available on node %s: %w",
|
"route (%s) is not available on node %s: %w",
|
||||||
machine.Hostname,
|
machine.Hostname,
|
||||||
@@ -1028,77 +975,52 @@ func (h *Headscale) EnableRoutes(machine *Machine, routeStrs ...string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Separate loop so we don't leave things in a half-updated state
|
machine.EnabledRoutes = newRoutes
|
||||||
for _, prefix := range newRoutes {
|
|
||||||
route := Route{}
|
|
||||||
err := h.db.Preload("Machine").
|
|
||||||
Where("machine_id = ? AND prefix = ?", machine.ID, IPPrefix(prefix)).
|
|
||||||
First(&route).Error
|
|
||||||
if err == nil {
|
|
||||||
route.Enabled = true
|
|
||||||
|
|
||||||
// Mark already as primary if there is only this node offering this subnet
|
if err := h.db.Save(machine).Error; err != nil {
|
||||||
// (and is not an exit route)
|
return fmt.Errorf("failed enable routes for machine in the database: %w", err)
|
||||||
if !route.isExitRoute() {
|
|
||||||
route.IsPrimary = h.isUniquePrefix(route)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = h.db.Save(&route).Error
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to enable route: %w", err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return fmt.Errorf("failed to find route: %w", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnableAutoApprovedRoutes enables any routes advertised by a machine that match the ACL autoApprovers policy.
|
// Enabled any routes advertised by a machine that match the ACL autoApprovers policy.
|
||||||
func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
|
func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) {
|
||||||
if len(machine.IPAddresses) == 0 {
|
if len(machine.IPAddresses) == 0 {
|
||||||
return nil // This machine has no IPAddresses, so can't possibly match any autoApprovers ACLs
|
return // This machine has no IPAddresses, so can't possibly match any autoApprovers ACLs
|
||||||
}
|
}
|
||||||
|
|
||||||
routes := []Route{}
|
approvedRoutes := make([]netip.Prefix, 0, len(machine.HostInfo.RoutableIPs))
|
||||||
err := h.db.
|
thisMachine := []Machine{*machine}
|
||||||
Preload("Machine").
|
|
||||||
Where("machine_id = ? AND advertised = true AND enabled = false", machine.ID).Find(&routes).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
log.Error().
|
|
||||||
Caller().
|
|
||||||
Err(err).
|
|
||||||
Str("machine", machine.Hostname).
|
|
||||||
Msg("Could not get advertised routes for machine")
|
|
||||||
|
|
||||||
return err
|
for _, advertisedRoute := range machine.HostInfo.RoutableIPs {
|
||||||
}
|
if contains(machine.EnabledRoutes, advertisedRoute) {
|
||||||
|
continue // Skip routes that are already enabled for the node
|
||||||
|
}
|
||||||
|
|
||||||
approvedRoutes := []Route{}
|
routeApprovers, err := h.aclPolicy.AutoApprovers.GetRouteApprovers(
|
||||||
|
advertisedRoute,
|
||||||
for _, advertisedRoute := range routes {
|
)
|
||||||
routeApprovers, err := h.aclPolicy.AutoApprovers.GetRouteApprovers(netip.Prefix(advertisedRoute.Prefix))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Err(err).
|
log.Err(err).
|
||||||
Str("advertisedRoute", advertisedRoute.String()).
|
Str("advertisedRoute", advertisedRoute.String()).
|
||||||
Uint64("machineId", machine.ID).
|
Uint64("machineId", machine.ID).
|
||||||
Msg("Failed to resolve autoApprovers for advertised route")
|
Msg("Failed to resolve autoApprovers for advertised route")
|
||||||
|
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, approvedAlias := range routeApprovers {
|
for _, approvedAlias := range routeApprovers {
|
||||||
if approvedAlias == machine.Namespace.Name {
|
if approvedAlias == machine.Namespace.Name {
|
||||||
approvedRoutes = append(approvedRoutes, advertisedRoute)
|
approvedRoutes = append(approvedRoutes, advertisedRoute)
|
||||||
} else {
|
} else {
|
||||||
approvedIps, err := expandAlias([]Machine{*machine}, *h.aclPolicy, approvedAlias, h.cfg.OIDC.StripEmaildomain)
|
approvedIps, err := expandAlias(thisMachine, *h.aclPolicy, approvedAlias, h.cfg.OIDC.StripEmaildomain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Err(err).
|
log.Err(err).
|
||||||
Str("alias", approvedAlias).
|
Str("alias", approvedAlias).
|
||||||
Msg("Failed to expand alias when processing autoApprovers policy")
|
Msg("Failed to expand alias when processing autoApprovers policy")
|
||||||
|
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// approvedIPs should contain all of machine's IPs if it matches the rule, so check for first
|
// approvedIPs should contain all of machine's IPs if it matches the rule, so check for first
|
||||||
@@ -1109,20 +1031,26 @@ func (h *Headscale) EnableAutoApprovedRoutes(machine *Machine) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, approvedRoute := range approvedRoutes {
|
for _, approvedRoute := range approvedRoutes {
|
||||||
approvedRoutes[i].Enabled = true
|
if !contains(machine.EnabledRoutes, approvedRoute) {
|
||||||
err = h.db.Save(&approvedRoutes[i]).Error
|
log.Info().
|
||||||
if err != nil {
|
Str("route", approvedRoute.String()).
|
||||||
log.Err(err).
|
Uint64("client", machine.ID).
|
||||||
Str("approvedRoute", approvedRoute.String()).
|
Msg("Enabling autoApproved route for client")
|
||||||
Uint64("machineId", machine.ID).
|
machine.EnabledRoutes = append(machine.EnabledRoutes, approvedRoute)
|
||||||
Msg("Failed to enable approved route")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
func (machine *Machine) RoutesToProto() *v1.Routes {
|
||||||
|
availableRoutes := machine.GetAdvertisedRoutes()
|
||||||
|
|
||||||
|
enabledRoutes := machine.GetEnabledRoutes()
|
||||||
|
|
||||||
|
return &v1.Routes{
|
||||||
|
AdvertisedRoutes: ipPrefixToString(availableRoutes),
|
||||||
|
EnabledRoutes: ipPrefixToString(enabledRoutes),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) generateGivenName(suppliedName string, randomSuffix bool) (string, error) {
|
func (h *Headscale) generateGivenName(suppliedName string, randomSuffix bool) (string, error) {
|
||||||
|
|||||||
@@ -1153,16 +1153,9 @@ func (s *Suite) TestAutoApproveRoutes(c *check.C) {
|
|||||||
|
|
||||||
app.db.Save(&machine)
|
app.db.Save(&machine)
|
||||||
|
|
||||||
err = app.processMachineRoutes(&machine)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
machine0ByID, err := app.GetMachineByID(0)
|
machine0ByID, err := app.GetMachineByID(0)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
err = app.EnableAutoApprovedRoutes(machine0ByID)
|
app.EnableAutoApprovedRoutes(machine0ByID)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(machine0ByID.GetEnabledRoutes(), check.HasLen, 3)
|
||||||
|
|
||||||
enabledRoutes, err := app.GetEnabledRoutes(machine0ByID)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(enabledRoutes, check.HasLen, 3)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,31 +126,17 @@ service HeadscaleService {
|
|||||||
// --- Machine end ---
|
// --- Machine end ---
|
||||||
|
|
||||||
// --- Route start ---
|
// --- Route start ---
|
||||||
rpc GetRoutes(GetRoutesRequest) returns (GetRoutesResponse) {
|
rpc GetMachineRoute(GetMachineRouteRequest) returns (GetMachineRouteResponse) {
|
||||||
option (google.api.http) = {
|
|
||||||
get: "/api/v1/routes"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
rpc EnableRoute(EnableRouteRequest) returns (EnableRouteResponse) {
|
|
||||||
option (google.api.http) = {
|
|
||||||
post: "/api/v1/routes/{route_id}/enable"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
rpc DisableRoute(DisableRouteRequest) returns (DisableRouteResponse) {
|
|
||||||
option (google.api.http) = {
|
|
||||||
post: "/api/v1/routes/{route_id}/disable"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
rpc GetMachineRoutes(GetMachineRoutesRequest) returns (GetMachineRoutesResponse) {
|
|
||||||
option (google.api.http) = {
|
option (google.api.http) = {
|
||||||
get: "/api/v1/machine/{machine_id}/routes"
|
get: "/api/v1/machine/{machine_id}/routes"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpc EnableMachineRoutes(EnableMachineRoutesRequest) returns (EnableMachineRoutesResponse) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
post: "/api/v1/machine/{machine_id}/routes"
|
||||||
|
};
|
||||||
|
}
|
||||||
// --- Route end ---
|
// --- Route end ---
|
||||||
|
|
||||||
// --- ApiKeys start ---
|
// --- ApiKeys start ---
|
||||||
|
|||||||
@@ -2,47 +2,24 @@ syntax = "proto3";
|
|||||||
package headscale.v1;
|
package headscale.v1;
|
||||||
option go_package = "github.com/juanfont/headscale/gen/go/v1";
|
option go_package = "github.com/juanfont/headscale/gen/go/v1";
|
||||||
|
|
||||||
import "google/protobuf/timestamp.proto";
|
message Routes {
|
||||||
import "headscale/v1/machine.proto";
|
repeated string advertised_routes = 1;
|
||||||
|
repeated string enabled_routes = 2;
|
||||||
message Route {
|
|
||||||
uint64 id = 1;
|
|
||||||
Machine machine = 2;
|
|
||||||
string prefix = 3;
|
|
||||||
bool advertised = 4;
|
|
||||||
bool enabled = 5;
|
|
||||||
bool is_primary = 6;
|
|
||||||
|
|
||||||
google.protobuf.Timestamp created_at = 7;
|
|
||||||
google.protobuf.Timestamp updated_at = 8;
|
|
||||||
google.protobuf.Timestamp deleted_at = 9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetRoutesRequest {
|
message GetMachineRouteRequest {
|
||||||
}
|
|
||||||
|
|
||||||
message GetRoutesResponse {
|
|
||||||
repeated Route routes = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message EnableRouteRequest {
|
|
||||||
uint64 route_id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message EnableRouteResponse {
|
|
||||||
}
|
|
||||||
|
|
||||||
message DisableRouteRequest {
|
|
||||||
uint64 route_id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DisableRouteResponse {
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetMachineRoutesRequest {
|
|
||||||
uint64 machine_id = 1;
|
uint64 machine_id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetMachineRoutesResponse {
|
message GetMachineRouteResponse {
|
||||||
repeated Route routes = 1;
|
Routes routes = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message EnableMachineRoutesRequest {
|
||||||
|
uint64 machine_id = 1;
|
||||||
|
repeated string routes = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EnableMachineRoutesResponse {
|
||||||
|
Routes routes = 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,15 +32,6 @@ func (h *Headscale) handlePollCommon(
|
|||||||
machine.DiscoKey = DiscoPublicKeyStripPrefix(mapRequest.DiscoKey)
|
machine.DiscoKey = DiscoPublicKeyStripPrefix(mapRequest.DiscoKey)
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
|
|
||||||
err := h.processMachineRoutes(machine)
|
|
||||||
if err != nil {
|
|
||||||
log.Error().
|
|
||||||
Caller().
|
|
||||||
Err(err).
|
|
||||||
Str("machine", machine.Hostname).
|
|
||||||
Msg("Error processing machine routes")
|
|
||||||
}
|
|
||||||
|
|
||||||
// update ACLRules with peer informations (to update server tags if necessary)
|
// update ACLRules with peer informations (to update server tags if necessary)
|
||||||
if h.aclPolicy != nil {
|
if h.aclPolicy != nil {
|
||||||
err := h.UpdateACLRules()
|
err := h.UpdateACLRules()
|
||||||
@@ -53,15 +44,7 @@ func (h *Headscale) handlePollCommon(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update routes with peer information
|
// update routes with peer information
|
||||||
err = h.EnableAutoApprovedRoutes(machine)
|
h.EnableAutoApprovedRoutes(machine)
|
||||||
if err != nil {
|
|
||||||
log.Error().
|
|
||||||
Caller().
|
|
||||||
Bool("noise", isNoise).
|
|
||||||
Str("machine", machine.Hostname).
|
|
||||||
Err(err).
|
|
||||||
Msg("Error running auto approved routes")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// From Tailscale client:
|
// From Tailscale client:
|
||||||
|
|||||||
362
routes.go
362
routes.go
@@ -1,338 +1,118 @@
|
|||||||
package headscale
|
package headscale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
|
||||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ErrRouteIsNotAvailable = Error("route is not available")
|
ErrRouteIsNotAvailable = Error("route is not available")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// Deprecated: use machine function instead
|
||||||
ExitRouteV4 = netip.MustParsePrefix("0.0.0.0/0")
|
// GetAdvertisedNodeRoutes returns the subnet routes advertised by a node (identified by
|
||||||
ExitRouteV6 = netip.MustParsePrefix("::/0")
|
// namespace and node name).
|
||||||
)
|
func (h *Headscale) GetAdvertisedNodeRoutes(
|
||||||
|
namespace string,
|
||||||
type Route struct {
|
nodeName string,
|
||||||
gorm.Model
|
) (*[]netip.Prefix, error) {
|
||||||
|
machine, err := h.GetMachine(namespace, nodeName)
|
||||||
MachineID uint64
|
|
||||||
Machine Machine
|
|
||||||
Prefix IPPrefix
|
|
||||||
|
|
||||||
Advertised bool
|
|
||||||
Enabled bool
|
|
||||||
IsPrimary bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type Routes []Route
|
|
||||||
|
|
||||||
func (r *Route) String() string {
|
|
||||||
return fmt.Sprintf("%s:%s", r.Machine, netip.Prefix(r.Prefix).String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Route) isExitRoute() bool {
|
|
||||||
return netip.Prefix(r.Prefix) == ExitRouteV4 || netip.Prefix(r.Prefix) == ExitRouteV6
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs Routes) toPrefixes() []netip.Prefix {
|
|
||||||
prefixes := make([]netip.Prefix, len(rs))
|
|
||||||
for i, r := range rs {
|
|
||||||
prefixes[i] = netip.Prefix(r.Prefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
return prefixes
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Headscale) GetRoutes() ([]Route, error) {
|
|
||||||
var routes []Route
|
|
||||||
err := h.db.Preload("Machine").Find(&routes).Error
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return routes, nil
|
return &machine.HostInfo.RoutableIPs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) GetMachineRoutes(m *Machine) ([]Route, error) {
|
// Deprecated: use machine function instead
|
||||||
var routes []Route
|
// GetEnabledNodeRoutes returns the subnet routes enabled by a node (identified by
|
||||||
err := h.db.
|
// namespace and node name).
|
||||||
Preload("Machine").
|
func (h *Headscale) GetEnabledNodeRoutes(
|
||||||
Where("machine_id = ?", m.ID).
|
namespace string,
|
||||||
Find(&routes).Error
|
nodeName string,
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
) ([]netip.Prefix, error) {
|
||||||
return nil, err
|
machine, err := h.GetMachine(namespace, nodeName)
|
||||||
}
|
|
||||||
|
|
||||||
return routes, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Headscale) GetRoute(id uint64) (*Route, error) {
|
|
||||||
var route Route
|
|
||||||
err := h.db.Preload("Machine").First(&route, id).Error
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &route, nil
|
return machine.EnabledRoutes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) EnableRoute(id uint64) error {
|
// Deprecated: use machine function instead
|
||||||
route, err := h.GetRoute(id)
|
// IsNodeRouteEnabled checks if a certain route has been enabled.
|
||||||
|
func (h *Headscale) IsNodeRouteEnabled(
|
||||||
|
namespace string,
|
||||||
|
nodeName string,
|
||||||
|
routeStr string,
|
||||||
|
) bool {
|
||||||
|
route, err := netip.ParsePrefix(routeStr)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
enabledRoutes, err := h.GetEnabledNodeRoutes(namespace, nodeName)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, enabledRoute := range enabledRoutes {
|
||||||
|
if route == enabledRoute {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: use EnableRoute in machine.go
|
||||||
|
// EnableNodeRoute enables a subnet route advertised by a node (identified by
|
||||||
|
// namespace and node name).
|
||||||
|
func (h *Headscale) EnableNodeRoute(
|
||||||
|
namespace string,
|
||||||
|
nodeName string,
|
||||||
|
routeStr string,
|
||||||
|
) error {
|
||||||
|
machine, err := h.GetMachine(namespace, nodeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.EnableRoutes(&route.Machine, netip.Prefix(route.Prefix).String())
|
route, err := netip.ParsePrefix(routeStr)
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Headscale) DisableRoute(id uint64) error {
|
|
||||||
route, err := h.GetRoute(id)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
route.Enabled = false
|
availableRoutes, err := h.GetAdvertisedNodeRoutes(namespace, nodeName)
|
||||||
route.IsPrimary = false
|
|
||||||
err = h.db.Save(route).Error
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.handlePrimarySubnetFailover()
|
enabledRoutes, err := h.GetEnabledNodeRoutes(namespace, nodeName)
|
||||||
}
|
|
||||||
|
|
||||||
// isUniquePrefix returns if there is another machine providing the same route already.
|
|
||||||
func (h *Headscale) isUniquePrefix(route Route) bool {
|
|
||||||
var count int64
|
|
||||||
h.db.
|
|
||||||
Model(&Route{}).
|
|
||||||
Where("prefix = ? AND machine_id != ? AND advertised = ? AND enabled = ?",
|
|
||||||
route.Prefix,
|
|
||||||
route.MachineID,
|
|
||||||
true, true).Count(&count)
|
|
||||||
|
|
||||||
return count == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Headscale) getPrimaryRoute(prefix netip.Prefix) (*Route, error) {
|
|
||||||
var route Route
|
|
||||||
err := h.db.
|
|
||||||
Preload("Machine").
|
|
||||||
Where("prefix = ? AND advertised = ? AND enabled = ? AND is_primary = ?", IPPrefix(prefix), true, true, true).
|
|
||||||
First(&route).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return nil, gorm.ErrRecordNotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
return &route, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// getMachinePrimaryRoutes returns the routes that are enabled and marked as primary (for subnet failover)
|
|
||||||
// Exit nodes are not considered for this, as they are never marked as Primary.
|
|
||||||
func (h *Headscale) getMachinePrimaryRoutes(m *Machine) ([]Route, error) {
|
|
||||||
var routes []Route
|
|
||||||
err := h.db.
|
|
||||||
Preload("Machine").
|
|
||||||
Where("machine_id = ? AND advertised = ? AND enabled = ? AND is_primary = ?", m.ID, true, true, true).
|
|
||||||
Find(&routes).Error
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return routes, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Headscale) processMachineRoutes(machine *Machine) error {
|
|
||||||
currentRoutes := []Route{}
|
|
||||||
err := h.db.Where("machine_id = ?", machine.ID).Find(¤tRoutes).Error
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
advertisedRoutes := map[netip.Prefix]bool{}
|
available := false
|
||||||
for _, prefix := range machine.HostInfo.RoutableIPs {
|
for _, availableRoute := range *availableRoutes {
|
||||||
advertisedRoutes[prefix] = false
|
// If the route is available, and not yet enabled, add it to the new routing table
|
||||||
}
|
if route == availableRoute {
|
||||||
|
available = true
|
||||||
for pos, route := range currentRoutes {
|
if !h.IsNodeRouteEnabled(namespace, nodeName, routeStr) {
|
||||||
if _, ok := advertisedRoutes[netip.Prefix(route.Prefix)]; ok {
|
enabledRoutes = append(enabledRoutes, route)
|
||||||
if !route.Advertised {
|
|
||||||
currentRoutes[pos].Advertised = true
|
|
||||||
err := h.db.Save(¤tRoutes[pos]).Error
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
advertisedRoutes[netip.Prefix(route.Prefix)] = true
|
|
||||||
} else if route.Advertised {
|
|
||||||
currentRoutes[pos].Advertised = false
|
|
||||||
currentRoutes[pos].Enabled = false
|
|
||||||
err := h.db.Save(¤tRoutes[pos]).Error
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for prefix, exists := range advertisedRoutes {
|
if !available {
|
||||||
if !exists {
|
return ErrRouteIsNotAvailable
|
||||||
route := Route{
|
}
|
||||||
MachineID: machine.ID,
|
|
||||||
Prefix: IPPrefix(prefix),
|
machine.EnabledRoutes = enabledRoutes
|
||||||
Advertised: true,
|
|
||||||
Enabled: false,
|
if err := h.db.Save(&machine).Error; err != nil {
|
||||||
}
|
return fmt.Errorf("failed to update node routes in the database: %w", err)
|
||||||
err := h.db.Create(&route).Error
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) handlePrimarySubnetFailover() error {
|
|
||||||
// first, get all the enabled routes
|
|
||||||
var routes []Route
|
|
||||||
err := h.db.
|
|
||||||
Preload("Machine").
|
|
||||||
Where("advertised = ? AND enabled = ?", true, true).
|
|
||||||
Find(&routes).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
log.Error().Err(err).Msg("error getting routes")
|
|
||||||
}
|
|
||||||
|
|
||||||
for pos, route := range routes {
|
|
||||||
if route.isExitRoute() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if !route.IsPrimary {
|
|
||||||
_, err := h.getPrimaryRoute(netip.Prefix(route.Prefix))
|
|
||||||
if h.isUniquePrefix(route) || errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
log.Info().
|
|
||||||
Str("prefix", netip.Prefix(route.Prefix).String()).
|
|
||||||
Str("machine", route.Machine.GivenName).
|
|
||||||
Msg("Setting primary route")
|
|
||||||
routes[pos].IsPrimary = true
|
|
||||||
err := h.db.Save(&routes[pos]).Error
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Msg("error marking route as primary")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if route.IsPrimary {
|
|
||||||
if route.Machine.isOnline() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// machine offline, find a new primary
|
|
||||||
log.Info().
|
|
||||||
Str("machine", route.Machine.Hostname).
|
|
||||||
Str("prefix", netip.Prefix(route.Prefix).String()).
|
|
||||||
Msgf("machine offline, finding a new primary subnet")
|
|
||||||
|
|
||||||
// find a new primary route
|
|
||||||
var newPrimaryRoutes []Route
|
|
||||||
err := h.db.
|
|
||||||
Preload("Machine").
|
|
||||||
Where("prefix = ? AND machine_id != ? AND advertised = ? AND enabled = ?",
|
|
||||||
route.Prefix,
|
|
||||||
route.MachineID,
|
|
||||||
true, true).
|
|
||||||
Find(&newPrimaryRoutes).Error
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
log.Error().Err(err).Msg("error finding new primary route")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var newPrimaryRoute *Route
|
|
||||||
for pos, r := range newPrimaryRoutes {
|
|
||||||
if r.Machine.isOnline() {
|
|
||||||
newPrimaryRoute = &newPrimaryRoutes[pos]
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if newPrimaryRoute == nil {
|
|
||||||
log.Warn().
|
|
||||||
Str("machine", route.Machine.Hostname).
|
|
||||||
Str("prefix", netip.Prefix(route.Prefix).String()).
|
|
||||||
Msgf("no alternative primary route found")
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Info().
|
|
||||||
Str("old_machine", route.Machine.Hostname).
|
|
||||||
Str("prefix", netip.Prefix(route.Prefix).String()).
|
|
||||||
Str("new_machine", newPrimaryRoute.Machine.Hostname).
|
|
||||||
Msgf("found new primary route")
|
|
||||||
|
|
||||||
// disable the old primary route
|
|
||||||
routes[pos].IsPrimary = false
|
|
||||||
err = h.db.Save(&routes[pos]).Error
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Msg("error disabling old primary route")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable the new primary route
|
|
||||||
newPrimaryRoute.IsPrimary = true
|
|
||||||
err = h.db.Save(&newPrimaryRoute).Error
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Msg("error enabling new primary route")
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs Routes) toProto() []*v1.Route {
|
|
||||||
protoRoutes := []*v1.Route{}
|
|
||||||
|
|
||||||
for _, route := range rs {
|
|
||||||
protoRoute := v1.Route{
|
|
||||||
Id: uint64(route.ID),
|
|
||||||
Machine: route.Machine.toProto(),
|
|
||||||
Prefix: netip.Prefix(route.Prefix).String(),
|
|
||||||
Advertised: route.Advertised,
|
|
||||||
Enabled: route.Enabled,
|
|
||||||
IsPrimary: route.IsPrimary,
|
|
||||||
CreatedAt: timestamppb.New(route.CreatedAt),
|
|
||||||
UpdatedAt: timestamppb.New(route.UpdatedAt),
|
|
||||||
}
|
|
||||||
|
|
||||||
if route.DeletedAt.Valid {
|
|
||||||
protoRoute.DeletedAt = timestamppb.New(route.DeletedAt.Time)
|
|
||||||
}
|
|
||||||
|
|
||||||
protoRoutes = append(protoRoutes, &protoRoute)
|
|
||||||
}
|
|
||||||
|
|
||||||
return protoRoutes
|
|
||||||
}
|
|
||||||
|
|||||||
277
routes_test.go
277
routes_test.go
@@ -2,7 +2,6 @@ package headscale
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"time"
|
|
||||||
|
|
||||||
"gopkg.in/check.v1"
|
"gopkg.in/check.v1"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
@@ -38,17 +37,17 @@ func (s *Suite) TestGetRoutes(c *check.C) {
|
|||||||
}
|
}
|
||||||
app.db.Save(&machine)
|
app.db.Save(&machine)
|
||||||
|
|
||||||
err = app.processMachineRoutes(&machine)
|
advertisedRoutes, err := app.GetAdvertisedNodeRoutes(
|
||||||
|
"test",
|
||||||
|
"test_get_route_machine",
|
||||||
|
)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
c.Assert(len(*advertisedRoutes), check.Equals, 1)
|
||||||
|
|
||||||
advertisedRoutes, err := app.GetAdvertisedRoutes(&machine)
|
err = app.EnableNodeRoute("test", "test_get_route_machine", "192.168.0.0/24")
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(advertisedRoutes), check.Equals, 1)
|
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine, "192.168.0.0/24")
|
|
||||||
c.Assert(err, check.NotNil)
|
c.Assert(err, check.NotNil)
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine, "10.0.0.0/24")
|
err = app.EnableNodeRoute("test", "test_get_route_machine", "10.0.0.0/24")
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,266 +88,48 @@ func (s *Suite) TestGetEnableRoutes(c *check.C) {
|
|||||||
}
|
}
|
||||||
app.db.Save(&machine)
|
app.db.Save(&machine)
|
||||||
|
|
||||||
err = app.processMachineRoutes(&machine)
|
availableRoutes, err := app.GetAdvertisedNodeRoutes(
|
||||||
|
"test",
|
||||||
|
"test_enable_route_machine",
|
||||||
|
)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
c.Assert(len(*availableRoutes), check.Equals, 2)
|
||||||
|
|
||||||
availableRoutes, err := app.GetAdvertisedRoutes(&machine)
|
noEnabledRoutes, err := app.GetEnabledNodeRoutes(
|
||||||
c.Assert(err, check.IsNil)
|
"test",
|
||||||
c.Assert(err, check.IsNil)
|
"test_enable_route_machine",
|
||||||
c.Assert(len(availableRoutes), check.Equals, 2)
|
)
|
||||||
|
|
||||||
noEnabledRoutes, err := app.GetEnabledRoutes(&machine)
|
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(len(noEnabledRoutes), check.Equals, 0)
|
c.Assert(len(noEnabledRoutes), check.Equals, 0)
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine, "192.168.0.0/24")
|
err = app.EnableNodeRoute("test", "test_enable_route_machine", "192.168.0.0/24")
|
||||||
c.Assert(err, check.NotNil)
|
c.Assert(err, check.NotNil)
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine, "10.0.0.0/24")
|
err = app.EnableNodeRoute("test", "test_enable_route_machine", "10.0.0.0/24")
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
enabledRoutes, err := app.GetEnabledRoutes(&machine)
|
enabledRoutes, err := app.GetEnabledNodeRoutes("test", "test_enable_route_machine")
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(len(enabledRoutes), check.Equals, 1)
|
c.Assert(len(enabledRoutes), check.Equals, 1)
|
||||||
|
|
||||||
// Adding it twice will just let it pass through
|
// Adding it twice will just let it pass through
|
||||||
err = app.EnableRoutes(&machine, "10.0.0.0/24")
|
err = app.EnableNodeRoute("test", "test_enable_route_machine", "10.0.0.0/24")
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
enableRoutesAfterDoubleApply, err := app.GetEnabledRoutes(&machine)
|
enableRoutesAfterDoubleApply, err := app.GetEnabledNodeRoutes(
|
||||||
|
"test",
|
||||||
|
"test_enable_route_machine",
|
||||||
|
)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(len(enableRoutesAfterDoubleApply), check.Equals, 1)
|
c.Assert(len(enableRoutesAfterDoubleApply), check.Equals, 1)
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine, "150.0.10.0/25")
|
err = app.EnableNodeRoute("test", "test_enable_route_machine", "150.0.10.0/25")
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
enabledRoutesWithAdditionalRoute, err := app.GetEnabledRoutes(&machine)
|
enabledRoutesWithAdditionalRoute, err := app.GetEnabledNodeRoutes(
|
||||||
|
"test",
|
||||||
|
"test_enable_route_machine",
|
||||||
|
)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(len(enabledRoutesWithAdditionalRoute), check.Equals, 2)
|
c.Assert(len(enabledRoutesWithAdditionalRoute), check.Equals, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Suite) TestIsUniquePrefix(c *check.C) {
|
|
||||||
namespace, err := app.CreateNamespace("test")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
pak, err := app.CreatePreAuthKey(namespace.Name, false, false, nil, nil)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
_, err = app.GetMachine("test", "test_enable_route_machine")
|
|
||||||
c.Assert(err, check.NotNil)
|
|
||||||
|
|
||||||
route, err := netip.ParsePrefix(
|
|
||||||
"10.0.0.0/24",
|
|
||||||
)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
route2, err := netip.ParsePrefix(
|
|
||||||
"150.0.10.0/25",
|
|
||||||
)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
hostInfo1 := tailcfg.Hostinfo{
|
|
||||||
RoutableIPs: []netip.Prefix{route, route2},
|
|
||||||
}
|
|
||||||
machine1 := Machine{
|
|
||||||
ID: 1,
|
|
||||||
MachineKey: "foo",
|
|
||||||
NodeKey: "bar",
|
|
||||||
DiscoKey: "faa",
|
|
||||||
Hostname: "test_enable_route_machine",
|
|
||||||
NamespaceID: namespace.ID,
|
|
||||||
RegisterMethod: RegisterMethodAuthKey,
|
|
||||||
AuthKeyID: uint(pak.ID),
|
|
||||||
HostInfo: HostInfo(hostInfo1),
|
|
||||||
}
|
|
||||||
app.db.Save(&machine1)
|
|
||||||
|
|
||||||
err = app.processMachineRoutes(&machine1)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine1, route.String())
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine1, route2.String())
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
hostInfo2 := tailcfg.Hostinfo{
|
|
||||||
RoutableIPs: []netip.Prefix{route2},
|
|
||||||
}
|
|
||||||
machine2 := Machine{
|
|
||||||
ID: 2,
|
|
||||||
MachineKey: "foo",
|
|
||||||
NodeKey: "bar",
|
|
||||||
DiscoKey: "faa",
|
|
||||||
Hostname: "test_enable_route_machine",
|
|
||||||
NamespaceID: namespace.ID,
|
|
||||||
RegisterMethod: RegisterMethodAuthKey,
|
|
||||||
AuthKeyID: uint(pak.ID),
|
|
||||||
HostInfo: HostInfo(hostInfo2),
|
|
||||||
}
|
|
||||||
app.db.Save(&machine2)
|
|
||||||
|
|
||||||
err = app.processMachineRoutes(&machine2)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine2, route2.String())
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
enabledRoutes1, err := app.GetEnabledRoutes(&machine1)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(enabledRoutes1), check.Equals, 2)
|
|
||||||
|
|
||||||
enabledRoutes2, err := app.GetEnabledRoutes(&machine2)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(enabledRoutes2), check.Equals, 1)
|
|
||||||
|
|
||||||
routes, err := app.getMachinePrimaryRoutes(&machine1)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(routes), check.Equals, 2)
|
|
||||||
|
|
||||||
routes, err = app.getMachinePrimaryRoutes(&machine2)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(routes), check.Equals, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Suite) TestSubnetFailover(c *check.C) {
|
|
||||||
namespace, err := app.CreateNamespace("test")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
pak, err := app.CreatePreAuthKey(namespace.Name, false, false, nil, nil)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
_, err = app.GetMachine("test", "test_enable_route_machine")
|
|
||||||
c.Assert(err, check.NotNil)
|
|
||||||
|
|
||||||
prefix, err := netip.ParsePrefix(
|
|
||||||
"10.0.0.0/24",
|
|
||||||
)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
prefix2, err := netip.ParsePrefix(
|
|
||||||
"150.0.10.0/25",
|
|
||||||
)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
hostInfo1 := tailcfg.Hostinfo{
|
|
||||||
RoutableIPs: []netip.Prefix{prefix, prefix2},
|
|
||||||
}
|
|
||||||
|
|
||||||
now := time.Now()
|
|
||||||
machine1 := Machine{
|
|
||||||
ID: 1,
|
|
||||||
MachineKey: "foo",
|
|
||||||
NodeKey: "bar",
|
|
||||||
DiscoKey: "faa",
|
|
||||||
Hostname: "test_enable_route_machine",
|
|
||||||
NamespaceID: namespace.ID,
|
|
||||||
RegisterMethod: RegisterMethodAuthKey,
|
|
||||||
AuthKeyID: uint(pak.ID),
|
|
||||||
HostInfo: HostInfo(hostInfo1),
|
|
||||||
LastSeen: &now,
|
|
||||||
}
|
|
||||||
app.db.Save(&machine1)
|
|
||||||
|
|
||||||
err = app.processMachineRoutes(&machine1)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine1, prefix.String())
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine1, prefix2.String())
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.handlePrimarySubnetFailover()
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
enabledRoutes1, err := app.GetEnabledRoutes(&machine1)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(enabledRoutes1), check.Equals, 2)
|
|
||||||
|
|
||||||
route, err := app.getPrimaryRoute(prefix)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(route.MachineID, check.Equals, machine1.ID)
|
|
||||||
|
|
||||||
hostInfo2 := tailcfg.Hostinfo{
|
|
||||||
RoutableIPs: []netip.Prefix{prefix2},
|
|
||||||
}
|
|
||||||
machine2 := Machine{
|
|
||||||
ID: 2,
|
|
||||||
MachineKey: "foo",
|
|
||||||
NodeKey: "bar",
|
|
||||||
DiscoKey: "faa",
|
|
||||||
Hostname: "test_enable_route_machine",
|
|
||||||
NamespaceID: namespace.ID,
|
|
||||||
RegisterMethod: RegisterMethodAuthKey,
|
|
||||||
AuthKeyID: uint(pak.ID),
|
|
||||||
HostInfo: HostInfo(hostInfo2),
|
|
||||||
LastSeen: &now,
|
|
||||||
}
|
|
||||||
app.db.Save(&machine2)
|
|
||||||
|
|
||||||
err = app.processMachineRoutes(&machine2)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine2, prefix2.String())
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.handlePrimarySubnetFailover()
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
enabledRoutes1, err = app.GetEnabledRoutes(&machine1)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(enabledRoutes1), check.Equals, 2)
|
|
||||||
|
|
||||||
enabledRoutes2, err := app.GetEnabledRoutes(&machine2)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(enabledRoutes2), check.Equals, 1)
|
|
||||||
|
|
||||||
routes, err := app.getMachinePrimaryRoutes(&machine1)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(routes), check.Equals, 2)
|
|
||||||
|
|
||||||
routes, err = app.getMachinePrimaryRoutes(&machine2)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(routes), check.Equals, 0)
|
|
||||||
|
|
||||||
// lets make machine1 lastseen 10 mins ago
|
|
||||||
before := now.Add(-10 * time.Minute)
|
|
||||||
machine1.LastSeen = &before
|
|
||||||
err = app.db.Save(&machine1).Error
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.handlePrimarySubnetFailover()
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
routes, err = app.getMachinePrimaryRoutes(&machine1)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(routes), check.Equals, 1)
|
|
||||||
|
|
||||||
routes, err = app.getMachinePrimaryRoutes(&machine2)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(routes), check.Equals, 1)
|
|
||||||
|
|
||||||
machine2.HostInfo = HostInfo(tailcfg.Hostinfo{
|
|
||||||
RoutableIPs: []netip.Prefix{prefix, prefix2},
|
|
||||||
})
|
|
||||||
err = app.db.Save(&machine2).Error
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.processMachineRoutes(&machine2)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.EnableRoutes(&machine2, prefix.String())
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
err = app.handlePrimarySubnetFailover()
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
routes, err = app.getMachinePrimaryRoutes(&machine1)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(routes), check.Equals, 0)
|
|
||||||
|
|
||||||
routes, err = app.getMachinePrimaryRoutes(&machine2)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
c.Assert(len(routes), check.Equals, 2)
|
|
||||||
}
|
|
||||||
|
|||||||
10
utils.go
10
utils.go
@@ -254,6 +254,16 @@ func GrpcSocketDialer(ctx context.Context, addr string) (net.Conn, error) {
|
|||||||
return d.DialContext(ctx, "unix", addr)
|
return d.DialContext(ctx, "unix", addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ipPrefixToString(prefixes []netip.Prefix) []string {
|
||||||
|
result := make([]string, len(prefixes))
|
||||||
|
|
||||||
|
for index, prefix := range prefixes {
|
||||||
|
result[index] = prefix.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func stringToIPPrefix(prefixes []string) ([]netip.Prefix, error) {
|
func stringToIPPrefix(prefixes []string) ([]netip.Prefix, error) {
|
||||||
result := make([]netip.Prefix, len(prefixes))
|
result := make([]netip.Prefix, len(prefixes))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user