Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/admin/src/sections/servers/form-schema/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export function getProtocolDefaultConfig(proto: ProtocolType) {
path: null,
service_name: null,
sni: null,
ech_enable: null,
ech_server_name: null,
allow_insecure: null,
fingerprint: "chrome",
cert_mode: "none",
Expand All @@ -50,6 +52,8 @@ export function getProtocolDefaultConfig(proto: ProtocolType) {
path: null,
service_name: null,
sni: null,
ech_enable: null,
ech_server_name: null,
allow_insecure: null,
fingerprint: "chrome",
reality_server_addr: null,
Expand Down Expand Up @@ -83,6 +87,8 @@ export function getProtocolDefaultConfig(proto: ProtocolType) {
path: null,
service_name: null,
sni: null,
ech_enable: null,
ech_server_name: null,
allow_insecure: null,
fingerprint: "chrome",
cert_mode: "none",
Expand All @@ -103,6 +109,8 @@ export function getProtocolDefaultConfig(proto: ProtocolType) {
up_mbps: null,
down_mbps: null,
sni: null,
ech_enable: null,
ech_server_name: null,
allow_insecure: null,
fingerprint: "chrome",
cert_mode: "none",
Expand All @@ -121,6 +129,8 @@ export function getProtocolDefaultConfig(proto: ProtocolType) {
congestion_controller: "bbr",
security: "tls",
sni: null,
ech_enable: null,
ech_server_name: null,
allow_insecure: false,
fingerprint: "chrome",
cert_mode: "none",
Expand All @@ -142,6 +152,8 @@ export function getProtocolDefaultConfig(proto: ProtocolType) {
port: null,
security: "none",
sni: null,
ech_enable: null,
ech_server_name: null,
allow_insecure: null,
fingerprint: "chrome",
cert_mode: "none",
Expand All @@ -156,6 +168,8 @@ export function getProtocolDefaultConfig(proto: ProtocolType) {
port: null,
security: "none",
sni: null,
ech_enable: null,
ech_server_name: null,
allow_insecure: null,
fingerprint: "chrome",
cert_mode: "none",
Expand All @@ -179,6 +193,8 @@ export function getProtocolDefaultConfig(proto: ProtocolType) {
security: "tls",
padding_scheme: null,
sni: null,
ech_enable: null,
ech_server_name: null,
allow_insecure: false,
fingerprint: "chrome",
cert_mode: "none",
Expand Down
16 changes: 16 additions & 0 deletions apps/admin/src/sections/servers/form-schema/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const vmess = z.object({
cert_mode: z.enum(CERT_MODES).nullish(),
cert_dns_provider: nullableString,
cert_dns_env: nullableString,
ech_enable: z.boolean().nullish(),
ech_server_name: nullableString,
});

const vless = z.object({
Expand Down Expand Up @@ -84,6 +86,8 @@ const vless = z.object({
cert_mode: z.enum(CERT_MODES).nullish(),
cert_dns_provider: nullableString,
cert_dns_env: nullableString,
ech_enable: z.boolean().nullish(),
ech_server_name: nullableString,
});

const trojan = z.object({
Expand All @@ -102,6 +106,8 @@ const trojan = z.object({
cert_mode: z.enum(CERT_MODES).nullish(),
cert_dns_provider: nullableString,
cert_dns_env: nullableString,
ech_enable: z.boolean().nullish(),
ech_server_name: nullableString,
});

const hysteria = z.object({
Expand All @@ -122,6 +128,8 @@ const hysteria = z.object({
cert_mode: z.enum(CERT_MODES).nullish(),
cert_dns_provider: nullableString,
cert_dns_env: nullableString,
ech_enable: z.boolean().nullish(),
ech_server_name: nullableString,
});

const tuic = z.object({
Expand All @@ -141,6 +149,8 @@ const tuic = z.object({
cert_mode: z.enum(CERT_MODES).nullish(),
cert_dns_provider: nullableString,
cert_dns_env: nullableString,
ech_enable: z.boolean().nullish(),
ech_server_name: nullableString,
});

const anytls = z.object({
Expand All @@ -156,6 +166,8 @@ const anytls = z.object({
cert_mode: z.enum(CERT_MODES).nullish(),
cert_dns_provider: nullableString,
cert_dns_env: nullableString,
ech_enable: z.boolean().nullish(),
ech_server_name: nullableString,
reality_server_addr: nullableString,
reality_server_port: nullablePort,
reality_private_key: nullableString,
Expand All @@ -182,6 +194,8 @@ const naive = z.object({
cert_mode: z.enum(CERT_MODES).nullish(),
cert_dns_provider: nullableString,
cert_dns_env: nullableString,
ech_enable: z.boolean().nullish(),
ech_server_name: nullableString,
});

const http = z.object({
Expand All @@ -196,6 +210,8 @@ const http = z.object({
cert_mode: z.enum(CERT_MODES).nullish(),
cert_dns_provider: nullableString,
cert_dns_env: nullableString,
ech_enable: z.boolean().nullish(),
ech_server_name: nullableString,
});

const mieru = z.object({
Expand Down
68 changes: 68 additions & 0 deletions apps/admin/src/sections/servers/form-schema/useProtocolFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,23 @@ export function useProtocolFields() {
group: "security",
condition: (p) => p.security === "tls" && p.cert_mode === "dns",
},
{
name: "ech_enable",
type: "select",
label: t("ech_enable", "ECH Enable"),
options: ["false", "true"],
defaultValue: "false",
group: "security",
condition: (p) => p.security === "tls",
},
{
name: "ech_server_name",
type: "input",
label: t("ech_server_name", "ECH Server Name"),
placeholder: "e.g. cloudflare-ech.com",
group: "security",
condition: (p) => p.security === "tls" && p.ech_enable === true,
},
],
vless: [
{
Expand Down Expand Up @@ -539,6 +556,23 @@ export function useProtocolFields() {
group: "security",
condition: (p) => p.security === "tls" && p.cert_mode === "dns",
},
{
name: "ech_enable",
type: "select",
label: t("ech_enable", "ECH Enable"),
options: ["false", "true"],
defaultValue: "false",
group: "security",
condition: (p) => p.security === "tls",
},
{
name: "ech_server_name",
type: "input",
label: t("ech_server_name", "ECH Server Name"),
placeholder: "e.g. cloudflare-ech.com",
group: "security",
condition: (p) => p.security === "tls" && p.ech_enable === true,
},
],
trojan: [
{
Expand Down Expand Up @@ -650,6 +684,23 @@ export function useProtocolFields() {
group: "security",
condition: (p) => p.security === "tls" && p.cert_mode === "dns",
},
{
name: "ech_enable",
type: "select",
label: t("ech_enable", "ECH Enable"),
options: ["false", "true"],
defaultValue: "false",
group: "security",
condition: (p) => p.security === "tls",
},
{
name: "ech_server_name",
type: "input",
label: t("ech_server_name", "ECH Server Name"),
placeholder: "e.g. cloudflare-ech.com",
group: "security",
condition: (p) => p.security === "tls" && p.ech_enable === true,
},
],
hysteria: [
{
Expand Down Expand Up @@ -971,6 +1022,23 @@ export function useProtocolFields() {
group: "security",
condition: (p) => p.security === "tls" && p.cert_mode === "dns",
},
{
name: "ech_enable",
type: "select",
label: t("ech_enable", "ECH Enable"),
options: ["false", "true"],
defaultValue: "false",
group: "security",
condition: (p) => p.security === "tls",
},
{
name: "ech_server_name",
type: "input",
label: t("ech_server_name", "ECH Server Name"),
placeholder: "e.g. cloudflare-ech.com",
group: "security",
condition: (p) => p.security === "tls" && p.ech_enable === true,
},
],
http: [
{
Expand Down
28 changes: 23 additions & 5 deletions apps/admin/src/sections/servers/server-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,19 @@ function DynamicField({
<FormLabel>{getFieldLabel(field)}</FormLabel>
<FormControl>
<Select
onValueChange={(v) => fieldProps.onChange(v)}
value={fieldProps.value ?? field.defaultValue}
onValueChange={(v) =>
field.name === "ech_enable"
? fieldProps.onChange(v === "true")
: fieldProps.onChange(v)
}
value={
field.name === "ech_enable"
? String(
(fieldProps.value ?? field.defaultValue ?? false) ===
true
)
: (fieldProps.value ?? field.defaultValue)
}
>
<FormControl>
<SelectTrigger>
Expand Down Expand Up @@ -515,9 +526,16 @@ export default function ServerForm(props: {
return;
}

const filteredProtocols = (values?.protocols || []).filter(
(protocol: any) => protocol?.enable
);
const filteredProtocols = (values?.protocols || [])
.filter((protocol: any) => protocol?.enable)
.map((protocol: any) => {
if (protocol.ech_enable === true) {
return protocol;
}

const { ech_enable, ech_server_name, ...rest } = protocol;
return rest;
});

const result = {
name: values.name,
Expand Down
4 changes: 3 additions & 1 deletion apps/user/src/sections/subscribe/payment-methods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const PaymentMethods: React.FC<PaymentMethodsProps> = ({
<Label
className={cn(
"flex flex-col items-center justify-between rounded-md border-2 border-muted bg-popover py-2 text-popover-foreground hover:bg-accent hover:text-accent-foreground",
String(value) === String(item.id) ? "border-primary bg-primary/10 text-foreground" : ""
String(value) === String(item.id)
? "border-primary bg-primary/10 text-foreground"
: ""
)}
htmlFor={String(item.id)}
>
Expand Down
6 changes: 3 additions & 3 deletions functions/v1/[[path]].ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const onRequest: PagesFunction<Env> = async (context) => {

const apiBase = (env.API_BASE_URL || "https://api.ppanel.dev").replace(
/\/$/,
"",
""
);

const url = new URL(request.url);
Expand Down Expand Up @@ -41,11 +41,11 @@ export const onRequest: PagesFunction<Env> = async (context) => {
responseHeaders.set("Access-Control-Allow-Origin", url.origin);
responseHeaders.set(
"Access-Control-Allow-Methods",
"GET, POST, PUT, DELETE, PATCH, OPTIONS",
"GET, POST, PUT, DELETE, PATCH, OPTIONS"
);
responseHeaders.set(
"Access-Control-Allow-Headers",
"Content-Type, Authorization",
"Content-Type, Authorization"
);

if (request.method === "OPTIONS") {
Expand Down