ms-vite-plugin 1.5.9 → 1.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/api/device.md +5 -9
- package/docs/api/global.md +2 -2
- package/docs/api/jbclear.md +291 -0
- package/docs/api/jbdevice.md +574 -0
- package/docs/api/jbdylib.md +219 -0
- package/docs/api/jbshell.md +59 -0
- package/docs/api/jbsystem.md +211 -0
- package/docs/api/jbvpn.md +219 -0
- package/docs/api/pip.md +50 -15
- package/docs/api/plist.md +137 -0
- package/docs/api/ui.md +114 -0
- package/docs/apicn/device.md +4 -8
- package/docs/apicn/global.md +2 -2
- package/docs/apicn/pip.md +50 -15
- package/docs/apicn/ui.md +114 -0
- package/docs/apilua/device.md +5 -9
- package/docs/apilua/global.md +2 -2
- package/docs/apilua/jbclear.md +313 -0
- package/docs/apilua/jbdevice.md +609 -0
- package/docs/apilua/jbdylib.md +231 -0
- package/docs/apilua/jbshell.md +63 -0
- package/docs/apilua/jbsystem.md +225 -0
- package/docs/apilua/jbvpn.md +233 -0
- package/docs/apilua/pip.md +53 -15
- package/docs/apilua/plist.md +153 -0
- package/docs/apilua/ui.md +117 -0
- package/docs/apipython/device.md +6 -8
- package/docs/apipython/g.md +1 -1
- package/docs/apipython/jbclear.md +288 -0
- package/docs/apipython/jbdevice.md +570 -0
- package/docs/apipython/jbdylib.md +215 -0
- package/docs/apipython/jbshell.md +61 -0
- package/docs/apipython/jbsystem.md +216 -0
- package/docs/apipython/jbvpn.md +231 -0
- package/docs/apipython/overview.md +1 -1
- package/docs/apipython/pip.md +52 -15
- package/docs/apipython/plist.md +152 -0
- package/docs/apipython/ui.md +118 -0
- package/docs/httpapi/api.md +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# 动态库模块 (JBDylib)
|
|
2
|
+
|
|
3
|
+
仅越狱包可用。免越狱包没有 `jbdylib`。
|
|
4
|
+
|
|
5
|
+
把动态库放到脚本项目的 `res` 目录,用相对路径 `open`,再用 `define` / `defineAll` 绑定签名,之后按符号名调用。同一进程重复打开同一路径会复用已加载的库。未 `define` 的符号不能调用。C 符号名不能与 `define` / `defineAll` / `call` / `symbol` 重名。
|
|
6
|
+
|
|
7
|
+
## 类型
|
|
8
|
+
|
|
9
|
+
`retType` / `argTypes` 使用下面的类型名:
|
|
10
|
+
|
|
11
|
+
| 类型 | 说明 |
|
|
12
|
+
| ---- | ---- |
|
|
13
|
+
| `void` | 无返回值;调用成功时返回 `True` |
|
|
14
|
+
| `bool` | 布尔 |
|
|
15
|
+
| `int` | 32 位整数 |
|
|
16
|
+
| `uint` | 32 位无符号整数 |
|
|
17
|
+
| `int64` | 64 位整数 |
|
|
18
|
+
| `uint64` | 64 位无符号整数 |
|
|
19
|
+
| `float` | 32 位浮点 |
|
|
20
|
+
| `double` | 64 位浮点 |
|
|
21
|
+
| `string` | C 字符串 |
|
|
22
|
+
| `pointer` | 指针 |
|
|
23
|
+
|
|
24
|
+
只支持常见 C 标量类型。整数、指针、字符串参数合计最多 8 个,浮点参数最多 8 个。不支持结构体、C++ 方法和可变参数。指针用 `"0x..."` 字符串。
|
|
25
|
+
|
|
26
|
+
`defineAll` / `open` 第二参数里,每个函数可以写成:
|
|
27
|
+
|
|
28
|
+
| 写法 | 含义 |
|
|
29
|
+
| ---- | ---- |
|
|
30
|
+
| `"void"` 或 `["void"]` | 返回 `void`,无参数 |
|
|
31
|
+
| `["int", ["int", "int"]]` | 返回 `int`,两个 `int` 参数 |
|
|
32
|
+
| `["int", "int", "int"]` | 同上,参数类型也可以扁平写在返回类型后面 |
|
|
33
|
+
|
|
34
|
+
## API 参考
|
|
35
|
+
|
|
36
|
+
### open - 从 `res` 加载动态库,返回库对象。
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
def open(name: str, defs: Optional[Dict[str, Any]] = None) -> Optional[JbDylibLib]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**参数:**
|
|
43
|
+
|
|
44
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
45
|
+
| ------ | ---- | -------- | ------ | ------------------------------------------------------------ |
|
|
46
|
+
| `name` | str | 是 | - | 相对 `res` 的动态库路径,例如 `"mylib.dylib"` 或 `"libs/mylib.dylib"` |
|
|
47
|
+
| `defs` | dict | 否 | `None` | 打开后立刻批量绑定的函数表 |
|
|
48
|
+
|
|
49
|
+
**返回值:**
|
|
50
|
+
|
|
51
|
+
| 类型 | 描述 |
|
|
52
|
+
| ----------------------- | ---------------------------------- |
|
|
53
|
+
| `JbDylibLib \| None` | 加载成功返回库对象,失败返回 `None` |
|
|
54
|
+
|
|
55
|
+
**示例:**
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from kuaijs import jbdylib
|
|
59
|
+
|
|
60
|
+
lib = jbdylib.open("mylib.dylib", {
|
|
61
|
+
"mylib_add": ["int", ["int", "int"]],
|
|
62
|
+
"mylib_get_name": ["string"],
|
|
63
|
+
"mylib_touch": "void",
|
|
64
|
+
})
|
|
65
|
+
if lib:
|
|
66
|
+
print(lib.mylib_add(1, 2))
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### isLoaded - 查询动态库是否已加载。
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
def isLoaded(name: str) -> bool
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**参数:**
|
|
76
|
+
|
|
77
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
78
|
+
| ------ | ---- | -------- | ------ | ------------------------ |
|
|
79
|
+
| `name` | str | 是 | - | 相对 `res` 的动态库路径 |
|
|
80
|
+
|
|
81
|
+
**返回值:**
|
|
82
|
+
|
|
83
|
+
| 类型 | 描述 |
|
|
84
|
+
| ------ | ---------------------------- |
|
|
85
|
+
| `bool` | 已加载为 `True`,否则 `False` |
|
|
86
|
+
|
|
87
|
+
**示例:**
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
if not jbdylib.isLoaded("mylib.dylib"):
|
|
91
|
+
jbdylib.open("mylib.dylib")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 库对象
|
|
95
|
+
|
|
96
|
+
`open` 返回的库对象。先定义签名,再按符号名调用。
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from kuaijs._types import KuaiJSNamespace
|
|
100
|
+
|
|
101
|
+
class JbDylibLib(KuaiJSNamespace):
|
|
102
|
+
def define(self, symbol: str, retType: str, argTypes: Optional[List[str]] = None) -> bool: ...
|
|
103
|
+
def defineAll(self, specs: Dict[str, Any]) -> bool: ...
|
|
104
|
+
def call(self, symbol: str, *args: Any) -> Any: ...
|
|
105
|
+
def symbol(self, name: str) -> Optional[str]: ...
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### define - 绑定一个导出函数的签名。
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
def define(self, symbol: str, retType: str, argTypes: Optional[List[str]] = None) -> bool
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**参数:**
|
|
115
|
+
|
|
116
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
117
|
+
| ---------- | ------------------- | -------- | ------ | ------------------------------ |
|
|
118
|
+
| `symbol` | str | 是 | - | 导出符号名,例如 `"mylib_add"` |
|
|
119
|
+
| `retType` | str | 是 | - | 返回类型 |
|
|
120
|
+
| `argTypes` | `List[str] \| None` | 否 | `None` | 每个参数的类型,无参数时可省略 |
|
|
121
|
+
|
|
122
|
+
**返回值:**
|
|
123
|
+
|
|
124
|
+
| 类型 | 描述 |
|
|
125
|
+
| ------ | ---------------------------------------- |
|
|
126
|
+
| `bool` | 签名合法且符号存在为 `True`,否则 `False` |
|
|
127
|
+
|
|
128
|
+
**示例:**
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
lib = jbdylib.open("mylib.dylib")
|
|
132
|
+
lib.define("mylib_add", "int", ["int", "int"])
|
|
133
|
+
print(lib.mylib_add(1, 2))
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### defineAll - 批量绑定导出函数。
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
def defineAll(self, specs: Dict[str, Any]) -> bool
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**参数:**
|
|
143
|
+
|
|
144
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
145
|
+
| ------- | ---- | -------- | ------ | ------------------------ |
|
|
146
|
+
| `specs` | dict | 是 | - | 键为符号名,值为函数定义 |
|
|
147
|
+
|
|
148
|
+
**返回值:**
|
|
149
|
+
|
|
150
|
+
| 类型 | 描述 |
|
|
151
|
+
| ------ | ---------------------------------------------- |
|
|
152
|
+
| `bool` | 全部成功为 `True`;失败项会跳过,其余仍会绑定 |
|
|
153
|
+
|
|
154
|
+
**示例:**
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
lib.defineAll({
|
|
158
|
+
"mylib_add": ["int", ["int", "int"]],
|
|
159
|
+
"mylib_touch": "void",
|
|
160
|
+
})
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### call - 按已绑定签名调用导出函数。
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
def call(self, symbol: str, *args: Any) -> Any
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**参数:**
|
|
170
|
+
|
|
171
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
172
|
+
| -------- | ---- | -------- | ------ | -------------------------- |
|
|
173
|
+
| `symbol` | str | 是 | - | 已绑定的导出符号名 |
|
|
174
|
+
| `args` | Any | 否 | - | 与定义时参数类型对应的实参 |
|
|
175
|
+
|
|
176
|
+
**返回值:**
|
|
177
|
+
|
|
178
|
+
| 类型 | 描述 |
|
|
179
|
+
| ----- | ---------------------------------------------------- |
|
|
180
|
+
| `Any` | 调用成功返回结果;`void` 成功返回 `True`;失败返回 `None` |
|
|
181
|
+
|
|
182
|
+
**示例:**
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
sum = lib.call("mylib_add", 1, 2)
|
|
186
|
+
print(sum)
|
|
187
|
+
|
|
188
|
+
lib.define("mylib_touch", "void")
|
|
189
|
+
lib.call("mylib_touch")
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### symbol - 解析导出符号地址。
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
def symbol(self, name: str) -> Optional[str]
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**参数:**
|
|
199
|
+
|
|
200
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
201
|
+
| ------ | ---- | -------- | ------ | ---------- |
|
|
202
|
+
| `name` | str | 是 | - | 导出符号名 |
|
|
203
|
+
|
|
204
|
+
**返回值:**
|
|
205
|
+
|
|
206
|
+
| 类型 | 描述 |
|
|
207
|
+
| ------------- | ---------------------------------------- |
|
|
208
|
+
| `str \| None` | 成功返回 `"0x..."` 地址,失败返回 `None` |
|
|
209
|
+
|
|
210
|
+
**示例:**
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
addr = lib.symbol("mylib_add")
|
|
214
|
+
print(addr)
|
|
215
|
+
```
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# 终端模块 (JBShell)
|
|
2
|
+
|
|
3
|
+
仅越狱包可用。免越狱包没有 `jbshell`。
|
|
4
|
+
|
|
5
|
+
用 `exec` 执行一条 shell 命令,同步等到结束或超时,返回 `code`、`stdout`、`stderr`。命令走 `sh -c`。`stdout` / `stderr` 各最多 8MB。
|
|
6
|
+
|
|
7
|
+
## 类型
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from kuaijs._types import KuaiJSNamespace
|
|
11
|
+
|
|
12
|
+
class JbShellResult(KuaiJSNamespace):
|
|
13
|
+
code: int
|
|
14
|
+
stdout: str
|
|
15
|
+
stderr: str
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
| 字段 | 类型 | 描述 |
|
|
19
|
+
| -------- | ---- | -------------------------------------------- |
|
|
20
|
+
| `code` | int | 退出码;超时为 `-1`;被信号结束后为 `128 + 信号` |
|
|
21
|
+
| `stdout` | str | 标准输出文本 |
|
|
22
|
+
| `stderr` | str | 标准错误文本 |
|
|
23
|
+
|
|
24
|
+
## API 参考
|
|
25
|
+
|
|
26
|
+
### exec - 执行一条 shell 命令,等到结束或超时。
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
def exec(command: str, timeoutMs: Optional[int] = None) -> Optional[JbShellResult]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**参数:**
|
|
33
|
+
|
|
34
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
35
|
+
| ----------- | ---- | -------- | ------- | ---------------------------------------------- |
|
|
36
|
+
| `command` | str | 是 | - | 交给 `sh -c` 的命令 |
|
|
37
|
+
| `timeoutMs` | int | 否 | `30000` | 等待上限毫秒;`<= 0` 时用默认值,最长 `3600000` |
|
|
38
|
+
|
|
39
|
+
**返回值:**
|
|
40
|
+
|
|
41
|
+
| 类型 | 描述 |
|
|
42
|
+
| --------------------------- | ------------------------------------------------------------ |
|
|
43
|
+
| `JbShellResult \| None` | 启动成功返回结果;空命令或启动失败返回 `None`。超时仍返回已捕获输出,`code` 为 `-1` |
|
|
44
|
+
|
|
45
|
+
**示例:**
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from kuaijs import jbshell
|
|
49
|
+
|
|
50
|
+
r = jbshell.exec("printf hello")
|
|
51
|
+
if r:
|
|
52
|
+
print(r.code)
|
|
53
|
+
print(r.stdout)
|
|
54
|
+
|
|
55
|
+
failed = jbshell.exec("printf boom 1>&2; exit 7")
|
|
56
|
+
print(failed.code)
|
|
57
|
+
print(failed.stderr)
|
|
58
|
+
|
|
59
|
+
timed = jbshell.exec("sleep 5", 300)
|
|
60
|
+
print(timed.code)
|
|
61
|
+
```
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# 系统模块 (JBSystem)
|
|
2
|
+
|
|
3
|
+
仅越狱包可用。免越狱包没有 `jbsystem`。
|
|
4
|
+
|
|
5
|
+
`respring` 重启 SpringBoard。`reboot` 重启用户空间,不是重启整机。这两项调用后当前 App 和脚本通常会被系统结束。`restartSelf` 重启当前 App 进程,调用后当前脚本会结束,App 随后会被重新拉起。
|
|
6
|
+
|
|
7
|
+
还可读写「允许 App 请求跟踪」「个性化广告」和定位服务总开关。不同 iOS 版本中,这些设置项的名称或位置可能略有不同。
|
|
8
|
+
|
|
9
|
+
## API 参考
|
|
10
|
+
|
|
11
|
+
### respring - 重启 SpringBoard(Respring)。
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
def respring() -> bool
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**返回值:**
|
|
18
|
+
|
|
19
|
+
| 类型 | 描述 |
|
|
20
|
+
| ------ | ------------------------------- |
|
|
21
|
+
| `bool` | 成功为 `True` |
|
|
22
|
+
|
|
23
|
+
**示例:**
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from kuaijs import jbsystem
|
|
27
|
+
|
|
28
|
+
jbsystem.respring()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### reboot - 重启用户空间。
|
|
32
|
+
|
|
33
|
+
不是重启整机。
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
def reboot() -> bool
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**返回值:**
|
|
40
|
+
|
|
41
|
+
| 类型 | 描述 |
|
|
42
|
+
| ------ | ------------------------------- |
|
|
43
|
+
| `bool` | 成功为 `True` |
|
|
44
|
+
|
|
45
|
+
**示例:**
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from kuaijs import jbsystem
|
|
49
|
+
|
|
50
|
+
jbsystem.reboot()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### restartSelf - 重启当前 App 进程。
|
|
54
|
+
|
|
55
|
+
调用后当前脚本会结束,App 随后会被重新拉起。
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
def restartSelf() -> bool
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**返回值:**
|
|
62
|
+
|
|
63
|
+
| 类型 | 描述 |
|
|
64
|
+
| ------ | ----------------------- |
|
|
65
|
+
| `bool` | 成功为 `True` |
|
|
66
|
+
|
|
67
|
+
**示例:**
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from kuaijs import jbsystem
|
|
71
|
+
|
|
72
|
+
jbsystem.restartSelf()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### getUserTracking - 读取「允许 App 请求跟踪」总开关。
|
|
76
|
+
|
|
77
|
+
对应 `设置 > 隐私与安全性 > 跟踪 > 允许 App 请求跟踪`。
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
def getUserTracking() -> bool | None:
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**返回值:**
|
|
84
|
+
|
|
85
|
+
| 类型 | 描述 |
|
|
86
|
+
| --------------- | ------------------------------- |
|
|
87
|
+
| `bool \| None` | 当前是否允许;读失败返回 `None` |
|
|
88
|
+
|
|
89
|
+
**示例:**
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from kuaijs import jbsystem
|
|
93
|
+
|
|
94
|
+
allow = jbsystem.getUserTracking()
|
|
95
|
+
if isinstance(allow, bool):
|
|
96
|
+
jbsystem.setUserTracking(False)
|
|
97
|
+
jbsystem.setUserTracking(allow)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### setUserTracking - 设置「允许 App 请求跟踪」总开关。
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
def setUserTracking(enabled: bool) -> bool:
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**参数:**
|
|
107
|
+
|
|
108
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
109
|
+
| --------- | ---- | -------- | ------ | ---------------------------------------- |
|
|
110
|
+
| `enabled` | bool | 是 | - | `True` 允许 App 弹跟踪请求,`False` 不允许 |
|
|
111
|
+
|
|
112
|
+
**返回值:**
|
|
113
|
+
|
|
114
|
+
| 类型 | 描述 |
|
|
115
|
+
| ------ | ----------------------- |
|
|
116
|
+
| `bool` | 成功为 `True` |
|
|
117
|
+
|
|
118
|
+
**示例:**
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
jbsystem.setUserTracking(False)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### getPersonalizedAdvertising - 读取「个性化广告」开关。
|
|
125
|
+
|
|
126
|
+
对应 `设置 > 隐私与安全性 > Apple 广告 > 个性化广告`。
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
def getPersonalizedAdvertising() -> bool | None:
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**返回值:**
|
|
133
|
+
|
|
134
|
+
| 类型 | 描述 |
|
|
135
|
+
| --------------- | ------------------------------- |
|
|
136
|
+
| `bool \| None` | 当前是否允许;读失败返回 `None` |
|
|
137
|
+
|
|
138
|
+
**示例:**
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
allow = jbsystem.getPersonalizedAdvertising()
|
|
142
|
+
if isinstance(allow, bool):
|
|
143
|
+
jbsystem.setPersonalizedAdvertising(False)
|
|
144
|
+
jbsystem.setPersonalizedAdvertising(allow)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### setPersonalizedAdvertising - 设置「个性化广告」开关。
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
def setPersonalizedAdvertising(enabled: bool) -> bool:
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**参数:**
|
|
154
|
+
|
|
155
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
156
|
+
| --------- | ---- | -------- | ------ | ---------------------------------- |
|
|
157
|
+
| `enabled` | bool | 是 | - | `True` 允许个性化广告,`False` 不允许 |
|
|
158
|
+
|
|
159
|
+
**返回值:**
|
|
160
|
+
|
|
161
|
+
| 类型 | 描述 |
|
|
162
|
+
| ------ | ----------------------- |
|
|
163
|
+
| `bool` | 成功为 `True` |
|
|
164
|
+
|
|
165
|
+
**示例:**
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
jbsystem.setPersonalizedAdvertising(False)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### getLocationServices - 读取定位服务总开关。
|
|
172
|
+
|
|
173
|
+
对应 `设置 > 隐私与安全性 > 定位服务` 总开关。
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
def getLocationServices() -> bool | None:
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**返回值:**
|
|
180
|
+
|
|
181
|
+
| 类型 | 描述 |
|
|
182
|
+
| --------------- | ------------------------------- |
|
|
183
|
+
| `bool \| None` | 当前是否开启;读失败返回 `None` |
|
|
184
|
+
|
|
185
|
+
**示例:**
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
enabled = jbsystem.getLocationServices()
|
|
189
|
+
if isinstance(enabled, bool):
|
|
190
|
+
jbsystem.setLocationServices(False)
|
|
191
|
+
jbsystem.setLocationServices(enabled)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### setLocationServices - 设置定位服务总开关。
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
def setLocationServices(enabled: bool) -> bool:
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**参数:**
|
|
201
|
+
|
|
202
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
203
|
+
| --------- | ---- | -------- | ------ | ------------------------------ |
|
|
204
|
+
| `enabled` | bool | 是 | - | `True` 开启定位服务,`False` 关闭 |
|
|
205
|
+
|
|
206
|
+
**返回值:**
|
|
207
|
+
|
|
208
|
+
| 类型 | 描述 |
|
|
209
|
+
| ------ | ----------------------- |
|
|
210
|
+
| `bool` | 成功为 `True` |
|
|
211
|
+
|
|
212
|
+
**示例:**
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
jbsystem.setLocationServices(False)
|
|
216
|
+
```
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# VPN 模块 (JBVPN)
|
|
2
|
+
|
|
3
|
+
仅越狱包可用。免越狱包没有 `jbvpn`。
|
|
4
|
+
|
|
5
|
+
管理系统 VPN 配置:创建、列出、读取当前选中、选中、删除、连接、断开,以及读取当前选中配置的状态。类型支持 `L2TP`、`IPSec`、`IKEv2`。
|
|
6
|
+
|
|
7
|
+
`create` 必填显示名、类型和服务器。`select` / `remove` / `connect` 可传显示名,或 `list` 返回的 `id`。多条配置同名时不保证操作哪一条,精确操作请用 `id`。
|
|
8
|
+
|
|
9
|
+
`connect` / `disconnect` 返回 `True` 只表示已经开始,不表示已经连上或已经断开。用 `status` 看 `connected`。没有选中配置时,`connect()`、`disconnect()`、`status()` 失败。
|
|
10
|
+
|
|
11
|
+
## API 参考
|
|
12
|
+
|
|
13
|
+
### create - 创建一条系统 VPN 配置。
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
def create(config: dict) -> bool
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**参数:**
|
|
20
|
+
|
|
21
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
22
|
+
| -------- | ------ | -------- | ------ | ------------------------------------- |
|
|
23
|
+
| `config` | `dict` | 是 | - | 配置表。必填 `name`、`type`、`server` |
|
|
24
|
+
|
|
25
|
+
`config` 字段:
|
|
26
|
+
|
|
27
|
+
| 字段名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
28
|
+
| ----------------- | ------ | -------- | -------- | ------------------------------- |
|
|
29
|
+
| `name` | `str` | 是 | - | 显示名 |
|
|
30
|
+
| `type` | `str` | 是 | - | `L2TP` / `IPSec` / `IKEv2` |
|
|
31
|
+
| `server` | `str` | 是 | - | 服务器地址 |
|
|
32
|
+
| `account` | `str` | 否 | `""` | 账号 |
|
|
33
|
+
| `password` | `str` | 否 | `""` | 密码 |
|
|
34
|
+
| `secret` | `str` | 否 | `""` | 共享密钥。L2TP / IPSec 常用 |
|
|
35
|
+
| `group` | `str` | 否 | `""` | 群组名称 |
|
|
36
|
+
| `sendAllTraffic` | `bool` | 否 | `True` | 是否发送所有流量 |
|
|
37
|
+
| `encryptionLevel` | `int` | 否 | `1` | 加密级别 |
|
|
38
|
+
| `localId` | `str` | 否 | `""` | 本端标识。IKEv2 可用 |
|
|
39
|
+
| `remoteId` | `str` | 否 | `""` | 对端标识。IKEv2 可用 |
|
|
40
|
+
|
|
41
|
+
**返回值:**
|
|
42
|
+
|
|
43
|
+
| 类型 | 描述 |
|
|
44
|
+
| ------ | --------------- |
|
|
45
|
+
| `bool` | 成功为 `True` |
|
|
46
|
+
|
|
47
|
+
**示例:**
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from kuaijs import jbvpn
|
|
51
|
+
|
|
52
|
+
ok = jbvpn.create({
|
|
53
|
+
"name": "Demo",
|
|
54
|
+
"type": "L2TP",
|
|
55
|
+
"server": "vpn.example.com",
|
|
56
|
+
"account": "user",
|
|
57
|
+
"password": "pass",
|
|
58
|
+
"secret": "psk",
|
|
59
|
+
})
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### list - 列出当前系统 VPN 配置。
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
def list() -> list | None
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**返回值:**
|
|
69
|
+
|
|
70
|
+
| 类型 | 描述 |
|
|
71
|
+
| ------------- | --------------------------- |
|
|
72
|
+
| `list \| None` | 配置列表;读失败返回 `None` |
|
|
73
|
+
|
|
74
|
+
没有配置时是空列表。每项含 `name`、`id`。
|
|
75
|
+
|
|
76
|
+
**示例:**
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from kuaijs import jbvpn
|
|
80
|
+
|
|
81
|
+
items = jbvpn.list()
|
|
82
|
+
if items:
|
|
83
|
+
for item in items:
|
|
84
|
+
print(item.name, item.id)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### current - 读取当前选中的 VPN 配置。
|
|
88
|
+
|
|
89
|
+
没有选中配置返回 `None`。
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
def current() -> VpnItem | None
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**返回值:**
|
|
96
|
+
|
|
97
|
+
| 类型 | 描述 |
|
|
98
|
+
| ------------------ | ----------------------------------------- |
|
|
99
|
+
| `VpnItem \| None` | 含 `name`、`id`;没有选中配置返回 `None` |
|
|
100
|
+
|
|
101
|
+
**示例:**
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from kuaijs import jbvpn
|
|
105
|
+
|
|
106
|
+
item = jbvpn.current()
|
|
107
|
+
if item:
|
|
108
|
+
print(item.name, item.id)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### select - 选中一条 VPN 配置。
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
def select(nameOrId: str) -> bool
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**参数:**
|
|
118
|
+
|
|
119
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
120
|
+
| ----------- | ----- | -------- | ------ | ----------------------- |
|
|
121
|
+
| `nameOrId` | `str` | 是 | - | 显示名或 `list` 的 `id` |
|
|
122
|
+
|
|
123
|
+
**返回值:**
|
|
124
|
+
|
|
125
|
+
| 类型 | 描述 |
|
|
126
|
+
| ------ | --------------------- |
|
|
127
|
+
| `bool` | 找到并选中为 `True` |
|
|
128
|
+
|
|
129
|
+
**示例:**
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from kuaijs import jbvpn
|
|
133
|
+
|
|
134
|
+
jbvpn.select("Demo")
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### remove - 删除一条 VPN 配置。
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
def remove(nameOrId: str) -> bool
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**参数:**
|
|
144
|
+
|
|
145
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
146
|
+
| ----------- | ----- | -------- | ------ | ----------------------- |
|
|
147
|
+
| `nameOrId` | `str` | 是 | - | 显示名或 `list` 的 `id` |
|
|
148
|
+
|
|
149
|
+
**返回值:**
|
|
150
|
+
|
|
151
|
+
| 类型 | 描述 |
|
|
152
|
+
| ------ | --------------------- |
|
|
153
|
+
| `bool` | 找到并删除为 `True` |
|
|
154
|
+
|
|
155
|
+
**示例:**
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
from kuaijs import jbvpn
|
|
159
|
+
|
|
160
|
+
jbvpn.remove("Demo")
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### connect - 连接 VPN。
|
|
164
|
+
|
|
165
|
+
传入显示名或 `id` 时先选中再连接;省略则连接当前选中的配置。
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
def connect(nameOrId: str | None = None) -> bool
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**参数:**
|
|
172
|
+
|
|
173
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
174
|
+
| ----------- | ------------- | -------- | ------ | ----------------------------- |
|
|
175
|
+
| `nameOrId` | `str \| None` | 否 | - | 显示名或 `id`;省略用当前选中 |
|
|
176
|
+
|
|
177
|
+
**返回值:**
|
|
178
|
+
|
|
179
|
+
| 类型 | 描述 |
|
|
180
|
+
| ------ | --------------------------------- |
|
|
181
|
+
| `bool` | 开始连接为 `True`,不是已经连上 |
|
|
182
|
+
|
|
183
|
+
**示例:**
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from kuaijs import jbvpn
|
|
187
|
+
|
|
188
|
+
jbvpn.connect("Demo")
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### disconnect - 断开当前 VPN 连接。
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
def disconnect() -> bool
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**返回值:**
|
|
198
|
+
|
|
199
|
+
| 类型 | 描述 |
|
|
200
|
+
| ------ | --------------------------------- |
|
|
201
|
+
| `bool` | 开始断开为 `True`,不是已经断开 |
|
|
202
|
+
|
|
203
|
+
**示例:**
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
from kuaijs import jbvpn
|
|
207
|
+
|
|
208
|
+
jbvpn.disconnect()
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### status - 读取当前选中 VPN 的状态。
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
def status() -> VpnStatus | None
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**返回值:**
|
|
218
|
+
|
|
219
|
+
| 类型 | 描述 |
|
|
220
|
+
| ------------------ | --------------------------------------------- |
|
|
221
|
+
| `VpnStatus \| None` | 含 `text`、`connected`;没有选中配置返回 `None` |
|
|
222
|
+
|
|
223
|
+
**示例:**
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from kuaijs import jbvpn
|
|
227
|
+
|
|
228
|
+
st = jbvpn.status()
|
|
229
|
+
if st and st.connected:
|
|
230
|
+
print(st.text)
|
|
231
|
+
```
|