This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useTheme } from "next-themes";
|
||||
import { forwardRef, useEffect, useImperativeHandle } from "react";
|
||||
import { type RefObject, useEffect, useImperativeHandle } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Turnstile, { useTurnstile } from "react-turnstile";
|
||||
|
||||
@@ -9,14 +9,17 @@ export type TurnstileRef = {
|
||||
reset: () => void;
|
||||
};
|
||||
|
||||
const CloudFlareTurnstile = forwardRef<
|
||||
TurnstileRef,
|
||||
{
|
||||
id?: string;
|
||||
value?: null | string;
|
||||
onChange: (value?: string) => void;
|
||||
}
|
||||
>(function CloudFlareTurnstile({ id, value, onChange }, ref) {
|
||||
const CloudFlareTurnstile = function CloudFlareTurnstile({
|
||||
id,
|
||||
value,
|
||||
onChange,
|
||||
ref,
|
||||
}: {
|
||||
id?: string;
|
||||
value?: null | string;
|
||||
onChange: (value?: string) => void;
|
||||
ref?: RefObject<TurnstileRef | null>;
|
||||
}) {
|
||||
const { common } = useGlobalStore();
|
||||
const { verify } = common;
|
||||
const { resolvedTheme } = useTheme();
|
||||
@@ -58,6 +61,6 @@ const CloudFlareTurnstile = forwardRef<
|
||||
/>
|
||||
)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
export default CloudFlareTurnstile;
|
||||
|
||||
@@ -66,18 +66,13 @@ export const SECURITY = {
|
||||
trojan: ["tls"] as const,
|
||||
hysteria: ["tls"] as const,
|
||||
tuic: ["tls"] as const,
|
||||
anytls: ["tls"] as const,
|
||||
anytls: ["none", "tls", "reality"] as const,
|
||||
naive: ["none", "tls"] as const,
|
||||
http: ["none", "tls"] as const,
|
||||
} as const;
|
||||
|
||||
export const FLOWS = {
|
||||
vless: [
|
||||
"none",
|
||||
"xtls-rprx-direct",
|
||||
"xtls-rprx-splice",
|
||||
"xtls-rprx-vision",
|
||||
] as const,
|
||||
vless: ["none", "xtls-rprx-vision"] as const,
|
||||
} as const;
|
||||
|
||||
export const TUIC_UDP_RELAY_MODES = ["native", "quic"] as const;
|
||||
|
||||
@@ -184,6 +184,11 @@ export function getProtocolDefaultConfig(proto: ProtocolType) {
|
||||
cert_mode: "none",
|
||||
cert_dns_provider: null,
|
||||
cert_dns_env: null,
|
||||
reality_server_addr: null,
|
||||
reality_server_port: null,
|
||||
reality_private_key: null,
|
||||
reality_public_key: null,
|
||||
reality_short_id: null,
|
||||
ratio: 1,
|
||||
} as any;
|
||||
default:
|
||||
|
||||
@@ -156,6 +156,11 @@ const anytls = z.object({
|
||||
cert_mode: z.enum(CERT_MODES).nullish(),
|
||||
cert_dns_provider: nullableString,
|
||||
cert_dns_env: nullableString,
|
||||
reality_server_addr: nullableString,
|
||||
reality_server_port: nullablePort,
|
||||
reality_private_key: nullableString,
|
||||
reality_public_key: nullableString,
|
||||
reality_short_id: nullableString,
|
||||
});
|
||||
|
||||
const socks = z.object({
|
||||
|
||||
@@ -279,7 +279,10 @@ export function useProtocolFields() {
|
||||
options: FLOWS.vless,
|
||||
defaultValue: "none",
|
||||
group: "transport",
|
||||
condition: (p) => p.transport === "tcp",
|
||||
condition: (p) =>
|
||||
p.encryption === "mlkem768x25519plus" ||
|
||||
(p.transport === "tcp" &&
|
||||
(p.security === "tls" || p.security === "reality")),
|
||||
},
|
||||
{
|
||||
name: "security",
|
||||
@@ -441,7 +444,7 @@ export function useProtocolFields() {
|
||||
name: "encryption_ticket",
|
||||
type: "input",
|
||||
label: t("encryption_ticket", "Ticket Time"),
|
||||
placeholder: "e.g. 600s",
|
||||
placeholder: "e.g. 600",
|
||||
group: "encryption",
|
||||
condition: (p) =>
|
||||
p.encryption === "mlkem768x25519plus" &&
|
||||
@@ -1093,6 +1096,14 @@ export function useProtocolFields() {
|
||||
placeholder: "1-65535",
|
||||
group: "basic",
|
||||
},
|
||||
{
|
||||
name: "security",
|
||||
type: "select",
|
||||
label: t("security", "Security"),
|
||||
options: SECURITY.anytls,
|
||||
defaultValue: "tls",
|
||||
group: "security",
|
||||
},
|
||||
{
|
||||
name: "padding_scheme",
|
||||
type: "textarea",
|
||||
@@ -1108,12 +1119,14 @@ export function useProtocolFields() {
|
||||
type: "input",
|
||||
label: t("security_sni", "SNI"),
|
||||
group: "security",
|
||||
condition: (p) => p.security !== "none",
|
||||
},
|
||||
{
|
||||
name: "allow_insecure",
|
||||
type: "switch",
|
||||
label: t("security_allow_insecure", "Allow Insecure"),
|
||||
group: "security",
|
||||
condition: (p) => p.security !== "none",
|
||||
},
|
||||
{
|
||||
name: "fingerprint",
|
||||
@@ -1122,6 +1135,7 @@ export function useProtocolFields() {
|
||||
options: FINGERPRINTS,
|
||||
defaultValue: "chrome",
|
||||
group: "security",
|
||||
condition: (p) => p.security !== "none",
|
||||
},
|
||||
{
|
||||
name: "cert_mode",
|
||||
@@ -1130,6 +1144,7 @@ export function useProtocolFields() {
|
||||
options: CERT_MODES,
|
||||
defaultValue: "none",
|
||||
group: "security",
|
||||
condition: (p) => p.security === "tls",
|
||||
},
|
||||
{
|
||||
name: "cert_dns_provider",
|
||||
@@ -1148,6 +1163,63 @@ export function useProtocolFields() {
|
||||
group: "security",
|
||||
condition: (p) => p.cert_mode === "dns",
|
||||
},
|
||||
{
|
||||
name: "reality_server_addr",
|
||||
type: "input",
|
||||
label: t("security_server_address", "Reality Server Address"),
|
||||
placeholder: t(
|
||||
"security_server_address_placeholder",
|
||||
"e.g. 1.2.3.4 or domain"
|
||||
),
|
||||
group: "reality",
|
||||
condition: (p) => p.security === "reality",
|
||||
},
|
||||
{
|
||||
name: "reality_server_port",
|
||||
type: "number",
|
||||
label: t("security_server_port", "Reality Server Port"),
|
||||
min: 1,
|
||||
max: 65_535,
|
||||
placeholder: "1-65535",
|
||||
group: "reality",
|
||||
condition: (p) => p.security === "reality",
|
||||
},
|
||||
{
|
||||
name: "reality_private_key",
|
||||
type: "input",
|
||||
label: t("security_private_key", "Reality Private Key"),
|
||||
placeholder: t(
|
||||
"security_private_key_placeholder",
|
||||
"Enter private key"
|
||||
),
|
||||
group: "reality",
|
||||
generate: {
|
||||
function: generateRealityKeyPair,
|
||||
updateFields: {
|
||||
reality_private_key: "privateKey",
|
||||
reality_public_key: "publicKey",
|
||||
} as Record<string, string>,
|
||||
},
|
||||
condition: (p) => p.security === "reality",
|
||||
},
|
||||
{
|
||||
name: "reality_public_key",
|
||||
type: "input",
|
||||
label: t("security_public_key", "Reality Public Key"),
|
||||
placeholder: t("security_public_key_placeholder", "Enter public key"),
|
||||
group: "reality",
|
||||
condition: (p) => p.security === "reality",
|
||||
},
|
||||
{
|
||||
name: "reality_short_id",
|
||||
type: "input",
|
||||
label: t("security_short_id", "Reality Short ID"),
|
||||
group: "reality",
|
||||
generate: {
|
||||
function: generateRealityShortId,
|
||||
},
|
||||
condition: (p) => p.security === "reality",
|
||||
},
|
||||
],
|
||||
}),
|
||||
[t]
|
||||
|
||||
Reference in New Issue
Block a user