ddan-js 4.0.0 → 4.0.2
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/bin/class/joker.d.ts +1 -1
- package/bin/ddan-browser.js +1 -1
- package/bin/ddan-browser.mjs +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/ddan-js.mjs +1 -1
- package/bin/modules/node/socks5.d.ts +58 -9
- package/package.json +1 -1
|
@@ -1,20 +1,42 @@
|
|
|
1
1
|
import DEvent from '../../class/event';
|
|
2
2
|
import DPipeline from '../hook/modules/pipeline';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 代理配置接口
|
|
5
|
+
*/
|
|
6
|
+
export interface IProxy {
|
|
4
7
|
ipaddress: string;
|
|
5
8
|
port: number;
|
|
6
9
|
type?: 5;
|
|
7
10
|
userId?: string;
|
|
8
11
|
password?: string;
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
/**
|
|
14
|
+
* 带规则的代理配置接口
|
|
15
|
+
*/
|
|
16
|
+
export interface IRuleProxy extends IProxy {
|
|
11
17
|
rules?: string[];
|
|
12
18
|
}
|
|
13
|
-
|
|
19
|
+
/**
|
|
20
|
+
* 目标地址接口
|
|
21
|
+
*/
|
|
22
|
+
export interface IDestination {
|
|
23
|
+
addr: string;
|
|
24
|
+
port: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* SOCKS5事件类型
|
|
28
|
+
*/
|
|
29
|
+
export declare const Socks5Event: {
|
|
14
30
|
readonly Error: "error";
|
|
15
31
|
};
|
|
16
|
-
|
|
17
|
-
|
|
32
|
+
/**
|
|
33
|
+
* SOCKS5事件类型
|
|
34
|
+
*/
|
|
35
|
+
export type Socks5EventType = (typeof Socks5Event)[keyof typeof Socks5Event];
|
|
36
|
+
/**
|
|
37
|
+
* 日志接口
|
|
38
|
+
*/
|
|
39
|
+
export interface ILogger {
|
|
18
40
|
log: (...args: any[]) => void;
|
|
19
41
|
info: (...args: any[]) => void;
|
|
20
42
|
warn: (...args: any[]) => void;
|
|
@@ -51,12 +73,29 @@ export declare class Socks5 {
|
|
|
51
73
|
setSystemProxy(use: boolean, config?: IProxy): void;
|
|
52
74
|
/**
|
|
53
75
|
* 查找可用端口
|
|
54
|
-
* @param startPort
|
|
55
|
-
* @param maxRetries
|
|
56
|
-
* @returns
|
|
76
|
+
* @param startPort 起始端口
|
|
77
|
+
* @param maxRetries 最大重试次数
|
|
78
|
+
* @returns 可用端口或0(表示失败)
|
|
57
79
|
*/
|
|
58
80
|
private findAvailablePort;
|
|
81
|
+
/**
|
|
82
|
+
* 处理SOCKS5客户端连接
|
|
83
|
+
* @param clientSocket 客户端socket连接
|
|
84
|
+
*/
|
|
59
85
|
private handleSocksConnection;
|
|
86
|
+
/**
|
|
87
|
+
* 设置客户端socket事件处理
|
|
88
|
+
* @param clientSocket 客户端socket连接
|
|
89
|
+
*/
|
|
90
|
+
private setupClientSocketEvents;
|
|
91
|
+
/**
|
|
92
|
+
* 根据代理配置建立连接
|
|
93
|
+
* @param clientSocket 客户端socket连接
|
|
94
|
+
* @param destination 目标地址
|
|
95
|
+
* @param proxyConfig 代理配置
|
|
96
|
+
* @param addrport 地址端口字符串
|
|
97
|
+
*/
|
|
98
|
+
private establishConnection;
|
|
60
99
|
/**
|
|
61
100
|
* 回复客户端请求响应数据
|
|
62
101
|
* VER是SOCKS版本,这里应该是0x05;
|
|
@@ -89,7 +128,18 @@ export declare class Socks5 {
|
|
|
89
128
|
private connectToProxy;
|
|
90
129
|
private connectToLocal;
|
|
91
130
|
private setupDataForwarding;
|
|
131
|
+
/**
|
|
132
|
+
* 查找适合目标地址的代理配置
|
|
133
|
+
* @param addr 目标地址
|
|
134
|
+
* @returns 匹配的代理配置或undefined
|
|
135
|
+
*/
|
|
92
136
|
findProxyConfig(addr: string): IRuleProxy | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* 检查域名是否符合规则
|
|
139
|
+
* @param addr 目标地址
|
|
140
|
+
* @param rules 规则列表
|
|
141
|
+
* @returns 是否符合规则
|
|
142
|
+
*/
|
|
93
143
|
private isAllowedDomain;
|
|
94
144
|
close(): void;
|
|
95
145
|
on(name: Socks5EventType, listener: (...args: any[]) => void): void;
|
|
@@ -98,4 +148,3 @@ export declare class Socks5 {
|
|
|
98
148
|
private _emit;
|
|
99
149
|
private _updateRules;
|
|
100
150
|
}
|
|
101
|
-
export {};
|