feat: Support config redir port and tproxy port

This commit is contained in:
MystiPanda
2024-03-20 23:38:47 +08:00
parent ef4711987f
commit 2d925c62f5
7 changed files with 152 additions and 7 deletions

View File

@@ -49,11 +49,19 @@ export const useClashInfo = () => {
patch: Partial<
Pick<
IConfigData,
"port" | "socks-port" | "mixed-port" | "external-controller" | "secret"
| "port"
| "socks-port"
| "mixed-port"
| "redir-port"
| "tproxy-port"
| "external-controller"
| "secret"
>
>
) => {
const hasInfo =
patch["redir-port"] != null ||
patch["tproxy-port"] != null ||
patch["mixed-port"] != null ||
patch["socks-port"] != null ||
patch["port"] != null ||
@@ -62,6 +70,26 @@ export const useClashInfo = () => {
if (!hasInfo) return;
if (patch["redir-port"]) {
const port = patch["redir-port"];
if (port < 1000) {
throw new Error("The port should not < 1000");
}
if (port > 65536) {
throw new Error("The port should not > 65536");
}
}
if (patch["tproxy-port"]) {
const port = patch["tproxy-port"];
if (port < 1000) {
throw new Error("The port should not < 1000");
}
if (port > 65536) {
throw new Error("The port should not > 65536");
}
}
if (patch["mixed-port"]) {
const port = patch["mixed-port"];
if (port < 1000) {