增加 https2http 插件

This commit is contained in:
刘嘉伟 2025-01-05 21:17:56 +08:00
parent 3157b935e0
commit a1910be29c
3 changed files with 117 additions and 39 deletions

16
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,16 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node-terminal",
"name": "运行脚本: dev",
"request": "launch",
"command": "npm run dev",
"cwd": "${workspaceFolder}"
}
]
}

View File

@ -114,7 +114,7 @@ type = "https2http"
localAddr = "${m.localIp}:${m.localPort}" localAddr = "${m.localIp}:${m.localPort}"
crtPath = "${m.https2httpCaFile}" crtPath = "${m.https2httpCaFile}"
keyPath = "${m.https2httpCaFile}" keyPath = "${m.https2httpKeyFile}"
`; `;
} else { } else {
toml += ` toml += `
@ -265,18 +265,42 @@ remote_port = ${m.remotePort}
`; `;
break; break;
case "http": case "http":
ini += `
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 "https": case "https":
ini += ` ini += `
local_ip = "${m.localIp}"
local_port = ${m.localPort}
custom_domains=[${m.customDomains.map(m => `${m}`)}] custom_domains=[${m.customDomains.map(m => `${m}`)}]
subdomain="${m.subdomain}" subdomain="${m.subdomain}"
`; `;
if (m.basicAuth) { if (m.basicAuth) {
ini += ` ini += `
httpUser = "${m.httpUser}" httpUser = "${m.httpUser}"
httpPassword = "${m.httpPassword}" httpPassword = "${m.httpPassword}"
`; `;
}
if (m.https2http) {
ini += `
plugin = https2http
plugin_local_addr = ${m.localIp}:${m.localPort}
plugin_crt_path = ${m.https2httpCaFile}
plugin_key_path = ${m.https2httpKeyFile}
`;
} else {
ini += `
local_ip = "${m.localIp}"
local_port = ${m.localPort}
`;
} }
break; break;
case "stcp": case "stcp":

View File

@ -147,8 +147,7 @@ const editFormRules = reactive<FormRules>({
{ required: true, message: "请选择是否开启HTTP基本认证", trigger: "blur" } { required: true, message: "请选择是否开启HTTP基本认证", trigger: "blur" }
], ],
httpUser: [{ required: true, message: "请输入认证用户名", trigger: "blur" }], httpUser: [{ required: true, message: "请输入认证用户名", trigger: "blur" }],
httpPassword: [{ required: true, message: "请输入认证密码", trigger: "blur" }], httpPassword: [{ required: true, message: "请输入认证密码", trigger: "blur" }]
}); });
/** /**
@ -565,6 +564,20 @@ const handleRandomProxyName = () => {
`df_${editForm.value.type}_${result}`.toLocaleLowerCase(); `df_${editForm.value.type}_${result}`.toLocaleLowerCase();
}; };
const handleSelectFile = (type: number, ext: string[]) => {
ipcRenderer.invoke("file.selectFile", ext).then(r => {
switch (type) {
case 1:
editForm.value.https2httpCaFile = r[0];
break;
case 2:
editForm.value.https2httpKeyFile = r[0];
break;
}
console.log(r);
});
};
onMounted(() => { onMounted(() => {
handleInitHook(); handleInitHook();
handleLoadProxys(); handleLoadProxys();
@ -627,7 +640,7 @@ onUnmounted(() => {
class="mr-2" class="mr-2"
type="danger" type="danger"
size="small" size="small"
>已禁用 >已禁用
</el-tag> </el-tag>
<el-tag <el-tag
v-if=" v-if="
@ -648,7 +661,7 @@ onUnmounted(() => {
proxy.type === 'sudp') && proxy.type === 'sudp') &&
proxy.stcpModel === 'visited' proxy.stcpModel === 'visited'
" "
>被访问者 >被访问者
</el-tag> </el-tag>
<!-- <el-tag--> <!-- <el-tag-->
<!-- size="small"--> <!-- size="small"-->
@ -716,7 +729,9 @@ onUnmounted(() => {
<div <div
class="text-sm text-left" class="text-sm text-left"
v-if=" v-if="
(proxy.type !== 'stcp' && proxy.type !== 'xtcp' && proxy.type !== 'sudp') || (proxy.type !== 'stcp' &&
proxy.type !== 'xtcp' &&
proxy.type !== 'sudp') ||
proxy.stcpModel !== 'visitors' proxy.stcpModel !== 'visitors'
" "
> >
@ -849,8 +864,8 @@ onUnmounted(() => {
<el-popover placement="top" trigger="hover" width="300"> <el-popover placement="top" trigger="hover" width="300">
<template #default> <template #default>
对应参数<span class="font-black text-[#5A3DAA]" 对应参数<span class="font-black text-[#5A3DAA]"
>secretKey</span >secretKey</span
> >
只有访问者与被访问者共享密钥一致的用户才能访问该服务 只有访问者与被访问者共享密钥一致的用户才能访问该服务
</template> </template>
<template #reference> <template #reference>
@ -977,8 +992,8 @@ onUnmounted(() => {
> >
<template #default> <template #default>
对应参数<span class="font-black text-[#5A3DAA]" 对应参数<span class="font-black text-[#5A3DAA]"
>subdomain</span >subdomain</span
> >
</template> </template>
<template #reference> <template #reference>
<IconifyIconOffline <IconifyIconOffline
@ -1029,8 +1044,8 @@ onUnmounted(() => {
<el-popover placement="top" trigger="hover"> <el-popover placement="top" trigger="hover">
<template #default> <template #default>
对应参数<span class="font-black text-[#5A3DAA]" 对应参数<span class="font-black text-[#5A3DAA]"
>customDomains</span >customDomains</span
> >
</template> </template>
<template #reference> <template #reference>
<IconifyIconOffline <IconifyIconOffline
@ -1103,7 +1118,16 @@ onUnmounted(() => {
</template> </template>
<template v-if="isHttps"> <template v-if="isHttps">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="https2http" prop="https2http"> <el-form-item
label="https2http"
prop="https2http"
:rules="[
{
required: true,
trigger: 'blur'
}
]"
>
<el-switch <el-switch
active-text="开" active-text="开"
inline-prompt inline-prompt
@ -1118,6 +1142,13 @@ onUnmounted(() => {
label="证书文件:" label="证书文件:"
prop="https2httpCaFile" prop="https2httpCaFile"
label-width="180" label-width="180"
:rules="[
{
required: true,
message: '证书文件不能为空',
trigger: 'blur'
}
]"
> >
<!-- <template #label> <!-- <template #label>
<div class="h-full flex items-center mr-1"> <div class="h-full flex items-center mr-1">
@ -1165,6 +1196,13 @@ onUnmounted(() => {
label="密钥文件:" label="密钥文件:"
prop="https2httpKeyFile" prop="https2httpKeyFile"
label-width="180" label-width="180"
:rules="[
{
required: true,
message: '密钥文件不能为空',
trigger: 'blur'
}
]"
> >
<!-- <template #label> <!-- <template #label>
<div class="h-full flex items-center mr-1"> <div class="h-full flex items-center mr-1">
@ -1227,21 +1265,21 @@ onUnmounted(() => {
<el-popover placement="top" trigger="hover" width="300"> <el-popover placement="top" trigger="hover" width="300">
<template #default> <template #default>
对应参数<span class="font-black text-[#5A3DAA]" 对应参数<span class="font-black text-[#5A3DAA]"
>bindAddr</span >bindAddr</span
> >
要将被访问者的服务绑定到本地哪个<span 要将被访问者的服务绑定到本地哪个<span
class="font-black text-[#5A3DAA]" class="font-black text-[#5A3DAA]"
>IP</span >IP</span
> >
<br /> <br />
仅本机访问<span class="font-black text-[#5A3DAA]" 仅本机访问<span class="font-black text-[#5A3DAA]"
>127.0.0.1</span >127.0.0.1</span
> >
<br /> <br />
支持局域网其他设备访问<span 支持局域网其他设备访问<span
class="font-black text-[#5A3DAA]" class="font-black text-[#5A3DAA]"
>0.0.0.0</span >0.0.0.0</span
> >
<br /> <br />
</template> </template>
<template #reference> <template #reference>
@ -1273,12 +1311,12 @@ onUnmounted(() => {
<el-popover placement="top" trigger="hover" width="300"> <el-popover placement="top" trigger="hover" width="300">
<template #default> <template #default>
对应参数<span class="font-black text-[#5A3DAA]" 对应参数<span class="font-black text-[#5A3DAA]"
>bindAddr</span >bindAddr</span
> >
要将被访问者的服务绑定到本地哪个<span 要将被访问者的服务绑定到本地哪个<span
class="font-black text-[#5A3DAA]" class="font-black text-[#5A3DAA]"
>端口</span >端口</span
> >
<br /> <br />
请自行确保端口未被占用 请自行确保端口未被占用
</template> </template>
@ -1316,8 +1354,8 @@ onUnmounted(() => {
<el-popover placement="top" trigger="hover" width="300"> <el-popover placement="top" trigger="hover" width="300">
<template #default> <template #default>
对应参数<span class="font-black text-[#5A3DAA]" 对应参数<span class="font-black text-[#5A3DAA]"
>fallbackTo</span >fallbackTo</span
> >
<br /> <br />
xtcp 打洞失败会回退到使用 stcp-visitor 建立连接 xtcp 打洞失败会回退到使用 stcp-visitor 建立连接
</template> </template>
@ -1350,14 +1388,14 @@ onUnmounted(() => {
<el-popover placement="top" trigger="hover" width="300"> <el-popover placement="top" trigger="hover" width="300">
<template #default> <template #default>
对应参数<span class="font-black text-[#5A3DAA]" 对应参数<span class="font-black text-[#5A3DAA]"
>fallbackTimeoutMs</span >fallbackTimeoutMs</span
> >
<br /> <br />
xtcp 打洞时间超过该时间会回退到使用 stcp-visitor xtcp 打洞时间超过该时间会回退到使用 stcp-visitor
建立连接 单位<span 建立连接 单位<span
class="font-black text-[#5A3DAA]" class="font-black text-[#5A3DAA]"
>毫秒</span >毫秒</span
> >
</template> </template>
<template #reference> <template #reference>
<IconifyIconOffline <IconifyIconOffline