mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-13 02:58:49 +00:00
Migrate IP fields in database to dedicated columns (#1869)
This commit is contained in:
@@ -3,6 +3,7 @@ package hscontrol
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -195,7 +196,7 @@ func (api headscaleV1APIServer) RegisterNode(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
addrs, err := api.h.ipAlloc.Next()
|
||||
ipv4, ipv6, err := api.h.ipAlloc.Next()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -208,7 +209,7 @@ func (api headscaleV1APIServer) RegisterNode(
|
||||
request.GetUser(),
|
||||
nil,
|
||||
util.RegisterMethodCLI,
|
||||
addrs,
|
||||
ipv4, ipv6,
|
||||
)
|
||||
})
|
||||
if err != nil {
|
||||
@@ -468,6 +469,24 @@ func (api headscaleV1APIServer) MoveNode(
|
||||
return &v1.MoveNodeResponse{Node: node.Proto()}, nil
|
||||
}
|
||||
|
||||
func (api headscaleV1APIServer) BackfillNodeIPs(
|
||||
ctx context.Context,
|
||||
request *v1.BackfillNodeIPsRequest,
|
||||
) (*v1.BackfillNodeIPsResponse, error) {
|
||||
log.Trace().Msg("Backfill called")
|
||||
|
||||
if !request.Confirmed {
|
||||
return nil, errors.New("not confirmed, aborting")
|
||||
}
|
||||
|
||||
changes, err := api.h.db.BackfillNodeIPs(api.h.ipAlloc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &v1.BackfillNodeIPsResponse{Changes: changes}, nil
|
||||
}
|
||||
|
||||
func (api headscaleV1APIServer) GetRoutes(
|
||||
ctx context.Context,
|
||||
request *v1.GetRoutesRequest,
|
||||
|
Reference in New Issue
Block a user