fanqiang 2.0.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/LICENSE +202 -0
- package/README.md +78 -0
- package/bin/fanqiang.d.ts +3 -0
- package/bin/fanqiang.d.ts.map +1 -0
- package/bin/fanqiang.js +31 -0
- package/bin/fanqiang.js.map +1 -0
- package/bin/fanqiang.ts +35 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +6 -0
- package/index.js.map +1 -0
- package/index.ts +3 -0
- package/lib/core/AwsS3CloudStorage.d.ts +6 -0
- package/lib/core/AwsS3CloudStorage.d.ts.map +1 -0
- package/lib/core/AwsS3CloudStorage.js +70 -0
- package/lib/core/AwsS3CloudStorage.js.map +1 -0
- package/lib/core/AwsS3CloudStorage.ts +90 -0
- package/lib/core/Configuration.d.ts +15 -0
- package/lib/core/Configuration.d.ts.map +1 -0
- package/lib/core/Configuration.js +24 -0
- package/lib/core/Configuration.js.map +1 -0
- package/lib/core/Configuration.ts +33 -0
- package/lib/core/StoredOptions.d.ts +18 -0
- package/lib/core/StoredOptions.d.ts.map +1 -0
- package/lib/core/StoredOptions.js +30 -0
- package/lib/core/StoredOptions.js.map +1 -0
- package/lib/core/StoredOptions.ts +37 -0
- package/lib/core/TerraformTunnelProxyOperations.d.ts +9 -0
- package/lib/core/TerraformTunnelProxyOperations.d.ts.map +1 -0
- package/lib/core/TerraformTunnelProxyOperations.js +38 -0
- package/lib/core/TerraformTunnelProxyOperations.js.map +1 -0
- package/lib/core/TerraformTunnelProxyOperations.ts +43 -0
- package/lib/core/aliyunCredentials.d.ts +7 -0
- package/lib/core/aliyunCredentials.d.ts.map +1 -0
- package/lib/core/aliyunCredentials.js +29 -0
- package/lib/core/aliyunCredentials.js.map +1 -0
- package/lib/core/aliyunCredentials.ts +30 -0
- package/lib/core/langUtils.d.ts +11 -0
- package/lib/core/langUtils.d.ts.map +1 -0
- package/lib/core/langUtils.js +69 -0
- package/lib/core/langUtils.js.map +1 -0
- package/lib/core/langUtils.ts +71 -0
- package/lib/core/terraform.d.ts +5 -0
- package/lib/core/terraform.d.ts.map +1 -0
- package/lib/core/terraform.js +90 -0
- package/lib/core/terraform.js.map +1 -0
- package/lib/core/terraform.ts +99 -0
- package/lib/domain/Clash.d.ts +6 -0
- package/lib/domain/Clash.d.ts.map +1 -0
- package/lib/domain/Clash.js +24 -0
- package/lib/domain/Clash.js.map +1 -0
- package/lib/domain/Clash.ts +24 -0
- package/lib/domain/CloudStorage.d.ts +9 -0
- package/lib/domain/CloudStorage.d.ts.map +1 -0
- package/lib/domain/CloudStorage.js +3 -0
- package/lib/domain/CloudStorage.js.map +1 -0
- package/lib/domain/CloudStorage.ts +11 -0
- package/lib/domain/TunnelProxyOperations.d.ts +19 -0
- package/lib/domain/TunnelProxyOperations.d.ts.map +1 -0
- package/lib/domain/TunnelProxyOperations.js +3 -0
- package/lib/domain/TunnelProxyOperations.js.map +1 -0
- package/lib/domain/TunnelProxyOperations.ts +19 -0
- package/lib/handlers.d.ts +3 -0
- package/lib/handlers.d.ts.map +1 -0
- package/lib/handlers.js +27 -0
- package/lib/handlers.js.map +1 -0
- package/lib/handlers.ts +28 -0
- package/package.json +81 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CloudStorage.js","sourceRoot":"","sources":["CloudStorage.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export interface Bucket {
|
2
|
+
readonly name: string;
|
3
|
+
|
4
|
+
save(objectKey: string, content: string): Promise<string>;
|
5
|
+
}
|
6
|
+
|
7
|
+
export interface CloudStorage {
|
8
|
+
getBucket(region: string): Promise<Bucket>;
|
9
|
+
|
10
|
+
destroy(region: string, bucket: string): Promise<void>;
|
11
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { Bucket } from "./CloudStorage";
|
2
|
+
export interface TunnelProxyOperations {
|
3
|
+
create(request: TunnelProxyCreatingRequest): Promise<TunnelProxyCreatingResult>;
|
4
|
+
destroy(): Promise<void>;
|
5
|
+
}
|
6
|
+
export declare type TunnelProxyCreatingRequest = ProxyOptions & {
|
7
|
+
proxyRegion: string;
|
8
|
+
tunnelRegion: string;
|
9
|
+
};
|
10
|
+
export declare type ProxyOptions = {
|
11
|
+
port: number;
|
12
|
+
encryptionAlgorithm: string;
|
13
|
+
password: string;
|
14
|
+
};
|
15
|
+
export declare type TunnelProxyCreatingResult = {
|
16
|
+
address: string;
|
17
|
+
bucket: Bucket;
|
18
|
+
};
|
19
|
+
//# sourceMappingURL=TunnelProxyOperations.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TunnelProxyOperations.d.ts","sourceRoot":"","sources":["TunnelProxyOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAEhF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,oBAAY,0BAA0B,GAAG,YAAY,GAAG;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,oBAAY,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TunnelProxyOperations.js","sourceRoot":"","sources":["TunnelProxyOperations.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { Bucket } from "./CloudStorage";
|
2
|
+
|
3
|
+
export interface TunnelProxyOperations {
|
4
|
+
create(request: TunnelProxyCreatingRequest): Promise<TunnelProxyCreatingResult>;
|
5
|
+
|
6
|
+
destroy(): Promise<void>;
|
7
|
+
}
|
8
|
+
|
9
|
+
export type TunnelProxyCreatingRequest = ProxyOptions & {
|
10
|
+
proxyRegion: string;
|
11
|
+
tunnelRegion: string;
|
12
|
+
};
|
13
|
+
export type ProxyOptions = {
|
14
|
+
port: number;
|
15
|
+
encryptionAlgorithm: string;
|
16
|
+
password: string;
|
17
|
+
};
|
18
|
+
|
19
|
+
export type TunnelProxyCreatingResult = { address: string; bucket: Bucket };
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["handlers.ts"],"names":[],"mappings":"AAIA,wBAAsB,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBrF;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAI7C"}
|
package/lib/handlers.js
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.destroy = exports.create = void 0;
|
4
|
+
const Configuration_1 = require("./core/Configuration");
|
5
|
+
const crypto_1 = require("crypto");
|
6
|
+
const Clash_1 = require("./domain/Clash");
|
7
|
+
async function create(proxyRegion, tunnelRegion) {
|
8
|
+
const configuration = await Configuration_1.loadConfiguration();
|
9
|
+
const request = {
|
10
|
+
proxyRegion,
|
11
|
+
tunnelRegion,
|
12
|
+
port: 8388,
|
13
|
+
encryptionAlgorithm: "aes-256-gcm",
|
14
|
+
password: crypto_1.randomBytes(20).toString("base64"),
|
15
|
+
};
|
16
|
+
const result = await configuration.tunnelProxyOperations.create(request);
|
17
|
+
const clashConfigUrl = await result.bucket.save("clash/config.yaml", Clash_1.generateConfigFrom(Object.assign(Object.assign({}, request), { address: result.address })));
|
18
|
+
console.log("Saved Clash config to: " + clashConfigUrl);
|
19
|
+
}
|
20
|
+
exports.create = create;
|
21
|
+
async function destroy() {
|
22
|
+
const configuration = await Configuration_1.loadConfiguration();
|
23
|
+
await configuration.tunnelProxyOperations.destroy();
|
24
|
+
console.log("Successfully destroyed tunnel proxy infrastructures!");
|
25
|
+
}
|
26
|
+
exports.destroy = destroy;
|
27
|
+
//# sourceMappingURL=handlers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["handlers.ts"],"names":[],"mappings":";;;AAAA,wDAAyD;AACzD,mCAAqC;AACrC,0CAAoD;AAE7C,KAAK,UAAU,MAAM,CAAC,WAAmB,EAAE,YAAoB;IACpE,MAAM,aAAa,GAAG,MAAM,iCAAiB,EAAE,CAAC;IAEhD,MAAM,OAAO,GAAG;QACd,WAAW;QACX,YAAY;QACZ,IAAI,EAAE,IAAI;QACV,mBAAmB,EAAE,aAAa;QAClC,QAAQ,EAAE,oBAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;KAC7C,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEzE,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAC7C,mBAAmB,EACnB,0BAAkB,iCAAM,OAAO,KAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAG,CAC5D,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,cAAc,CAAC,CAAC;AAC1D,CAAC;AAjBD,wBAiBC;AAEM,KAAK,UAAU,OAAO;IAC3B,MAAM,aAAa,GAAG,MAAM,iCAAiB,EAAE,CAAC;IAChD,MAAM,aAAa,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;AACtE,CAAC;AAJD,0BAIC"}
|
package/lib/handlers.ts
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
import { loadConfiguration } from "./core/Configuration";
|
2
|
+
import { randomBytes } from "crypto";
|
3
|
+
import { generateConfigFrom } from "./domain/Clash";
|
4
|
+
|
5
|
+
export async function create(proxyRegion: string, tunnelRegion: string): Promise<void> {
|
6
|
+
const configuration = await loadConfiguration();
|
7
|
+
|
8
|
+
const request = {
|
9
|
+
proxyRegion,
|
10
|
+
tunnelRegion,
|
11
|
+
port: 8388,
|
12
|
+
encryptionAlgorithm: "aes-256-gcm",
|
13
|
+
password: randomBytes(20).toString("base64"),
|
14
|
+
};
|
15
|
+
const result = await configuration.tunnelProxyOperations.create(request);
|
16
|
+
|
17
|
+
const clashConfigUrl = await result.bucket.save(
|
18
|
+
"clash/config.yaml",
|
19
|
+
generateConfigFrom({ ...request, address: result.address })
|
20
|
+
);
|
21
|
+
console.log("Saved Clash config to: " + clashConfigUrl);
|
22
|
+
}
|
23
|
+
|
24
|
+
export async function destroy(): Promise<void> {
|
25
|
+
const configuration = await loadConfiguration();
|
26
|
+
await configuration.tunnelProxyOperations.destroy();
|
27
|
+
console.log("Successfully destroyed tunnel proxy infrastructures!");
|
28
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
{
|
2
|
+
"name": "fanqiang",
|
3
|
+
"version": "2.0.0",
|
4
|
+
"description": "Tunnel Proxy Auto Deployment",
|
5
|
+
"bin": "./bin/fanqiang.js",
|
6
|
+
"scripts": {
|
7
|
+
"clean": "rimraf \"index.{d.ts,js}{,.map}\" \"{lib,bin}/**/*.{d.ts,js}{,.map}\"",
|
8
|
+
"lint": "eslint --ext .ts . && prettier -c .",
|
9
|
+
"lint:fix": "eslint --ext .ts --fix . && prettier --write .",
|
10
|
+
"test": "mocha --timeout 10000 --require espower-typescript/guess \"test/**/*.ts\"",
|
11
|
+
"prepare": "husky install",
|
12
|
+
"build": "tsc --resolveJsonModule"
|
13
|
+
},
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "https://github.com/zhifanz/fanqiang.git"
|
17
|
+
},
|
18
|
+
"author": "Zhifan Zhang",
|
19
|
+
"license": "Apache-2.0",
|
20
|
+
"bugs": {
|
21
|
+
"url": "https://github.com/zhifanz/fanqiang/issues"
|
22
|
+
},
|
23
|
+
"files": [
|
24
|
+
"/bin",
|
25
|
+
"/lib",
|
26
|
+
"/cloud-init",
|
27
|
+
"index.*"
|
28
|
+
],
|
29
|
+
"homepage": "https://github.com/zhifanz/fanqiang#readme",
|
30
|
+
"devDependencies": {
|
31
|
+
"@commitlint/cli": "^12.1.4",
|
32
|
+
"@commitlint/config-conventional": "^12.1.4",
|
33
|
+
"@semantic-release/changelog": "^5.0.1",
|
34
|
+
"@semantic-release/git": "^9.0.0",
|
35
|
+
"@types/ali-oss": "^6.0.10",
|
36
|
+
"@types/fs-extra": "^9.0.12",
|
37
|
+
"@types/lodash": "^4.14.171",
|
38
|
+
"@types/mocha": "^8.2.3",
|
39
|
+
"@types/netmask": "^1.0.30",
|
40
|
+
"@types/node": "^14.14.31",
|
41
|
+
"@types/qs": "^6.9.7",
|
42
|
+
"@types/tmp": "^0.2.1",
|
43
|
+
"@types/yargs": "^17.0.2",
|
44
|
+
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
45
|
+
"@typescript-eslint/parser": "^4.28.2",
|
46
|
+
"eslint": "^7.30.0",
|
47
|
+
"eslint-config-prettier": "^8.3.0",
|
48
|
+
"eslint-config-standard": "^16.0.3",
|
49
|
+
"eslint-plugin-import": "^2.23.4",
|
50
|
+
"eslint-plugin-node": "^11.1.0",
|
51
|
+
"eslint-plugin-promise": "^5.1.0",
|
52
|
+
"espower-typescript": "^10.0.0",
|
53
|
+
"husky": "^7.0.0",
|
54
|
+
"mocha": "^9.0.2",
|
55
|
+
"npm-run-all": "^4.1.5",
|
56
|
+
"power-assert": "^1.6.1",
|
57
|
+
"prettier": "2.3.2",
|
58
|
+
"rimraf": "^3.0.2",
|
59
|
+
"semantic-release": "^17.4.4",
|
60
|
+
"ts-node": "^8.10.2",
|
61
|
+
"typescript": "^4.3.5"
|
62
|
+
},
|
63
|
+
"dependencies": {
|
64
|
+
"@alicloud/credentials": "^2.1.1",
|
65
|
+
"@alicloud/openapi-client": "^0.3.3",
|
66
|
+
"@alicloud/tea-typescript": "^1.7.1",
|
67
|
+
"@aws-sdk/client-iam": "^3.27.0",
|
68
|
+
"@aws-sdk/client-lightsail": "^3.21.0",
|
69
|
+
"@aws-sdk/client-s3": "^3.27.0",
|
70
|
+
"ali-oss": "^6.16.0",
|
71
|
+
"dotenv": "^10.0.0",
|
72
|
+
"fs-extra": "^10.0.0",
|
73
|
+
"lodash": "^4.17.21",
|
74
|
+
"netmask": "^2.0.2",
|
75
|
+
"qs": "^6.10.1",
|
76
|
+
"tmp": "^0.2.1",
|
77
|
+
"tslib": "^2.3.0",
|
78
|
+
"yaml": "^1.10.2",
|
79
|
+
"yargs": "^17.0.1"
|
80
|
+
}
|
81
|
+
}
|