diff --git a/electron/api/config.ts b/electron/api/config.ts index ef90b87..6957d6c 100644 --- a/electron/api/config.ts +++ b/electron/api/config.ts @@ -201,8 +201,10 @@ export const initConfigApi = win => { httpPassword: m.httpPassword || "", // 以下为stcp参数 stcpModel: "visited", + serverUser: "", serverName: "", secretKey: m?.secretKey || "", + allowUsers: m?.allowUsers || [], bindAddr: "", bindPort: null, status: m?.status || true, @@ -237,8 +239,10 @@ export const initConfigApi = win => { stcpModel: "visitors", serverName: m?.serverName, secretKey: m?.secretKey || "", + serverUser: m?.serverUser, bindAddr: m?.bindAddr, bindPort: m?.bindPort, + allowUsers: [], status: m?.status || true, fallbackTo: m?.fallbackTo, fallbackTimeoutMs: m?.fallbackTimeoutMs || 500, diff --git a/electron/api/frpc.ts b/electron/api/frpc.ts index 8e16388..7d83a17 100644 --- a/electron/api/frpc.ts +++ b/electron/api/frpc.ts @@ -115,6 +115,9 @@ localPort = ${m.localPort}\n`; toml += `serverName = "${m.serverName}" bindAddr = "${m.bindAddr}" bindPort = ${m.bindPort}\n`; + if (m.serverUser !== "") { + toml += `serverUser = "${m.serverUser}"\n` + } if (m.fallbackTo) { toml += `fallbackTo = "${m.fallbackTo}" fallbackTimeoutMs = ${m.fallbackTimeoutMs || 500}\n`; @@ -123,6 +126,10 @@ fallbackTimeoutMs = ${m.fallbackTimeoutMs || 500}\n`; // 被访问者 toml += `localIP = "${m.localIp}" localPort = ${m.localPort}\n`; +const allowUsers = m.allowUsers.filter(f1 => f1 !== ""); + if (allowUsers && allowUsers.length > 0) { + toml += `allowUsers = [${m.allowUsers.map(m => `"${m}"`)}]\n`; + } } toml += `secretKey="${m.secretKey}"\n`; @@ -283,6 +290,7 @@ local_port = ${m.localPort}\n`; // 访问者 ini += ` role = visitor +server_user = "${m.serverUser}" server_name = "${m.serverName}" bind_addr = "${m.bindAddr}" bind_port = ${m.bindPort}\n`; @@ -294,6 +302,7 @@ fallback_timeout_ms = ${m.fallbackTimeoutMs || 500}\n`; } else if (m.stcpModel === "visited") { // 被访问者 ini += ` +allow_users = ${m.allowUsers.map(m => `${m}`)} local_ip = "${m.localIp}" local_port = ${m.localPort}\n`; } diff --git a/src/views/proxy/index.vue b/src/views/proxy/index.vue index 055337a..68e68f4 100644 --- a/src/views/proxy/index.vue +++ b/src/views/proxy/index.vue @@ -53,8 +53,10 @@ const defaultForm = ref({ remotePort: "8080", customDomains: [""], stcpModel: "visitors", + serverUser: "", serverName: "", secretKey: "", + allowUsers: [""], bindAddr: "", bindPort: null, status: true, @@ -301,6 +303,21 @@ const handleDeleteDomain = (index: number) => { editForm.value.customDomains.splice(index, 1); }; +/** + * 添加允许访问用户名称 + */ + const handleAddUser = () => { + editForm.value.allowUsers.push(""); +}; + +/** + * 删除允许访问用户名称 + * @param index + */ +const handleDeleteUser = (index: number) => { + editForm.value.allowUsers.splice(index, 1); +}; + /** * 加载代理 */ @@ -913,6 +930,62 @@ onUnmounted(() => { +