feat: 支持自定义订阅节点并兼容现有数据库
This commit is contained in:
@@ -18,11 +18,20 @@ export async function GET(
|
||||
return new NextResponse("node not found", { status: 404 });
|
||||
}
|
||||
|
||||
return new NextResponse(buildNodeHy2Config(node, getOriginFromRequest(request)), {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/x-yaml; charset=utf-8",
|
||||
"Content-Disposition": `attachment; filename="${slug}.config.yaml"`,
|
||||
if (node.node_type !== "hy2") {
|
||||
return new NextResponse("hy2 config unavailable for custom node", {
|
||||
status: 409,
|
||||
});
|
||||
}
|
||||
|
||||
return new NextResponse(
|
||||
buildNodeHy2Config(node, getOriginFromRequest(request)),
|
||||
{
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/x-yaml; charset=utf-8",
|
||||
"Content-Disposition": `attachment; filename="${slug}.config.yaml"`,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { buildSubscriptionConfig, buildSubscriptionHeaders } from "@/lib/subscription";
|
||||
import {
|
||||
buildSubscriptionConfig,
|
||||
buildSubscriptionHeaders,
|
||||
} from "@/lib/subscription";
|
||||
import {
|
||||
getSubscriptionSettings,
|
||||
getUserBySubscriptionToken,
|
||||
@@ -26,10 +29,13 @@ export async function GET(
|
||||
try {
|
||||
body = buildSubscriptionConfig({ user, nodes, settings });
|
||||
} catch {
|
||||
return new Response("subscription secret unavailable", { status: 409 });
|
||||
return new Response("subscription configuration unavailable", {
|
||||
status: 409,
|
||||
});
|
||||
}
|
||||
|
||||
const profileName = user.subscription_label || settings.profileName || user.username;
|
||||
const profileName =
|
||||
user.subscription_label || settings.profileName || user.username;
|
||||
|
||||
return new Response(body, {
|
||||
status: 200,
|
||||
|
||||
Reference in New Issue
Block a user