@trim21/personal-pi-extensions 0.1.438 → 0.1.439
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/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const FAKEIP_RANGE = "198.18.0.1/16";
|
|
2
|
-
|
|
2
|
+
/** TUN 与 slirp4netns tap0 共用;不对齐时大包会在 slirp NAT 后 PMTU blackhole。 */
|
|
3
|
+
export const TUN_MTU = 1500;
|
|
3
4
|
|
|
4
5
|
export interface MihomoConfigOptions {
|
|
5
6
|
/** 允许直连的条目列表(域名 / IP / CIDR,可带 :port;空列表 = 默认拒绝一切出网)。 */
|
|
@@ -158,6 +159,7 @@ function buildRules(allowlist: readonly string[]): BuiltRules {
|
|
|
158
159
|
*
|
|
159
160
|
* - auto-detect-interface 让 mihomo 出站绑定 slirp4netns 的 tap0,否则它自己的
|
|
160
161
|
* DNS 查询会被 auto_route 送回 TUN 形成环;
|
|
162
|
+
* - TUN mtu 与 slirp4netns `--mtu` 共用 TUN_MTU,避免依赖各自默认值;
|
|
161
163
|
* - allowlist 域名走 fake-ip-filter 真实解析(见 buildRules 注释)。
|
|
162
164
|
*/
|
|
163
165
|
export function generateMihomoConfig(options: MihomoConfigOptions): MihomoConfig {
|
|
@@ -4,7 +4,7 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
|
|
7
|
-
import { generateMihomoConfig } from "./mihomo-config.js";
|
|
7
|
+
import { generateMihomoConfig, TUN_MTU } from "./mihomo-config.js";
|
|
8
8
|
|
|
9
9
|
/** 命令超时错误:name=TimeoutError(对齐标准错误分类),message 保留 timeout:N 格式。 */
|
|
10
10
|
export class TimeoutError extends Error {
|
|
@@ -169,6 +169,7 @@ export async function startNetworkStack(options: NetworkStackOptions): Promise<N
|
|
|
169
169
|
slirp4netnsPath,
|
|
170
170
|
[
|
|
171
171
|
"-c",
|
|
172
|
+
`--mtu=${TUN_MTU}`,
|
|
172
173
|
`--userns-path=/proc/${holderPid}/ns/user`,
|
|
173
174
|
"--netns-type=pid",
|
|
174
175
|
String(holderPid),
|