-
Notifications
You must be signed in to change notification settings - Fork 11
/
devices.go
56 lines (47 loc) · 995 Bytes
/
devices.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
"iconsole/tunnel"
"github.com/urfave/cli"
)
func devicesAction(ctx *cli.Context) error {
devices, err := tunnel.Devices()
if err != nil {
return err
}
for _, d := range devices {
conn, err := tunnel.LockdownDial(d)
if err != nil {
return err
}
if err := conn.StartSession(); err != nil {
return err
}
deviceName, err := conn.DeviceName()
if err != nil {
return err
}
deviceType, err := conn.DeviceClass()
if err != nil {
return err
}
version, err := conn.ProductVersion()
if err != nil {
return err
}
fmt.Printf("%s %s %s\n\tConnectionType: %s\n\tUDID: %s\n", deviceType, deviceName, version, d.GetConnectionType(), d.GetSerialNumber())
if err := conn.StopSession(); err != nil {
return err
}
conn.Close()
}
return nil
}
func initDevices() cli.Command {
return cli.Command{
Name: "devices",
ShortName: "dev",
Usage: "List all connect devices",
Action: devicesAction,
}
}