ddan-js 2.8.9 → 2.8.11

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.
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Mapping = exports.KValue = exports.Event = exports.dLogger = exports.dTracker = exports.dJoker = exports.dStore = exports.dCdn = exports.dMini = exports.dWeb = exports.dHook = exports.dUtil = void 0;
4
+ const gbk_1 = require("./modules/gbk");
5
+ const time_1 = require("./modules/time");
6
+ const hook_1 = require("./modules/hook");
7
+ const math_1 = require("./modules/math");
8
+ const util_1 = require("./util");
9
+ const list_1 = require("./modules/list");
10
+ const mini_1 = require("./modules/mini");
11
+ const qs_1 = require("./modules/qs");
12
+ const rule_1 = require("./modules/rule");
13
+ const regex_1 = require("./modules/regex");
14
+ const string_1 = require("./modules/string");
15
+ const obj_1 = require("./modules/obj");
16
+ const crypto_1 = require("./modules/crypto");
17
+ const css_1 = require("./modules/css");
18
+ const html_1 = require("./modules/html");
19
+ const cdn_1 = require("./modules/cdn");
20
+ const convert_1 = require("./modules/convert");
21
+ const http_1 = require("./modules/http");
22
+ const logger_1 = require("./modules/logger");
23
+ const fetch_1 = require("./modules/fetch");
24
+ const icon_1 = require("./class/icon");
25
+ const event_1 = require("./class/event");
26
+ exports.Event = event_1.default;
27
+ const store_1 = require("./class/store");
28
+ const persist_1 = require("./class/persist");
29
+ const watermark_1 = require("./class/watermark");
30
+ const joker_1 = require("./class/joker");
31
+ const tracker_1 = require("./class/tracker");
32
+ const rsa_1 = require("./modules/rsa");
33
+ const browser_1 = require("./modules/browser");
34
+ const kvalue_1 = require("./class/kvalue");
35
+ exports.KValue = kvalue_1.default;
36
+ const mapping_1 = require("./class/mapping");
37
+ exports.Mapping = mapping_1.default;
38
+ const dUtil = {
39
+ gbk: gbk_1.default,
40
+ math: math_1.default,
41
+ list: list_1.default,
42
+ string: string_1.default,
43
+ time: time_1.default,
44
+ obj: obj_1.default,
45
+ rule: rule_1.default,
46
+ regex: regex_1.default,
47
+ ...convert_1.default,
48
+ ...crypto_1.default,
49
+ ...util_1.default,
50
+ Event: event_1.default,
51
+ };
52
+ exports.dUtil = dUtil;
53
+ const singleton = util_1.default.singleton;
54
+ const dHook = {
55
+ ...convert_1.default,
56
+ ...crypto_1.default,
57
+ ...hook_1.default,
58
+ ...string_1.default,
59
+ ...math_1.default,
60
+ qs: qs_1.default,
61
+ singleton,
62
+ };
63
+ exports.dHook = dHook;
64
+ const dMini = { mini: mini_1.default, css: css_1.default, qs: qs_1.default, icon: icon_1.default, html: html_1.default };
65
+ exports.dMini = dMini;
66
+ const dCdn = { cdn: cdn_1.default, watermark: watermark_1.default };
67
+ exports.dCdn = dCdn;
68
+ const dStore = { Store: store_1.default, storeRef: store_1.storeRef, Persist: persist_1.default, persistConfig: persist_1.persistConfig };
69
+ exports.dStore = dStore;
70
+ const dJoker = joker_1.default;
71
+ exports.dJoker = dJoker;
72
+ const dTracker = tracker_1.default;
73
+ exports.dTracker = dTracker;
74
+ const dLogger = logger_1.default;
75
+ exports.dLogger = dLogger;
76
+ const dWeb = { fetch: fetch_1.default, Http: http_1.default, css: css_1.default, qs: qs_1.default, icon: icon_1.default, html: html_1.default, rsa: rsa_1.default, ...browser_1.default };
77
+ exports.dWeb = dWeb;
78
+ exports.default = {
79
+ gbk: gbk_1.default,
80
+ time: time_1.default,
81
+ hook: hook_1.default,
82
+ math: math_1.default,
83
+ util: util_1.default,
84
+ list: list_1.default,
85
+ string: string_1.default,
86
+ obj: obj_1.default,
87
+ crypto: crypto_1.default,
88
+ mini: mini_1.default,
89
+ qs: qs_1.default,
90
+ css: css_1.default,
91
+ cdn: cdn_1.default,
92
+ html: html_1.default,
93
+ icon: icon_1.default,
94
+ rule: rule_1.default,
95
+ regex: regex_1.default,
96
+ convert: convert_1.default,
97
+ KValue: kvalue_1.default,
98
+ Mapping: mapping_1.default,
99
+ Event: event_1.default,
100
+ Http: http_1.default,
101
+ Store: store_1.default,
102
+ storeRef: store_1.storeRef,
103
+ Persist: persist_1.default,
104
+ persistConfig: persist_1.persistConfig,
105
+ watermark: watermark_1.default,
106
+ joker: joker_1.default,
107
+ tracker: tracker_1.default,
108
+ logger: logger_1.default,
109
+ fetch: fetch_1.default,
110
+ rsa: rsa_1.default,
111
+ };
@@ -10,6 +10,7 @@ const hooker_1 = require("./hooker");
10
10
  const pipeline_1 = require("./modules/pipeline");
11
11
  const safeTask_1 = require("./modules/safeTask");
12
12
  const log_1 = require("./log");
13
+ const bezier_1 = require("./modules/bezier");
13
14
  /**
14
15
  *
15
16
  * @param task 任务
@@ -33,6 +34,7 @@ const safeTask = (func, callback) => new safeTask_1.default(func, callback);
33
34
  exports.default = {
34
35
  ...base_1.default,
35
36
  ...log_1.default,
37
+ ...bezier_1.default,
36
38
  sleep: base_1.default.delay,
37
39
  run,
38
40
  exec,
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bezier1 = (p0, p1, t) => {
4
+ return {
5
+ x: (1 - t) * p0.x + t * p1.x,
6
+ y: (1 - t) * p0.y + t * p1.y,
7
+ };
8
+ };
9
+ const bezier2 = (p0, p1, p2, t) => {
10
+ const q0 = bezier1(p0, p1, t);
11
+ const q1 = bezier1(p1, p2, t);
12
+ return bezier1(q0, q1, t);
13
+ };
14
+ const bezier3 = (p0, p1, p2, p3, t) => {
15
+ const q0 = bezier2(p0, p1, p2, t);
16
+ const q1 = bezier2(p1, p2, p3, t);
17
+ return bezier1(q0, q1, t);
18
+ };
19
+ /**
20
+ * 贝塞尔曲线
21
+ * @param points
22
+ * @param t [0, 1]
23
+ * @returns
24
+ */
25
+ const bezier = (points, t) => {
26
+ if (points.length === 1) {
27
+ return points[0]; // 递归终点
28
+ }
29
+ const nextPoints = [];
30
+ for (let i = 0; i < points.length - 1; i++) {
31
+ nextPoints.push({
32
+ x: (1 - t) * points[i].x + t * points[i + 1].x,
33
+ y: (1 - t) * points[i].y + t * points[i + 1].y,
34
+ });
35
+ }
36
+ return bezier(nextPoints, t);
37
+ };
38
+ /**
39
+ * 计算二项式系数 C(n, k)
40
+ * @param n 阶数
41
+ * @param k 选择的点数
42
+ * @returns 二项式系数
43
+ */
44
+ const binomialCoefficient = (n, k) => {
45
+ if (k === 0 || k === n)
46
+ return 1;
47
+ let res = 1;
48
+ for (let i = 1; i <= k; i++) {
49
+ res = (res * (n - i + 1)) / i;
50
+ }
51
+ return res;
52
+ };
53
+ /**
54
+ * 贝塞尔曲线
55
+ * @param points
56
+ * @param t [0, 1]
57
+ * @returns
58
+ */
59
+ const bezierCurve = (points, t) => {
60
+ const n = points.length - 1;
61
+ let x = 0;
62
+ let y = 0;
63
+ for (let i = 0; i <= n; i++) {
64
+ const coefficient = binomialCoefficient(n, i) * Math.pow(1 - t, n - i) * Math.pow(t, i);
65
+ x += coefficient * points[i].x;
66
+ y += coefficient * points[i].y;
67
+ }
68
+ return { x, y };
69
+ };
70
+ exports.default = { bezier1, bezier2, bezier3, bezier, bezierCurve };
@@ -168,7 +168,7 @@ class Socks5 {
168
168
  const destination = await this.parseClientRequest(clientSocket);
169
169
  const addr = destination.addr;
170
170
  addrport = `${addr}:${destination.port}`;
171
- this.__debug && this.__logger?.info(`[socks5] handle connection`, addrport);
171
+ this.__debug && this.__logger?.info(`[socks5] connection`, addrport);
172
172
  const proxyConfig = this.findProxyConfig(addr);
173
173
  if (proxyConfig) {
174
174
  // 走上游代理