-
Notifications
You must be signed in to change notification settings - Fork 11
/
wifiSync.go
71 lines (60 loc) · 1.47 KB
/
wifiSync.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"fmt"
"iconsole/tunnel"
"github.com/urfave/cli"
)
func edAction(ctx *cli.Context, ed bool) error {
udid := ctx.String("UDID")
return session(udid, func(conn *tunnel.LockdownConnection) error {
if resp, err := conn.SetValue("com.apple.mobile.wireless_lockdown", "EnableWifiConnections", ed); err != nil {
return err
} else if resp.Value.(bool) == ed {
fmt.Println("Succeed")
} else {
fmt.Println("Failed")
}
return nil
})
}
func syncEnableAction(ctx *cli.Context) error {
return edAction(ctx, true)
}
func syncDisableAction(ctx *cli.Context) error {
return edAction(ctx, false)
}
func syncAction(ctx *cli.Context) error {
udid := ctx.String("UDID")
return session(udid, func(conn *tunnel.LockdownConnection) error {
if resp, err := conn.GetValue("com.apple.mobile.wireless_lockdown", "EnableWifiConnections"); err != nil {
return err
} else if resp.Value.(bool) {
fmt.Println("Device enable WiFi connections")
} else {
fmt.Println("Device disable WiFi connections")
}
return nil
})
}
func initSyncCommond() cli.Command {
return cli.Command{
Name: "sync",
Usage: "Enable Wi-Fi sync or disable",
Action: syncAction,
Flags: globalFlags,
Subcommands: []cli.Command{
{
Name: "enable",
ShortName: "e",
Action: syncEnableAction,
Flags: globalFlags,
},
{
Name: "disable",
ShortName: "d",
Action: syncDisableAction,
Flags: globalFlags,
},
},
}
}