feat: 接入 AnyTLS 节点托管和用户流量同步
This commit is contained in:
+18
-2
@@ -1,3 +1,4 @@
|
||||
import { anytlsPassword } from "@/lib/anytls";
|
||||
import { renderCustomProxyYaml } from "@/lib/custom-proxy";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
@@ -52,11 +53,26 @@ function renderHy2Proxy(node: Hy2NodeRow, authString: string) {
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
function renderSubscriptionProxy(node: Hy2NodeRow, authString: string) {
|
||||
function renderSubscriptionProxy(
|
||||
node: Hy2NodeRow,
|
||||
authString: string,
|
||||
user: Hy2UserRow,
|
||||
) {
|
||||
if (node.node_type === "custom") {
|
||||
return renderCustomProxyYaml(node.custom_config_yaml);
|
||||
}
|
||||
|
||||
if (node.node_type === "anytls")
|
||||
return [
|
||||
`- name: ${JSON.stringify(node.client_name || node.name)}`,
|
||||
" type: anytls",
|
||||
` server: ${JSON.stringify(node.server_host)}`,
|
||||
` port: ${node.server_port}`,
|
||||
` password: ${JSON.stringify(anytlsPassword(user))}`,
|
||||
` sni: ${JSON.stringify(node.sni || node.server_host)}`,
|
||||
" skip-cert-verify: false",
|
||||
" udp: true",
|
||||
].join("\n");
|
||||
return renderHy2Proxy(node, authString);
|
||||
}
|
||||
|
||||
@@ -211,7 +227,7 @@ export function buildSubscriptionConfig(input: {
|
||||
);
|
||||
const proxyNames = orderedEligibleNodes.map((node) => getNodeProxyName(node));
|
||||
const proxiesBlock = orderedEligibleNodes
|
||||
.map((node) => renderSubscriptionProxy(node, authString))
|
||||
.map((node) => renderSubscriptionProxy(node, authString, input.user))
|
||||
.join("\n");
|
||||
const defaultTemplate =
|
||||
input.settings.template.trimEnd() || readDefaultTemplate();
|
||||
|
||||
Reference in New Issue
Block a user