mirror of
https://github.com/juanfont/headscale.git
synced 2025-09-06 17:54:31 +02:00
save routes on register
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
fec8d831d8
commit
7b06ba3dc4
@ -453,6 +453,10 @@ func RegisterNode(tx *gorm.DB, node types.Node, ipv4 *netip.Addr, ipv6 *netip.Ad
|
||||
return nil, fmt.Errorf("failed register(save) node in the database: %w", err)
|
||||
}
|
||||
|
||||
if _, err := SaveNodeRoutes(tx, &node); err != nil {
|
||||
return nil, fmt.Errorf("failed to save node routes: %w", err)
|
||||
}
|
||||
|
||||
log.Trace().
|
||||
Caller().
|
||||
Str("node", node.Hostname).
|
||||
|
@ -80,6 +80,7 @@ type TailscaleInContainer struct {
|
||||
withExtraHosts []string
|
||||
workdir string
|
||||
netfilter string
|
||||
extraLoginArgs []string
|
||||
|
||||
// build options, solely for HEAD
|
||||
buildConfig TailscaleInContainerBuildConfig
|
||||
@ -203,6 +204,14 @@ func WithBuildTag(tag string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithExtraLoginArgs adds additional arguments to the `tailscale up` command
|
||||
// as part of the Login function.
|
||||
func WithExtraLoginArgs(args []string) Option {
|
||||
return func(tsic *TailscaleInContainer) {
|
||||
tsic.extraLoginArgs = args
|
||||
}
|
||||
}
|
||||
|
||||
// New returns a new TailscaleInContainer instance.
|
||||
func New(
|
||||
pool *dockertest.Pool,
|
||||
@ -436,6 +445,10 @@ func (t *TailscaleInContainer) Login(
|
||||
"--accept-routes=false",
|
||||
}
|
||||
|
||||
if t.extraLoginArgs != nil {
|
||||
command = append(command, t.extraLoginArgs...)
|
||||
}
|
||||
|
||||
if t.withSSH {
|
||||
command = append(command, "--ssh")
|
||||
}
|
||||
@ -475,6 +488,10 @@ func (t *TailscaleInContainer) LoginWithURL(
|
||||
"--accept-routes=false",
|
||||
}
|
||||
|
||||
if t.extraLoginArgs != nil {
|
||||
command = append(command, t.extraLoginArgs...)
|
||||
}
|
||||
|
||||
stdout, stderr, err := t.Execute(command)
|
||||
if errors.Is(err, errTailscaleNotLoggedIn) {
|
||||
return nil, errTailscaleCannotUpWithoutAuthkey
|
||||
|
Loading…
Reference in New Issue
Block a user