proxylang 0.9.1 → 0.10.0

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/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { K as requestSchema, L as targetCatalog, M as compile, N as explain, V as StaticRuleSetUnknownError, Z as definitionDiagnostic, i as buildToDirectory, n as defineBuild, r as runBuild, t as checkBuild } from "./profile-build-Cyrem-0-.js";
2
+ import { K as requestSchema, L as targetCatalog, M as compile, N as explain, V as StaticRuleSetUnknownError, Z as definitionDiagnostic, i as buildToDirectory, n as defineBuild, r as runBuild, t as checkBuild } from "./profile-build-B04BpEx3.js";
3
3
  import { lstat, open, stat } from "node:fs/promises";
4
4
  import { resolve } from "node:path";
5
5
  import { pathToFileURL } from "node:url";
package/dist/index.d.ts CHANGED
@@ -129,6 +129,15 @@ export type AnyTLSNode = ProxyBase & {
129
129
  readonly skipCertVerify?: boolean;
130
130
  readonly surge?: SurgeAutomaticUdpOptions;
131
131
  };
132
+ export type Hysteria2Node = Omit<ProxyBase, "tcpFastOpen"> & {
133
+ readonly type: "hysteria2";
134
+ readonly tcpFastOpen?: never;
135
+ readonly password: Secret;
136
+ readonly serverName?: string;
137
+ readonly skipCertVerify?: boolean;
138
+ readonly portHopping?: string;
139
+ readonly portHoppingInterval?: number;
140
+ };
132
141
  export type HttpNode = ProxyBase & {
133
142
  readonly type: "http";
134
143
  readonly serverName?: never;
@@ -154,7 +163,7 @@ export type VLESSNode = ProxyBase & {
154
163
  readonly tls?: ProxyTLS;
155
164
  readonly transport?: WebSocketTransport;
156
165
  };
157
- export type ProxyNode = TrojanNode | AnyTLSNode | HttpNode | ShadowsocksNode | VMessNode | VLESSNode;
166
+ export type ProxyNode = TrojanNode | AnyTLSNode | Hysteria2Node | HttpNode | ShadowsocksNode | VMessNode | VLESSNode;
158
167
  export type TailscaleEndpoint = {
159
168
  readonly type: "sing-box-tailscale";
160
169
  readonly id: string;
@@ -523,7 +532,7 @@ export declare const targetCatalog: readonly [{
523
532
  readonly version: "1.11.0";
524
533
  readonly autoGroup: "urltest";
525
534
  readonly platforms: readonly ["linux", "macos"];
526
- readonly protocols: readonly ["trojan", "http", "shadowsocks", "vmess", "vless"];
535
+ readonly protocols: readonly ["hysteria2", "trojan", "http", "shadowsocks", "vmess", "vless"];
527
536
  readonly endpoints: readonly [];
528
537
  readonly groups: readonly ["select", "urltest"];
529
538
  readonly nativeRuleSets: readonly ["source", "binary"];
@@ -533,7 +542,7 @@ export declare const targetCatalog: readonly [{
533
542
  readonly version: "1.12.0";
534
543
  readonly autoGroup: "urltest";
535
544
  readonly platforms: readonly ["linux", "macos"];
536
- readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
545
+ readonly protocols: readonly ["hysteria2", "trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
537
546
  readonly endpoints: readonly ["sing-box-tailscale"];
538
547
  readonly groups: readonly ["select", "urltest"];
539
548
  readonly nativeRuleSets: readonly ["source", "binary"];
@@ -543,7 +552,7 @@ export declare const targetCatalog: readonly [{
543
552
  readonly version: "6.10.0";
544
553
  readonly autoGroup: "surge-smart";
545
554
  readonly platforms: readonly ["macos"];
546
- readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
555
+ readonly protocols: readonly ["hysteria2", "trojan", "http", "anytls", "shadowsocks", "vmess"];
547
556
  readonly endpoints: readonly [];
548
557
  readonly groups: readonly ["select", "surge-smart"];
549
558
  readonly nativeRuleSets: readonly ["rule-set", "domain-set"];
@@ -553,7 +562,7 @@ export declare const targetCatalog: readonly [{
553
562
  readonly version: "1.19.32";
554
563
  readonly autoGroup: "urltest";
555
564
  readonly platforms: readonly ["linux", "macos"];
556
- readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
565
+ readonly protocols: readonly ["hysteria2", "trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
557
566
  readonly endpoints: readonly [];
558
567
  readonly groups: readonly ["select", "urltest"];
559
568
  readonly nativeRuleSets: readonly ["yaml", "text"];
@@ -563,7 +572,7 @@ export declare const targetCatalog: readonly [{
563
572
  readonly version: "4.2.1";
564
573
  readonly autoGroup: null;
565
574
  readonly platforms: readonly ["macos"];
566
- readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
575
+ readonly protocols: readonly ["hysteria2", "trojan", "http", "anytls", "shadowsocks", "vmess"];
567
576
  readonly endpoints: readonly [];
568
577
  readonly groups: readonly ["select"];
569
578
  readonly nativeRuleSets: readonly [];
@@ -984,6 +993,7 @@ export declare const proxy: {
984
993
  http: (options: Omit<HttpNode, "type">) => HttpNode;
985
994
  trojan: (options: Omit<TrojanNode, "type">) => TrojanNode;
986
995
  anytls: (options: Omit<AnyTLSNode, "type">) => AnyTLSNode;
996
+ hysteria2: (options: Omit<Hysteria2Node, "type">) => Hysteria2Node;
987
997
  shadowsocks: (options: Omit<ShadowsocksNode, "type">) => ShadowsocksNode;
988
998
  vmess: (options: Omit<VMessNode, "type">) => VMessNode;
989
999
  vless: (options: Omit<VLESSNode, "type">) => VLESSNode;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as inspectDefinition, A as renderSurgeProfiles, B as validateProxyOptions, C as strategy, D as defineProfile, E as compileProfile, F as isReservedNativeName, G as nodeSchema, H as assertData, I as nativeNameSchema, J as defineProxyGroup, L as targetCatalog, M as compile, N as explain, O as compileSurgeProfile, P as compileStrategyGroups, Q as exactDefinition, R as RenderError, S as slot, T as use, U as deepFreeze, V as StaticRuleSetUnknownError, W as idSchema, X as defineRoutes, Y as defineRoute, _ as rule, a as render, b as sequence, c as direct, d as match, et as outbound, f as mihomo, g as route, h as reject, i as buildToDirectory, j as secretReader, k as renderSurgeProfile, l as dnsRule, m as proxy, n as defineBuild, o as block, p as policy, q as ProfileDefinitionError, r as runBuild, s as defineConfig, t as checkBuild, u as group, v as ruleSet, w as surge, x as singbox, y as secret, z as surgeProxy } from "./profile-build-Cyrem-0-.js";
1
+ import { $ as inspectDefinition, A as renderSurgeProfiles, B as validateProxyOptions, C as strategy, D as defineProfile, E as compileProfile, F as isReservedNativeName, G as nodeSchema, H as assertData, I as nativeNameSchema, J as defineProxyGroup, L as targetCatalog, M as compile, N as explain, O as compileSurgeProfile, P as compileStrategyGroups, Q as exactDefinition, R as RenderError, S as slot, T as use, U as deepFreeze, V as StaticRuleSetUnknownError, W as idSchema, X as defineRoutes, Y as defineRoute, _ as rule, a as render, b as sequence, c as direct, d as match, et as outbound, f as mihomo, g as route, h as reject, i as buildToDirectory, j as secretReader, k as renderSurgeProfile, l as dnsRule, m as proxy, n as defineBuild, o as block, p as policy, q as ProfileDefinitionError, r as runBuild, s as defineConfig, t as checkBuild, u as group, v as ruleSet, w as surge, x as singbox, y as secret, z as surgeProxy } from "./profile-build-B04BpEx3.js";
2
2
  import { z } from "zod";
3
3
  import { createHash } from "node:crypto";
4
4
  //#region src/proxy-fragments.ts
@@ -637,6 +637,10 @@ const surgeOptions$1 = { blockQuic: z.enum([
637
637
  "on",
638
638
  "off"
639
639
  ]).optional() };
640
+ const portHoppingSchema = z.string().max(2048).regex(/^[0-9]+(?:-[0-9]+)?(?:;[0-9]+(?:-[0-9]+)?)*$/).refine((value) => value.split(";").every((part) => {
641
+ const [start, end = start] = part.split("-").map(Number);
642
+ return start !== void 0 && end !== void 0 && start >= 1 && end <= 65535 && start <= end;
643
+ }));
640
644
  const nodeSchema = z.discriminatedUnion("type", [
641
645
  z.strictObject({
642
646
  ...nodeBase,
@@ -660,6 +664,16 @@ const nodeSchema = z.discriminatedUnion("type", [
660
664
  udpRelay: z.literal(true).optional()
661
665
  }).optional()
662
666
  }),
667
+ z.strictObject({
668
+ ...nodeBase,
669
+ type: z.literal("hysteria2"),
670
+ tcpFastOpen: z.never().optional(),
671
+ password: secretSchema,
672
+ serverName: domain$1.optional(),
673
+ skipCertVerify: z.boolean().optional(),
674
+ portHopping: portHoppingSchema.optional(),
675
+ portHoppingInterval: z.number().int().positive().optional()
676
+ }).refine((node) => node.portHoppingInterval === void 0 || node.portHopping !== void 0),
663
677
  z.strictObject({
664
678
  ...nodeBase,
665
679
  type: z.literal("http"),
@@ -1182,6 +1196,16 @@ function nodeIsTcpOnly(node, engine) {
1182
1196
  return node.type === "http" || node.type === "anytls" && engine !== "surge" || node.type === "vmess" || node.type === "vless" || engine === "surge" && node.type === "shadowsocks" && node.surge?.udpRelay === false;
1183
1197
  }
1184
1198
  function validateProxyOptions(node, target, diagnostics) {
1199
+ if (node.type === "hysteria2") {
1200
+ if (target.engine === "surge" && node.portHopping && node.via) diagnostics.push({
1201
+ severity: "error",
1202
+ code: "PROXY_OPTION_UNSUPPORTED",
1203
+ target: target.id,
1204
+ path: `targets.${target.id}.nodes.${node.id}`,
1205
+ message: "Surge 端口跳跃不能与 underlying-proxy 同用"
1206
+ });
1207
+ return;
1208
+ }
1185
1209
  const tls = "tls" in node ? node.tls : void 0;
1186
1210
  if (target.engine !== "surge") {
1187
1211
  if (node.tcpFastOpen !== void 0 || "skipCertVerify" in node && node.skipCertVerify !== void 0 || tls?.skipCertVerify !== void 0 || "surge" in node && node.surge !== void 0) diagnostics.push({
@@ -1215,6 +1239,19 @@ function singboxProxy(node, secret) {
1215
1239
  ...node.via ? { detour: node.via } : {}
1216
1240
  };
1217
1241
  switch (node.type) {
1242
+ case "hysteria2":
1243
+ result.password = secret(node.password);
1244
+ result.tls = {
1245
+ enabled: true,
1246
+ ...node.serverName ? { server_name: node.serverName } : {},
1247
+ ...node.skipCertVerify !== void 0 ? { insecure: node.skipCertVerify } : {}
1248
+ };
1249
+ if (node.portHopping) {
1250
+ delete result.server_port;
1251
+ result.server_ports = node.portHopping.split(";").map((part) => part.includes("-") ? part.replace("-", ":") : `${part}:${part}`);
1252
+ }
1253
+ if (node.portHoppingInterval !== void 0) result.hop_interval = `${node.portHoppingInterval}s`;
1254
+ break;
1218
1255
  case "http":
1219
1256
  result.password = secret(node.password);
1220
1257
  if (node.username) result.username = secret(node.username);
@@ -1262,6 +1299,13 @@ function clashProxy(node, engine, secret) {
1262
1299
  ...engine === "stash" ? { "block-quic": "off" } : {}
1263
1300
  };
1264
1301
  switch (node.type) {
1302
+ case "hysteria2":
1303
+ result[engine === "stash" ? "auth" : "password"] = secret(node.password);
1304
+ if (node.serverName) result.sni = node.serverName;
1305
+ if (node.skipCertVerify !== void 0) result["skip-cert-verify"] = node.skipCertVerify;
1306
+ if (node.portHopping) result.ports = node.portHopping.replaceAll(";", ",");
1307
+ if (node.portHoppingInterval !== void 0) result["hop-interval"] = node.portHoppingInterval;
1308
+ break;
1265
1309
  case "http":
1266
1310
  result.password = secret(node.password);
1267
1311
  if (node.username) result.username = secret(node.username);
@@ -1315,6 +1359,13 @@ function surgeProxy(node, secret, name = (id) => id) {
1315
1359
  if (node.username) params.push(`username=${atom(secret(node.username))}`);
1316
1360
  params.push(`password=${atom(secret(node.password))}`);
1317
1361
  break;
1362
+ case "hysteria2":
1363
+ params.push(`password=${atom(secret(node.password))}`);
1364
+ if (node.serverName) params.push(`sni=${node.serverName}`);
1365
+ if (node.skipCertVerify !== void 0) params.push(`skip-cert-verify=${node.skipCertVerify}`);
1366
+ if (node.portHopping) params.push(`port-hopping=${node.portHopping}`);
1367
+ if (node.portHoppingInterval !== void 0) params.push(`port-hopping-interval=${node.portHoppingInterval}`);
1368
+ break;
1318
1369
  case "trojan":
1319
1370
  case "anytls":
1320
1371
  params.push(`password=${atom(secret(node.password))}`);
@@ -1447,6 +1498,7 @@ const targetCatalog = deepFreeze([
1447
1498
  autoGroup: "urltest",
1448
1499
  platforms: ["linux", "macos"],
1449
1500
  protocols: [
1501
+ "hysteria2",
1450
1502
  "trojan",
1451
1503
  "http",
1452
1504
  "shadowsocks",
@@ -1464,6 +1516,7 @@ const targetCatalog = deepFreeze([
1464
1516
  autoGroup: "urltest",
1465
1517
  platforms: ["linux", "macos"],
1466
1518
  protocols: [
1519
+ "hysteria2",
1467
1520
  "trojan",
1468
1521
  "http",
1469
1522
  "anytls",
@@ -1482,6 +1535,7 @@ const targetCatalog = deepFreeze([
1482
1535
  autoGroup: "surge-smart",
1483
1536
  platforms: ["macos"],
1484
1537
  protocols: [
1538
+ "hysteria2",
1485
1539
  "trojan",
1486
1540
  "http",
1487
1541
  "anytls",
@@ -1499,6 +1553,7 @@ const targetCatalog = deepFreeze([
1499
1553
  autoGroup: "urltest",
1500
1554
  platforms: ["linux", "macos"],
1501
1555
  protocols: [
1556
+ "hysteria2",
1502
1557
  "trojan",
1503
1558
  "http",
1504
1559
  "anytls",
@@ -1517,6 +1572,7 @@ const targetCatalog = deepFreeze([
1517
1572
  autoGroup: null,
1518
1573
  platforms: ["macos"],
1519
1574
  protocols: [
1575
+ "hysteria2",
1520
1576
  "trojan",
1521
1577
  "http",
1522
1578
  "anytls",
@@ -3019,6 +3075,7 @@ const proxy = {
3019
3075
  http: nodeConstructor("http"),
3020
3076
  trojan: nodeConstructor("trojan"),
3021
3077
  anytls: nodeConstructor("anytls"),
3078
+ hysteria2: nodeConstructor("hysteria2"),
3022
3079
  shadowsocks: nodeConstructor("shadowsocks"),
3023
3080
  vmess: nodeConstructor("vmess"),
3024
3081
  vless: nodeConstructor("vless")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proxylang",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "Composable routing policies in TypeScript with explicit platform targets",
5
5
  "homepage": "https://github.com/CorrectRoadH/proxylang#readme",
6
6
  "bugs": {