Skip to content

Commit 18edbb5

Browse files
authored
Expose more fields on Device (#10)
This commit adds the following exported fields to the `Device` type. It will allow us to collect device-related metrics and manage devices using this client library. - `BlocksIncomingConnections` - `ClientVersion` - `Created` - `Expires` - `Hostname` - `IsExternal` - `LastSeen` - `MachineKey` - `NodeKey` - `OS` - `UpdateAvailable` Signed-off-by: Yohei Kanemaru <[email protected]>
1 parent c63503b commit 18edbb5

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

tailscale/client.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,24 @@ func (c *Client) DeviceSubnetRoutes(ctx context.Context, deviceID string) (*Devi
355355
}
356356

357357
type Device struct {
358-
Addresses []string `json:"addresses"`
359-
Name string `json:"name"`
360-
ID string `json:"id"`
361-
Authorized bool `json:"authorized"`
362-
User string `json:"user"`
363-
Tags []string `json:"tags"`
364-
KeyExpiryDisabled bool `json:"keyExpiryDisabled"`
358+
Addresses []string `json:"addresses"`
359+
Name string `json:"name"`
360+
ID string `json:"id"`
361+
Authorized bool `json:"authorized"`
362+
User string `json:"user"`
363+
Tags []string `json:"tags"`
364+
KeyExpiryDisabled bool `json:"keyExpiryDisabled"`
365+
BlocksIncomingConnections bool `json:"blocksIncomingConnections"`
366+
ClientVersion string `json:"clientVersion"`
367+
Created time.Time `json:"created"`
368+
Expires time.Time `json:"expires"`
369+
Hostname string `json:"hostname"`
370+
IsExternal bool `json:"isExternal"`
371+
LastSeen time.Time `json:"lastSeen"`
372+
MachineKey string `json:"machineKey"`
373+
NodeKey string `json:"nodeKey"`
374+
OS string `json:"os"`
375+
UpdateAvailable bool `json:"updateAvailable"`
365376
}
366377

367378
// Devices lists the devices in a tailnet.

tailscale/client_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,17 @@ func TestClient_Devices(t *testing.T) {
281281
Tags: []string{
282282
"tag:value",
283283
},
284+
BlocksIncomingConnections: false,
285+
ClientVersion: "1.22.1",
286+
Created: time.Date(2022, 2, 10, 11, 50, 23, 0, time.UTC),
287+
Expires: time.Date(2022, 8, 9, 11, 50, 23, 0, time.UTC),
288+
Hostname: "test",
289+
IsExternal: false,
290+
LastSeen: time.Date(2022, 3, 9, 20, 3, 42, 0, time.UTC),
291+
MachineKey: "mkey:test",
292+
NodeKey: "nodekey:test",
293+
OS: "windows",
294+
UpdateAvailable: true,
284295
},
285296
},
286297
}

0 commit comments

Comments
 (0)