Skip to content

Commit 3a49b74

Browse files
committed
all: add ts_omit_tailnetlock as a start of making it build-time modular
Updates tailscale#17115 Change-Id: I6b083c0db4c4d359e49eb129d626b7f128f0a9d2 Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent 0e3d942 commit 3a49b74

File tree

23 files changed

+897
-634
lines changed

23 files changed

+897
-634
lines changed

client/local/local.go

Lines changed: 0 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ import (
3838
"tailscale.com/paths"
3939
"tailscale.com/safesocket"
4040
"tailscale.com/tailcfg"
41-
"tailscale.com/tka"
4241
"tailscale.com/types/dnstype"
4342
"tailscale.com/types/key"
44-
"tailscale.com/types/tkatype"
4543
"tailscale.com/util/eventbus"
4644
)
4745

@@ -1219,183 +1217,6 @@ func (lc *Client) Ping(ctx context.Context, ip netip.Addr, pingtype tailcfg.Ping
12191217
return lc.PingWithOpts(ctx, ip, pingtype, PingOpts{})
12201218
}
12211219

1222-
// NetworkLockStatus fetches information about the tailnet key authority, if one is configured.
1223-
func (lc *Client) NetworkLockStatus(ctx context.Context) (*ipnstate.NetworkLockStatus, error) {
1224-
body, err := lc.send(ctx, "GET", "/localapi/v0/tka/status", 200, nil)
1225-
if err != nil {
1226-
return nil, fmt.Errorf("error: %w", err)
1227-
}
1228-
return decodeJSON[*ipnstate.NetworkLockStatus](body)
1229-
}
1230-
1231-
// NetworkLockInit initializes the tailnet key authority.
1232-
//
1233-
// TODO(tom): Plumb through disablement secrets.
1234-
func (lc *Client) NetworkLockInit(ctx context.Context, keys []tka.Key, disablementValues [][]byte, supportDisablement []byte) (*ipnstate.NetworkLockStatus, error) {
1235-
var b bytes.Buffer
1236-
type initRequest struct {
1237-
Keys []tka.Key
1238-
DisablementValues [][]byte
1239-
SupportDisablement []byte
1240-
}
1241-
1242-
if err := json.NewEncoder(&b).Encode(initRequest{Keys: keys, DisablementValues: disablementValues, SupportDisablement: supportDisablement}); err != nil {
1243-
return nil, err
1244-
}
1245-
1246-
body, err := lc.send(ctx, "POST", "/localapi/v0/tka/init", 200, &b)
1247-
if err != nil {
1248-
return nil, fmt.Errorf("error: %w", err)
1249-
}
1250-
return decodeJSON[*ipnstate.NetworkLockStatus](body)
1251-
}
1252-
1253-
// NetworkLockWrapPreauthKey wraps a pre-auth key with information to
1254-
// enable unattended bringup in the locked tailnet.
1255-
func (lc *Client) NetworkLockWrapPreauthKey(ctx context.Context, preauthKey string, tkaKey key.NLPrivate) (string, error) {
1256-
encodedPrivate, err := tkaKey.MarshalText()
1257-
if err != nil {
1258-
return "", err
1259-
}
1260-
1261-
var b bytes.Buffer
1262-
type wrapRequest struct {
1263-
TSKey string
1264-
TKAKey string // key.NLPrivate.MarshalText
1265-
}
1266-
if err := json.NewEncoder(&b).Encode(wrapRequest{TSKey: preauthKey, TKAKey: string(encodedPrivate)}); err != nil {
1267-
return "", err
1268-
}
1269-
1270-
body, err := lc.send(ctx, "POST", "/localapi/v0/tka/wrap-preauth-key", 200, &b)
1271-
if err != nil {
1272-
return "", fmt.Errorf("error: %w", err)
1273-
}
1274-
return string(body), nil
1275-
}
1276-
1277-
// NetworkLockModify adds and/or removes key(s) to the tailnet key authority.
1278-
func (lc *Client) NetworkLockModify(ctx context.Context, addKeys, removeKeys []tka.Key) error {
1279-
var b bytes.Buffer
1280-
type modifyRequest struct {
1281-
AddKeys []tka.Key
1282-
RemoveKeys []tka.Key
1283-
}
1284-
1285-
if err := json.NewEncoder(&b).Encode(modifyRequest{AddKeys: addKeys, RemoveKeys: removeKeys}); err != nil {
1286-
return err
1287-
}
1288-
1289-
if _, err := lc.send(ctx, "POST", "/localapi/v0/tka/modify", 204, &b); err != nil {
1290-
return fmt.Errorf("error: %w", err)
1291-
}
1292-
return nil
1293-
}
1294-
1295-
// NetworkLockSign signs the specified node-key and transmits that signature to the control plane.
1296-
// rotationPublic, if specified, must be an ed25519 public key.
1297-
func (lc *Client) NetworkLockSign(ctx context.Context, nodeKey key.NodePublic, rotationPublic []byte) error {
1298-
var b bytes.Buffer
1299-
type signRequest struct {
1300-
NodeKey key.NodePublic
1301-
RotationPublic []byte
1302-
}
1303-
1304-
if err := json.NewEncoder(&b).Encode(signRequest{NodeKey: nodeKey, RotationPublic: rotationPublic}); err != nil {
1305-
return err
1306-
}
1307-
1308-
if _, err := lc.send(ctx, "POST", "/localapi/v0/tka/sign", 200, &b); err != nil {
1309-
return fmt.Errorf("error: %w", err)
1310-
}
1311-
return nil
1312-
}
1313-
1314-
// NetworkLockAffectedSigs returns all signatures signed by the specified keyID.
1315-
func (lc *Client) NetworkLockAffectedSigs(ctx context.Context, keyID tkatype.KeyID) ([]tkatype.MarshaledSignature, error) {
1316-
body, err := lc.send(ctx, "POST", "/localapi/v0/tka/affected-sigs", 200, bytes.NewReader(keyID))
1317-
if err != nil {
1318-
return nil, fmt.Errorf("error: %w", err)
1319-
}
1320-
return decodeJSON[[]tkatype.MarshaledSignature](body)
1321-
}
1322-
1323-
// NetworkLockLog returns up to maxEntries number of changes to network-lock state.
1324-
func (lc *Client) NetworkLockLog(ctx context.Context, maxEntries int) ([]ipnstate.NetworkLockUpdate, error) {
1325-
v := url.Values{}
1326-
v.Set("limit", fmt.Sprint(maxEntries))
1327-
body, err := lc.send(ctx, "GET", "/localapi/v0/tka/log?"+v.Encode(), 200, nil)
1328-
if err != nil {
1329-
return nil, fmt.Errorf("error %w: %s", err, body)
1330-
}
1331-
return decodeJSON[[]ipnstate.NetworkLockUpdate](body)
1332-
}
1333-
1334-
// NetworkLockForceLocalDisable forcibly shuts down network lock on this node.
1335-
func (lc *Client) NetworkLockForceLocalDisable(ctx context.Context) error {
1336-
// This endpoint expects an empty JSON stanza as the payload.
1337-
var b bytes.Buffer
1338-
if err := json.NewEncoder(&b).Encode(struct{}{}); err != nil {
1339-
return err
1340-
}
1341-
1342-
if _, err := lc.send(ctx, "POST", "/localapi/v0/tka/force-local-disable", 200, &b); err != nil {
1343-
return fmt.Errorf("error: %w", err)
1344-
}
1345-
return nil
1346-
}
1347-
1348-
// NetworkLockVerifySigningDeeplink verifies the network lock deeplink contained
1349-
// in url and returns information extracted from it.
1350-
func (lc *Client) NetworkLockVerifySigningDeeplink(ctx context.Context, url string) (*tka.DeeplinkValidationResult, error) {
1351-
vr := struct {
1352-
URL string
1353-
}{url}
1354-
1355-
body, err := lc.send(ctx, "POST", "/localapi/v0/tka/verify-deeplink", 200, jsonBody(vr))
1356-
if err != nil {
1357-
return nil, fmt.Errorf("sending verify-deeplink: %w", err)
1358-
}
1359-
1360-
return decodeJSON[*tka.DeeplinkValidationResult](body)
1361-
}
1362-
1363-
// NetworkLockGenRecoveryAUM generates an AUM for recovering from a tailnet-lock key compromise.
1364-
func (lc *Client) NetworkLockGenRecoveryAUM(ctx context.Context, removeKeys []tkatype.KeyID, forkFrom tka.AUMHash) ([]byte, error) {
1365-
vr := struct {
1366-
Keys []tkatype.KeyID
1367-
ForkFrom string
1368-
}{removeKeys, forkFrom.String()}
1369-
1370-
body, err := lc.send(ctx, "POST", "/localapi/v0/tka/generate-recovery-aum", 200, jsonBody(vr))
1371-
if err != nil {
1372-
return nil, fmt.Errorf("sending generate-recovery-aum: %w", err)
1373-
}
1374-
1375-
return body, nil
1376-
}
1377-
1378-
// NetworkLockCosignRecoveryAUM co-signs a recovery AUM using the node's tailnet lock key.
1379-
func (lc *Client) NetworkLockCosignRecoveryAUM(ctx context.Context, aum tka.AUM) ([]byte, error) {
1380-
r := bytes.NewReader(aum.Serialize())
1381-
body, err := lc.send(ctx, "POST", "/localapi/v0/tka/cosign-recovery-aum", 200, r)
1382-
if err != nil {
1383-
return nil, fmt.Errorf("sending cosign-recovery-aum: %w", err)
1384-
}
1385-
1386-
return body, nil
1387-
}
1388-
1389-
// NetworkLockSubmitRecoveryAUM submits a recovery AUM to the control plane.
1390-
func (lc *Client) NetworkLockSubmitRecoveryAUM(ctx context.Context, aum tka.AUM) error {
1391-
r := bytes.NewReader(aum.Serialize())
1392-
_, err := lc.send(ctx, "POST", "/localapi/v0/tka/submit-recovery-aum", 200, r)
1393-
if err != nil {
1394-
return fmt.Errorf("sending cosign-recovery-aum: %w", err)
1395-
}
1396-
return nil
1397-
}
1398-
13991220
// SetServeConfig sets or replaces the serving settings.
14001221
// If config is nil, settings are cleared and serving is disabled.
14011222
func (lc *Client) SetServeConfig(ctx context.Context, config *ipn.ServeConfig) error {
@@ -1421,14 +1242,6 @@ func (lc *Client) DisconnectControl(ctx context.Context) error {
14211242
return nil
14221243
}
14231244

1424-
// NetworkLockDisable shuts down network-lock across the tailnet.
1425-
func (lc *Client) NetworkLockDisable(ctx context.Context, secret []byte) error {
1426-
if _, err := lc.send(ctx, "POST", "/localapi/v0/tka/disable", 200, bytes.NewReader(secret)); err != nil {
1427-
return fmt.Errorf("error: %w", err)
1428-
}
1429-
return nil
1430-
}
1431-
14321245
// GetServeConfig return the current serve config.
14331246
//
14341247
// If the serve config is empty, it returns (nil, nil).

0 commit comments

Comments
 (0)