From f788990705dc011b9105b0652124eeca652053f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=98=89=E4=BC=9F?= <8473136@qq.com> Date: Wed, 25 Sep 2024 10:21:29 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=90=AF=E5=8A=A8=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E5=92=8C=E6=94=AF=E6=8C=81=20http=20Basic=E3=80=81=E5=AD=90?= =?UTF-8?q?=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/api/frpc.ts | 20 +++++- src/views/config/index.vue | 1 + src/views/proxy/index.vue | 133 +++++++++++++++++++++++++++++-------- types/global.d.ts | 6 +- 4 files changed, 130 insertions(+), 30 deletions(-) diff --git a/electron/api/frpc.ts b/electron/api/frpc.ts index be3452c..740b63c 100644 --- a/electron/api/frpc.ts +++ b/electron/api/frpc.ts @@ -35,8 +35,8 @@ const getFrpcVersionWorkerPath = ( const isRangePort = (m: Proxy) => { return ( - (m.localPort.indexOf("-") !== -1 || m.localPort.indexOf(",") !== -1) && - (m.type === "tcp" || m.type === "udp") + (m.type === "tcp" || m.type === "udp") && + (m.localPort.indexOf("-") !== -1 || m.localPort.indexOf(",") !== -1) ); }; @@ -82,7 +82,14 @@ remotePort = ${m.remotePort} localIP = "${m.localIp}" localPort = ${m.localPort} customDomains=[${m.customDomains.map(m => `"${m}"`)}] +subdomain="${m.subdomain}" `; + if (m.basicAuth) { + toml += ` +httpUser = "${m.httpUser}" +httpPassword = "${m.httpPassword}" +`; + } break; case "stcp": if (m.stcpModel === "visitors") { @@ -204,7 +211,7 @@ export const genIniConfig = (config: FrpConfig, proxys: Proxy[]) => { const proxyIni = proxys.map(m => { const rangePort = isRangePort(m); let ini = ` -[${rangePort ? 'range:' : ''}${m.name}] +[${rangePort ? "range:" : ""}${m.name}] type = "${m.type}" `; switch (m.type) { @@ -222,7 +229,14 @@ remote_port = ${m.remotePort} local_ip = "${m.localIp}" local_port = ${m.localPort} custom_domains=[${m.customDomains.map(m => `"${m}"`)}] +subdomain="${m.subdomain}" `; + if (m.basicAuth) { + ini += ` +httpUser = "${m.httpUser}" +httpPassword = "${m.httpPassword}" +`; + } break; case "stcp": if (m.stcpModel === "visitors") { diff --git a/src/views/config/index.vue b/src/views/config/index.vue index 2502bec..61e00ed 100644 --- a/src/views/config/index.vue +++ b/src/views/config/index.vue @@ -537,6 +537,7 @@ onUnmounted(() => { placeholder="token" type="password" v-model="formData.authToken" + :show-password="true" /> diff --git a/src/views/proxy/index.vue b/src/views/proxy/index.vue index 0519298..7af4daa 100644 --- a/src/views/proxy/index.vue +++ b/src/views/proxy/index.vue @@ -57,7 +57,11 @@ const defaultForm = ref({ secretKey: "", bindAddr: "", bindPort: null, - status: true + status: true, + subdomain: "", + basicAuth: false, + httpUser: "", + httpPassword: "" }); /** @@ -133,7 +137,12 @@ const editFormRules = reactive({ trigger: "blur" } ], - bindPort: [{ required: true, message: "请输入绑定的端口", trigger: "blur" }] + bindPort: [{ required: true, message: "请输入绑定的端口", trigger: "blur" }], + basicAuth: [ + { required: true, message: "请选择是否开启HTTP基本认证", trigger: "blur" } + ], + httpUser: [{ required: true, message: "请输入认证用户名", trigger: "blur" }], + httpPassword: [{ required: true, message: "请输入认证密码", trigger: "blur" }] }); /** @@ -192,6 +201,9 @@ const handleGetPortCount = (portString: string) => { }; const handleRangePort = () => { + if (isHttp || isHttps) { + return false; + } if (editForm.value.localPort.indexOf("-") !== -1) { return true; } @@ -631,13 +643,20 @@ onUnmounted(() => { - + + + + + + + { - 共享密钥: + 共享密钥: @@ -701,6 +720,7 @@ onUnmounted(() => { type="password" v-model="editForm.secretKey" placeholder="密钥" + :show-password="true" /> @@ -762,7 +782,6 @@ onUnmounted(() => { - + { +