mirror of
https://github.com/tailscale/tailscale.git
synced 2025-06-25 09:39:05 +00:00
ipn/ipnlocal: make pricing restriction message for Tailnet Lock clearer
Fixes tailscale/corp#24417 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
This commit is contained in:
parent
49ae66c10c
commit
a91fcc8813
@ -600,18 +600,14 @@ func (b *LocalBackend) NetworkLockInit(keys []tka.Key, disablementValues [][]byt
|
|||||||
|
|
||||||
var ourNodeKey key.NodePublic
|
var ourNodeKey key.NodePublic
|
||||||
var nlPriv key.NLPrivate
|
var nlPriv key.NLPrivate
|
||||||
|
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
|
|
||||||
if !b.capTailnetLock {
|
|
||||||
b.mu.Unlock()
|
|
||||||
return errors.New("not permitted to enable tailnet lock")
|
|
||||||
}
|
|
||||||
|
|
||||||
if p := b.pm.CurrentPrefs(); p.Valid() && p.Persist().Valid() && !p.Persist().PrivateNodeKey().IsZero() {
|
if p := b.pm.CurrentPrefs(); p.Valid() && p.Persist().Valid() && !p.Persist().PrivateNodeKey().IsZero() {
|
||||||
ourNodeKey = p.Persist().PublicNodeKey()
|
ourNodeKey = p.Persist().PublicNodeKey()
|
||||||
nlPriv = p.Persist().NetworkLockKey()
|
nlPriv = p.Persist().NetworkLockKey()
|
||||||
}
|
}
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
|
|
||||||
if ourNodeKey.IsZero() || nlPriv.IsZero() {
|
if ourNodeKey.IsZero() || nlPriv.IsZero() {
|
||||||
return errors.New("no node-key: is tailscale logged in?")
|
return errors.New("no node-key: is tailscale logged in?")
|
||||||
}
|
}
|
||||||
@ -671,6 +667,13 @@ func (b *LocalBackend) NetworkLockInit(keys []tka.Key, disablementValues [][]byt
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NetworkLockAllowed reports whether the node is allowed to use Tailnet Lock.
|
||||||
|
func (b *LocalBackend) NetworkLockAllowed() bool {
|
||||||
|
b.mu.Lock()
|
||||||
|
defer b.mu.Unlock()
|
||||||
|
return b.capTailnetLock
|
||||||
|
}
|
||||||
|
|
||||||
// Only use is in tests.
|
// Only use is in tests.
|
||||||
func (b *LocalBackend) NetworkLockVerifySignatureForTest(nks tkatype.MarshaledSignature, nodeKey key.NodePublic) error {
|
func (b *LocalBackend) NetworkLockVerifySignatureForTest(nks tkatype.MarshaledSignature, nodeKey key.NodePublic) error {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
|
@ -1970,6 +1970,11 @@ func (h *Handler) serveTKAInit(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !h.b.NetworkLockAllowed() {
|
||||||
|
http.Error(w, "Tailnet Lock is not supported on your pricing plan", http.StatusForbidden)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err := h.b.NetworkLockInit(req.Keys, req.DisablementValues, req.SupportDisablement); err != nil {
|
if err := h.b.NetworkLockInit(req.Keys, req.DisablementValues, req.SupportDisablement); err != nil {
|
||||||
http.Error(w, "initialization failed: "+err.Error(), http.StatusInternalServerError)
|
http.Error(w, "initialization failed: "+err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user