Migrate IP fields in database to dedicated columns (#1869)
This commit is contained in:
parent
85cef84e17
commit
2ce23df45a
39 changed files with 1885 additions and 1055 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue