@maiyunnet/kebab 9.1.3 → 9.2.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/doc/kebab-rag.md +2237 -437
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/buffer.d.ts +5 -0
- package/lib/buffer.js +13 -0
- package/lib/cookie.d.ts +44 -0
- package/lib/cookie.js +216 -0
- package/lib/core.d.ts +3 -2
- package/lib/core.js +15 -12
- package/lib/dns.d.ts +1 -1
- package/lib/dns.js +4 -6
- package/lib/net/request.d.ts +2 -1
- package/lib/net.d.ts +3 -38
- package/lib/net.js +6 -219
- package/lib/socket.d.ts +4 -3
- package/lib/turnstile.js +2 -2
- package/lib/undici/formdata.d.ts +83 -0
- package/lib/undici/formdata.js +166 -0
- package/lib/undici/request.d.ts +86 -0
- package/lib/undici/request.js +120 -0
- package/lib/undici/response.d.ts +39 -0
- package/lib/undici/response.js +111 -0
- package/lib/undici.d.ts +174 -0
- package/lib/undici.js +595 -0
- package/lib/ws.d.ts +6 -5
- package/lib/ws.js +9 -9
- package/package.json +3 -2
- package/sys/cmd.js +4 -1
- package/sys/route.js +5 -2
- package/www/example/ctr/middle.js +3 -2
- package/www/example/ctr/test.d.ts +32 -0
- package/www/example/ctr/test.js +526 -4
- package/www/example/route.json +1 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import * as lUndici from '#kebab/lib/undici.js';
|
|
2
|
+
export class Request {
|
|
3
|
+
/** --- get 或 post 的数据 --- */
|
|
4
|
+
_data = undefined;
|
|
5
|
+
/** --- 访问的 URL --- */
|
|
6
|
+
_url = '';
|
|
7
|
+
/** --- 要传递的参数 --- */
|
|
8
|
+
_opt = {};
|
|
9
|
+
constructor(url) {
|
|
10
|
+
this._url = url;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* --- 设置 get 或 post 的数据 ---
|
|
14
|
+
* @param data 数据
|
|
15
|
+
*/
|
|
16
|
+
data(data) {
|
|
17
|
+
this._data = data;
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* --- 设置 get 或 post 请求 ---
|
|
22
|
+
* @param method
|
|
23
|
+
*/
|
|
24
|
+
method(method) {
|
|
25
|
+
this._opt['method'] = method;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* --- method get 方法别名 ---
|
|
30
|
+
*/
|
|
31
|
+
get() {
|
|
32
|
+
return this.method('GET');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* --- method post 方法别名 ---
|
|
36
|
+
*/
|
|
37
|
+
post() {
|
|
38
|
+
return this.method('POST');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* --- 设置提交模式,json 还是普通 form ---
|
|
42
|
+
* @param type
|
|
43
|
+
*/
|
|
44
|
+
type(type) {
|
|
45
|
+
this._opt['type'] = type;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* --- type json 方法别名 ---
|
|
50
|
+
*/
|
|
51
|
+
json() {
|
|
52
|
+
return this.type('json');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* --- 设置请求有效期 ---
|
|
56
|
+
* @param timeout 秒
|
|
57
|
+
*/
|
|
58
|
+
timeout(timeout) {
|
|
59
|
+
this._opt['timeout'] = timeout;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* --- 设置是否跟随请求方的 location,留空为跟随,不设置为不跟随 ---
|
|
64
|
+
* @param follow
|
|
65
|
+
*/
|
|
66
|
+
follow(follow = 5) {
|
|
67
|
+
this._opt['follow'] = follow;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* --- 设置域名 -> ip的对应键值,就像电脑里的 hosts 一样 ---
|
|
72
|
+
* @param hosts
|
|
73
|
+
*/
|
|
74
|
+
hosts(hosts) {
|
|
75
|
+
this._opt['hosts'] = hosts;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* --- 设置后将直接保存到本地文件,不会返回,save 为本地实体路径 ---
|
|
80
|
+
* @param save
|
|
81
|
+
*/
|
|
82
|
+
save(save) {
|
|
83
|
+
this._opt['save'] = save;
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* --- 设置使用的本地网卡 IP ---
|
|
88
|
+
* @param addr
|
|
89
|
+
*/
|
|
90
|
+
local(addr) {
|
|
91
|
+
this._opt['local'] = addr;
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* --- 批量设置提交的 headers ---
|
|
96
|
+
* @param headers
|
|
97
|
+
*/
|
|
98
|
+
headers(headers) {
|
|
99
|
+
this._opt['headers'] = headers;
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* --- 设置单条 header ---
|
|
104
|
+
* @param name
|
|
105
|
+
* @param val
|
|
106
|
+
*/
|
|
107
|
+
setHeader(name, val) {
|
|
108
|
+
this._opt['headers'] ??= {};
|
|
109
|
+
this._opt['headers'][name] = val;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* --- 发起请求 ---
|
|
114
|
+
* @param cookie
|
|
115
|
+
*/
|
|
116
|
+
request(cookie) {
|
|
117
|
+
this._opt.cookie = cookie;
|
|
118
|
+
return lUndici.request(this._url, this._data, this._opt);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project: Kebab, User: JianSuoQiYue
|
|
3
|
+
* Date: 2020-4-9 15:33:06
|
|
4
|
+
* Last: 2020-4-12 11:12:03, 2022-09-10 12:43:23, 2022-12-25 15:12:57, 2023-9-26 14:20:41
|
|
5
|
+
*/
|
|
6
|
+
import * as undici from 'undici';
|
|
7
|
+
import * as zlib from 'zlib';
|
|
8
|
+
import * as lUndici from '#kebab/lib/undici.js';
|
|
9
|
+
export declare class Response {
|
|
10
|
+
/** --- httpClient 请求对象 --- */
|
|
11
|
+
private readonly _req;
|
|
12
|
+
/** --- 返回的 headers --- */
|
|
13
|
+
headers: lUndici.THttpHeaders | null;
|
|
14
|
+
error: Error | null;
|
|
15
|
+
/** --- 用户自定义的 content 内容 --- */
|
|
16
|
+
private _content;
|
|
17
|
+
constructor(req: undici.Dispatcher.ResponseData | null);
|
|
18
|
+
/**
|
|
19
|
+
* --- 读取所有内容到内存 ---
|
|
20
|
+
*/
|
|
21
|
+
getContent(): Promise<Buffer | null>;
|
|
22
|
+
/** --- 读取所有内容为文本 --- */
|
|
23
|
+
getText(): Promise<string | null>;
|
|
24
|
+
/** --- 读取所有内容为 JSON --- */
|
|
25
|
+
getJson(): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* --- 用户自定义的 content 内容 ---
|
|
28
|
+
* @param v 内容值
|
|
29
|
+
*/
|
|
30
|
+
setContent(v: string | Buffer): void;
|
|
31
|
+
/**
|
|
32
|
+
* --- 获取响应读取流对象 ---
|
|
33
|
+
*/
|
|
34
|
+
getStream(): (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress | null;
|
|
35
|
+
/**
|
|
36
|
+
* --- 获取原生响应读取流对象 ---
|
|
37
|
+
*/
|
|
38
|
+
getRawStream(): (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | null;
|
|
39
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as zlib from 'zlib';
|
|
2
|
+
import * as lBuffer from '#kebab/lib/buffer.js';
|
|
3
|
+
import * as lText from '#kebab/lib/text.js';
|
|
4
|
+
export class Response {
|
|
5
|
+
/** --- httpClient 请求对象 --- */
|
|
6
|
+
_req = null;
|
|
7
|
+
/** --- 返回的 headers --- */
|
|
8
|
+
headers = null;
|
|
9
|
+
error = null;
|
|
10
|
+
/** --- 用户自定义的 content 内容 --- */
|
|
11
|
+
_content = null;
|
|
12
|
+
constructor(req) {
|
|
13
|
+
this._req = req;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* --- 读取所有内容到内存 ---
|
|
17
|
+
*/
|
|
18
|
+
async getContent() {
|
|
19
|
+
if (this._content) {
|
|
20
|
+
return this._content;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const stream = this.getStream();
|
|
24
|
+
if (!stream) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return this._req ? await lBuffer.getFull(stream) : null;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** --- 读取所有内容为文本 --- */
|
|
34
|
+
async getText() {
|
|
35
|
+
try {
|
|
36
|
+
const buf = await this.getContent();
|
|
37
|
+
if (!buf) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return buf.toString('utf-8');
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** --- 读取所有内容为 JSON --- */
|
|
47
|
+
async getJson() {
|
|
48
|
+
try {
|
|
49
|
+
const text = await this.getText();
|
|
50
|
+
if (!text) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return lText.parseJson(text);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* --- 用户自定义的 content 内容 ---
|
|
61
|
+
* @param v 内容值
|
|
62
|
+
*/
|
|
63
|
+
setContent(v) {
|
|
64
|
+
this._content = typeof v === 'string' ? Buffer.from(v) : v;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* --- 获取响应读取流对象 ---
|
|
68
|
+
*/
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
70
|
+
getStream() {
|
|
71
|
+
try {
|
|
72
|
+
// --- 要解压 ---
|
|
73
|
+
if (!this._req || !this.headers) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const enc = this.headers['content-encoding'];
|
|
77
|
+
if ((enc !== 'gzip') && (enc !== 'deflate') && (enc !== 'br')) {
|
|
78
|
+
return this._req.body;
|
|
79
|
+
}
|
|
80
|
+
// --- gzip ---
|
|
81
|
+
if (this.headers['content-encoding'] === 'gzip') {
|
|
82
|
+
return this._req.body.pipe(zlib.createGunzip());
|
|
83
|
+
}
|
|
84
|
+
// --- deflate ---
|
|
85
|
+
if (this.headers['content-encoding'] === 'deflate') {
|
|
86
|
+
return this._req.body.pipe(zlib.createInflate());
|
|
87
|
+
}
|
|
88
|
+
// --- br ---
|
|
89
|
+
if (this.headers['content-encoding'] === 'br') {
|
|
90
|
+
return this._req.body.pipe(zlib.createBrotliDecompress());
|
|
91
|
+
}
|
|
92
|
+
// --- 不知道 ---
|
|
93
|
+
return this._req.body;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* --- 获取原生响应读取流对象 ---
|
|
101
|
+
*/
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
103
|
+
getRawStream() {
|
|
104
|
+
try {
|
|
105
|
+
return this._req ? this._req.body : null;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
package/lib/undici.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as undici from 'undici';
|
|
2
|
+
import * as stream from 'stream';
|
|
3
|
+
import * as http from 'http';
|
|
4
|
+
import * as http2 from 'http2';
|
|
5
|
+
import * as kebab from '#kebab/index.js';
|
|
6
|
+
import * as lCookie from '#kebab/lib/cookie.js';
|
|
7
|
+
import * as sCtr from '#kebab/sys/ctr.js';
|
|
8
|
+
import * as lFd from './undici/formdata.js';
|
|
9
|
+
import * as lRequest from './undici/request.js';
|
|
10
|
+
import * as lResponse from './undici/response.js';
|
|
11
|
+
/** --- 获取代理 agent --- */
|
|
12
|
+
export declare function getProxyAgent(url: string): undici.ProxyAgent;
|
|
13
|
+
/**
|
|
14
|
+
* --- 创建一个请求对象 ---
|
|
15
|
+
* @param u
|
|
16
|
+
*/
|
|
17
|
+
export declare function open(u: string): lRequest.Request;
|
|
18
|
+
/**
|
|
19
|
+
* --- 发起一个 get 请求 ---
|
|
20
|
+
* @param u 请求的 URL
|
|
21
|
+
* @param opt 参数
|
|
22
|
+
*/
|
|
23
|
+
export declare function get(u: string, opt?: IRequestOptions): Promise<lResponse.Response>;
|
|
24
|
+
/**
|
|
25
|
+
* --- 发起一个 post 请求 ---
|
|
26
|
+
* @param u 请求的 URL
|
|
27
|
+
* @param data 要发送的数据
|
|
28
|
+
* @param opt 参数
|
|
29
|
+
*/
|
|
30
|
+
export declare function post(u: string, data: Record<string, kebab.Json> | Buffer | string | stream.Readable, opt?: IRequestOptions): Promise<lResponse.Response>;
|
|
31
|
+
/**
|
|
32
|
+
* --- 发起 JSON 请求 ---
|
|
33
|
+
* @param u 网址
|
|
34
|
+
* @param data 数据
|
|
35
|
+
* @param opt 选项
|
|
36
|
+
*/
|
|
37
|
+
export declare function postJson(u: string, data: kebab.Json[] | Record<string, kebab.Json>, opt?: IRequestOptions): Promise<lResponse.Response>;
|
|
38
|
+
/**
|
|
39
|
+
* --- 发起 JSON 请求并解析 JSON 响应 ---
|
|
40
|
+
* @param u 网址
|
|
41
|
+
* @param data 数据
|
|
42
|
+
* @param opt 选项
|
|
43
|
+
* @returns JSON 数据,失败时返回 null
|
|
44
|
+
*/
|
|
45
|
+
export declare function postJsonResponseJson(u: string, data: kebab.Json[] | Record<string, kebab.Json>, opt?: IRequestOptions): Promise<kebab.Json | null>;
|
|
46
|
+
/**
|
|
47
|
+
* --- 发起 GET 请求并解析 JSON 响应 ---
|
|
48
|
+
* @param u 网址
|
|
49
|
+
* @param opt 选项
|
|
50
|
+
* @returns JSON 数据,失败时返回 null
|
|
51
|
+
*/
|
|
52
|
+
export declare function getResponseJson(u: string, opt?: IRequestOptions): Promise<kebab.Json | null>;
|
|
53
|
+
/**
|
|
54
|
+
* --- 发起一个完全兼容 fetch 的请求 ---
|
|
55
|
+
* @param input 请求的 URL 或 Request 对象
|
|
56
|
+
* @param init 增加 mproxy、hosts
|
|
57
|
+
*/
|
|
58
|
+
export declare function fetch(input: string | URL | Request, init?: RequestInit & {
|
|
59
|
+
/** --- 正向 mproxy 代理,url 如 https://xxx/abc --- */
|
|
60
|
+
'mproxy'?: {
|
|
61
|
+
'url': string;
|
|
62
|
+
'auth': string;
|
|
63
|
+
'data'?: kebab.Json;
|
|
64
|
+
};
|
|
65
|
+
/** --- 自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host --- */
|
|
66
|
+
'hosts'?: Record<string, string> | string;
|
|
67
|
+
}): Promise<Response>;
|
|
68
|
+
/**
|
|
69
|
+
* --- 发起一个请求 ---
|
|
70
|
+
* @param opt 配置项
|
|
71
|
+
*/
|
|
72
|
+
export declare function request(u: string, data?: Record<string, kebab.Json> | Buffer | string | stream.Readable, opt?: IRequestOptions): Promise<lResponse.Response>;
|
|
73
|
+
/**
|
|
74
|
+
* --- 创建 FormData 对象 ---
|
|
75
|
+
*/
|
|
76
|
+
export declare function getFormData(): lFd.FormData;
|
|
77
|
+
/**
|
|
78
|
+
* --- 剔除不代理的 header,返回新的 header ---
|
|
79
|
+
* @param headers 剔除前的 header
|
|
80
|
+
* @param res 直接设置头部而不返回,可置空
|
|
81
|
+
* @param filter 返回 true 则留下
|
|
82
|
+
*/
|
|
83
|
+
export declare function filterHeaders(headers: http.IncomingHttpHeaders | http2.IncomingHttpHeaders | THttpHeaders, res?: http2.Http2ServerResponse | http.ServerResponse, filter?: (h: string) => boolean): Record<string, string | string[]>;
|
|
84
|
+
/**
|
|
85
|
+
* --- 正向 mproxy 代理,注意提前处理不要自动处理 post 数据,读取 get 的 url 为实际请求地址 ---
|
|
86
|
+
* --- get: url, auth ---
|
|
87
|
+
* @param ctr 当前控制器
|
|
88
|
+
* @param auth 校验字符串,读取 get 的 auth 和本参数做比对
|
|
89
|
+
* @param opt 参数
|
|
90
|
+
*/
|
|
91
|
+
export declare function mproxy(ctr: sCtr.Ctr, auth: string, opt?: IMproxyOptions): Promise<number>;
|
|
92
|
+
/**
|
|
93
|
+
* --- 获取 mproxy 的附加数据 ---
|
|
94
|
+
* @param ctr 当前控制器
|
|
95
|
+
*/
|
|
96
|
+
export declare function mproxyData(ctr: sCtr.Ctr): kebab.Json;
|
|
97
|
+
/**
|
|
98
|
+
* --- 反向代理,注意提前处理不要自动处理 post 数据,将本服务器的某个路由反代到其他网址 ---
|
|
99
|
+
* @param ctr 当前控制器
|
|
100
|
+
* @param route 要反代的路由
|
|
101
|
+
* @param opt 参数
|
|
102
|
+
*/
|
|
103
|
+
export declare function rproxy(ctr: sCtr.Ctr, route: Record<string, string>, opt?: IRproxyOptions): Promise<boolean>;
|
|
104
|
+
/** --- 请求的传入参数选项 --- */
|
|
105
|
+
export interface IRequestOptions {
|
|
106
|
+
'method'?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'OPTIONS';
|
|
107
|
+
'type'?: 'form' | 'json';
|
|
108
|
+
/** --- 秒数,默认 10 秒 --- */
|
|
109
|
+
'timeout'?: number;
|
|
110
|
+
/** --- 追踪 location 次数,0 为不追踪,默认为 0 --- */
|
|
111
|
+
'follow'?: number;
|
|
112
|
+
/** --- 自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host --- */
|
|
113
|
+
'hosts'?: Record<string, string> | string;
|
|
114
|
+
'save'?: string;
|
|
115
|
+
'local'?: string;
|
|
116
|
+
'headers'?: THttpHeaders;
|
|
117
|
+
/** --- 正向 mproxy 代理,url 如 https://xxx/abc --- */
|
|
118
|
+
'mproxy'?: {
|
|
119
|
+
'url': string;
|
|
120
|
+
'auth': string;
|
|
121
|
+
'data'?: kebab.Json;
|
|
122
|
+
/** --- 落地端自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host --- */
|
|
123
|
+
'hosts'?: Record<string, string> | string;
|
|
124
|
+
};
|
|
125
|
+
/** --- 连接是否保持长连接(即是否允许复用),默认为 true --- */
|
|
126
|
+
'keep'?: boolean;
|
|
127
|
+
/** --- 复用池名/Agent,默认为 default --- */
|
|
128
|
+
'reuse'?: string | undici.ProxyAgent | undici.Agent;
|
|
129
|
+
/** --- cookie 托管对象 --- */
|
|
130
|
+
'cookie'?: Record<string, lCookie.ICookie>;
|
|
131
|
+
/** --- 若有异常写入文件日志,默认为 true --- */
|
|
132
|
+
'log'?: boolean;
|
|
133
|
+
}
|
|
134
|
+
/** --- 正向代理请求的传入参数选项 --- */
|
|
135
|
+
export interface IMproxyOptions {
|
|
136
|
+
/** --- 秒数 --- */
|
|
137
|
+
'timeout'?: number;
|
|
138
|
+
'follow'?: number;
|
|
139
|
+
/** --- 自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host --- */
|
|
140
|
+
'hosts'?: Record<string, string> | string;
|
|
141
|
+
'local'?: string;
|
|
142
|
+
'headers'?: THttpHeaders;
|
|
143
|
+
/** --- 过滤 header,返回 true 则留下 --- */
|
|
144
|
+
filter?: (h: string) => boolean;
|
|
145
|
+
/** --- 默认为 default --- */
|
|
146
|
+
'reuse'?: string | undici.ProxyAgent | undici.Agent;
|
|
147
|
+
}
|
|
148
|
+
/** --- 反向代理请求的传入参数选项 --- */
|
|
149
|
+
export interface IRproxyOptions {
|
|
150
|
+
/** --- 秒数 --- */
|
|
151
|
+
'timeout'?: number;
|
|
152
|
+
'follow'?: number;
|
|
153
|
+
/** --- 自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host --- */
|
|
154
|
+
'hosts'?: Record<string, string> | string;
|
|
155
|
+
'local'?: string;
|
|
156
|
+
'headers'?: THttpHeaders;
|
|
157
|
+
/** --- 过滤 header,返回 true 则留下 --- */
|
|
158
|
+
filter?: (h: string) => boolean;
|
|
159
|
+
/** --- 正向 mproxy 代理,url 如 https://xxx/abc --- */
|
|
160
|
+
'mproxy'?: {
|
|
161
|
+
'url': string;
|
|
162
|
+
'auth': string;
|
|
163
|
+
'data'?: kebab.Json;
|
|
164
|
+
/** --- 落地端自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host --- */
|
|
165
|
+
'hosts'?: Record<string, string> | string;
|
|
166
|
+
};
|
|
167
|
+
/** --- 默认为 default --- */
|
|
168
|
+
'reuse'?: string | undici.ProxyAgent | undici.Agent;
|
|
169
|
+
}
|
|
170
|
+
/** --- http headers --- */
|
|
171
|
+
export type THttpHeaders = http.IncomingHttpHeaders & {
|
|
172
|
+
'http-code'?: number;
|
|
173
|
+
'http-url'?: string;
|
|
174
|
+
};
|