diff --git a/v2/devices.go b/v2/devices.go index e4853ca..90879f0 100644 --- a/v2/devices.go +++ b/v2/devices.go @@ -44,25 +44,57 @@ func (t *Time) UnmarshalJSON(data []byte) error { return nil } +type DeviceClientConnectivityClientSupports struct { + HairPinning bool `json:"hairPinning"` + IPv6 bool `json:"ipv6"` + PCP bool `json:"pcp"` + PMP bool `json:"pmp"` + UDP bool `json:"udp"` + UPnP bool `json:"upnp"` +} + +type DeviceClientConnectivityLocationLatency struct { + Preferred bool `json:"preferred"` + LatencyMs float64 `json:"latencyMs"` +} + +type DeviceClientConnectivity struct { + Endpoints []string `json:"endpoints"` + MappingVariesByDestIP bool `json:"mappingVariesByDestIP"` + Latency map[string]DeviceClientConnectivityLocationLatency `json:"latency"` + ClientSupports DeviceClientConnectivityClientSupports `json:"clientSupports"` +} + +type DevicePostureIdentity struct { + Disabled bool `json:"disabled"` + SerialNumbers []string `json:"serialNumbers"` +} + type Device struct { - Addresses []string `json:"addresses"` - Name string `json:"name"` - ID string `json:"id"` - Authorized bool `json:"authorized"` - User string `json:"user"` - Tags []string `json:"tags"` - KeyExpiryDisabled bool `json:"keyExpiryDisabled"` - BlocksIncomingConnections bool `json:"blocksIncomingConnections"` - ClientVersion string `json:"clientVersion"` - Created Time `json:"created"` - Expires Time `json:"expires"` - Hostname string `json:"hostname"` - IsExternal bool `json:"isExternal"` - LastSeen Time `json:"lastSeen"` - MachineKey string `json:"machineKey"` - NodeKey string `json:"nodeKey"` - OS string `json:"os"` - UpdateAvailable bool `json:"updateAvailable"` + Addresses []string `json:"addresses"` + Name string `json:"name"` + ID string `json:"id"` + Authorized bool `json:"authorized"` + User string `json:"user"` + Tags []string `json:"tags"` + KeyExpiryDisabled bool `json:"keyExpiryDisabled"` + BlocksIncomingConnections bool `json:"blocksIncomingConnections"` + ClientVersion string `json:"clientVersion"` + Created Time `json:"created"` + Expires Time `json:"expires"` + Hostname string `json:"hostname"` + IsExternal bool `json:"isExternal"` + LastSeen Time `json:"lastSeen"` + MachineKey string `json:"machineKey"` + NodeKey string `json:"nodeKey"` + OS string `json:"os"` + UpdateAvailable bool `json:"updateAvailable"` + EnabledRoutes []string `json:"enabledRoutes"` + AdvertisedRoutes []string `json:"advertisedRoutes"` + ClientConnectivity DeviceClientConnectivity `json:"clientConnectivity"` + TailnetLockError string `json:"tailnetLockError"` + TailnetLockKey string `json:"tailnetLockKey"` + PostureIdentity DevicePostureIdentity `json:"postureIdentity"` } // Get gets the [Device] identified by deviceID. diff --git a/v2/devices_test.go b/v2/devices_test.go index 697ea07..484bc67 100644 --- a/v2/devices_test.go +++ b/v2/devices_test.go @@ -62,6 +62,27 @@ func TestClient_Devices_Get(t *testing.T) { NodeKey: "nodekey:test", OS: "windows", UpdateAvailable: true, + EnabledRoutes: []string{"10.0.0.0/16"}, + AdvertisedRoutes: []string{"10.0.0.0/16"}, + ClientConnectivity: tsclient.DeviceClientConnectivity{ + Endpoints: []string{"199.9.14.201:59128", "192.68.0.21:59128"}, + Latency: map[string]tsclient.DeviceClientConnectivityLocationLatency{"Dallas": {LatencyMs: 60.463043}, "New York City": {Preferred: true, LatencyMs: 31.323811}}, + MappingVariesByDestIP: false, + ClientSupports: tsclient.DeviceClientConnectivityClientSupports{ + HairPinning: false, + IPv6: true, + PCP: false, + PMP: false, + UDP: false, + UPnP: false, + }, + }, + TailnetLockError: "test", + TailnetLockKey: "test", + PostureIdentity: tsclient.DevicePostureIdentity{ + Disabled: false, + SerialNumbers: []string{"test"}, + }, } client, server := NewTestHarness(t) @@ -101,6 +122,27 @@ func TestClient_Devices_List(t *testing.T) { NodeKey: "nodekey:test", OS: "windows", UpdateAvailable: true, + EnabledRoutes: []string{"10.0.0.0/16"}, + AdvertisedRoutes: []string{"10.0.0.0/16"}, + ClientConnectivity: tsclient.DeviceClientConnectivity{ + Endpoints: []string{"199.9.14.201:59128", "192.68.0.21:59128"}, + Latency: map[string]tsclient.DeviceClientConnectivityLocationLatency{"Dallas": {LatencyMs: 60.463043}, "New York City": {Preferred: true, LatencyMs: 31.323811}}, + MappingVariesByDestIP: false, + ClientSupports: tsclient.DeviceClientConnectivityClientSupports{ + HairPinning: false, + IPv6: true, + PCP: false, + PMP: false, + UDP: false, + UPnP: false, + }, + }, + TailnetLockError: "test", + TailnetLockKey: "test", + PostureIdentity: tsclient.DevicePostureIdentity{ + Disabled: false, + SerialNumbers: []string{"test"}, + }, }, }, } @@ -171,12 +213,27 @@ func TestDevices_Unmarshal(t *testing.T) { LastSeen: tsclient.Time{ time.Date(2022, 4, 15, 13, 25, 21, 0, time.UTC), }, - MachineKey: "mkey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d", - Name: "foo.example.com", - NodeKey: "nodekey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d", - OS: "linux", - UpdateAvailable: false, - User: "foo@example.com", + MachineKey: "mkey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d", + Name: "foo.example.com", + NodeKey: "nodekey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d", + OS: "linux", + UpdateAvailable: false, + User: "foo@example.com", + EnabledRoutes: []string{"10.0.0.0/16", "192.168.1.0/24"}, + AdvertisedRoutes: []string{"10.0.0.0/16", "192.168.1.0/24"}, + ClientConnectivity: tsclient.DeviceClientConnectivity{ + Endpoints: []string{"199.9.14.201:59128", "192.68.0.21:59128"}, + Latency: map[string]tsclient.DeviceClientConnectivityLocationLatency{"Dallas": {LatencyMs: 60.463043}, "New York City": {Preferred: true, LatencyMs: 31.323811}}, + MappingVariesByDestIP: false, + ClientSupports: tsclient.DeviceClientConnectivityClientSupports{ + HairPinning: false, + IPv6: true, + PCP: false, + PMP: false, + UDP: false, + UPnP: false, + }, + }, }, }, }, diff --git a/v2/testdata/devices.json b/v2/testdata/devices.json index 71a4675..fab3cf1 100644 --- a/v2/testdata/devices.json +++ b/v2/testdata/devices.json @@ -42,7 +42,39 @@ "nodeKey": "nodekey:30dc3c061ac8b33fdc6d88a4a67b053b01b56930d78cae0cf7a164411d424c0d", "os": "linux", "updateAvailable": false, - "user": "foo@example.com" + "user": "foo@example.com", + "enabledRoutes": [ + "10.0.0.0/16", + "192.168.1.0/24" + ], + "advertisedRoutes": [ + "10.0.0.0/16", + "192.168.1.0/24" + ], + "clientConnectivity": { + "endpoints": [ + "199.9.14.201:59128", + "192.68.0.21:59128" + ], + "latency": { + "Dallas": { + "latencyMs": 60.463043 + }, + "New York City": { + "preferred": true, + "latencyMs": 31.323811 + } + }, + "mappingVariesByDestIP": false, + "clientSupports": { + "hairPinning": false, + "ipv6": true, + "pcp": false, + "pmp": false, + "udp": false, + "upnp": false + } + } } ] }