fix relay

This commit is contained in:
ryan
2026-06-22 11:56:31 +08:00
parent 53e6efa33b
commit 0a3cd250d1
12 changed files with 131 additions and 270 deletions
+4
View File
@@ -22,6 +22,8 @@ sidebar: false
### 变更 ### 变更
- 彻底移除废弃的 GitHub OAuth 和微信登录相关遗留设置项(包括 `GitHubOAuthEnabled`、`GitHubClientId`、`GitHubClientSecret`、`WeChatAuthEnabled` 等),从公开状态接口 `/api/v1/d/status` 移除这些字段的返回。
- 前端路由调整:将 TLS 证书和 DNS 账号的路由地址移出 `/websites`(分别变更为顶级路由 `/certificates` 和 `/dns-accounts`),将 WAF IP 组的路由地址移出 `/waf`(变更为顶级路由 `/ip-groups`)。 - 前端路由调整:将 TLS 证书和 DNS 账号的路由地址移出 `/websites`(分别变更为顶级路由 `/certificates` 和 `/dns-accounts`),将 WAF IP 组的路由地址移出 `/waf`(变更为顶级路由 `/ip-groups`)。
- 前端页面鉴权改为默认私域:除 `/login`、`/register`、`/callback` 外,未登录访问任意页面(含数据看板 `/`)均重定向至登录页。 - 前端页面鉴权改为默认私域:除 `/login`、`/register`、`/callback` 外,未登录访问任意页面(含数据看板 `/`)均重定向至登录页。
@@ -30,6 +32,8 @@ sidebar: false
### 修复 ### 修复
- 修复点击「打开 FRPS WebUI」跳转到 `about:blank#blocked`:在 Relay 节点详情页的 WebUI 磁贴卡片中增加展示具体 URL 地址,并提供一键复制按钮。解决因 Chrome 浏览器限制从公网安全源(HTTPS)跨域直接访问本地/私有网络 HTTP 端口(Private Network Access 限制)而导致新页面打开被拦截的问题。
- 修复 Docker 部署模式下 Agent 无法自更新:修改 Docker 启动脚本 `agent-entrypoint.sh`,在降权前将二进制文件所在目录 `/usr/local/bin` 及二进制文件自身的属主赋予 `openflare`,解决容器内自更新写入时报 `permission denied` 的问题。 - 修复 Docker 部署模式下 Agent 无法自更新:修改 Docker 启动脚本 `agent-entrypoint.sh`,在降权前将二进制文件所在目录 `/usr/local/bin` 及二进制文件自身的属主赋予 `openflare`,解决容器内自更新写入时报 `permission denied` 的问题。
- 修复 Agent 升级版本比对逻辑:使用统一的 `pkg/utils.CompareVersions` 对比版本,正确处理预览/预发布版本(如 `v3.0.0-beta` 升级到 `v3.0.0-beta.1`),避免升级按钮非预期禁用的问题。 - 修复 Agent 升级版本比对逻辑:使用统一的 `pkg/utils.CompareVersions` 对比版本,正确处理预览/预发布版本(如 `v3.0.0-beta` 升级到 `v3.0.0-beta.1`),避免升级按钮非预期禁用的问题。
+15 -74
View File
@@ -309,7 +309,6 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "认证源 ID 或名称", "description": "认证源 ID 或名称",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -387,7 +386,6 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "认证源 ID 或名称", "description": "认证源 ID 或名称",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -455,7 +453,6 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "认证源 ID 或名称", "description": "认证源 ID 或名称",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -1366,7 +1363,6 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "通道ID", "description": "通道ID",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -1420,7 +1416,6 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "通道ID", "description": "通道ID",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -3373,7 +3368,6 @@ const docTemplate = `{
}, },
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "上传用户 ID", "description": "上传用户 ID",
"name": "user_id", "name": "user_id",
"in": "query" "in": "query"
@@ -4352,7 +4346,7 @@ const docTemplate = `{
"type": "object", "type": "object",
"properties": { "properties": {
"data": { "data": {
"$ref": "#/definitions/protocol.PagesDeploymentHashResponse" "$ref": "#/definitions/github_com_Rain-kl_Wavelet_pkg_protocol.PagesDeploymentHashResponse"
} }
} }
} }
@@ -4528,38 +4522,6 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/custom/hello": {
"get": {
"description": "A sample business API for customization",
"produces": [
"application/json"
],
"tags": [
"custom"
],
"summary": "Sample Hello API",
"responses": {
"200": {
"description": "成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "string"
}
}
}
]
}
}
}
}
},
"/api/v1/d/access-logs": { "/api/v1/d/access-logs": {
"get": { "get": {
"security": [ "security": [
@@ -11226,7 +11188,6 @@ const docTemplate = `{
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "外部帐号绑定记录 ID", "description": "外部帐号绑定记录 ID",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -13858,22 +13819,19 @@ const docTemplate = `{
"source_countries": { "source_countries": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
"type": "integer", "type": "integer"
"format": "int64"
} }
}, },
"status_codes": { "status_codes": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
"type": "integer", "type": "integer"
"format": "int64"
} }
}, },
"top_domains": { "top_domains": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
"type": "integer", "type": "integer"
"format": "int64"
} }
}, },
"unique_visitor_count": { "unique_visitor_count": {
@@ -13887,6 +13845,17 @@ const docTemplate = `{
} }
} }
}, },
"github_com_Rain-kl_Wavelet_pkg_protocol.PagesDeploymentHashResponse": {
"type": "object",
"properties": {
"deployment_id": {
"type": "integer"
},
"hash": {
"type": "string"
}
}
},
"github_com_Rain-kl_Wavelet_pkg_protocol.WAFIPGroup": { "github_com_Rain-kl_Wavelet_pkg_protocol.WAFIPGroup": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -15167,11 +15136,6 @@ const docTemplate = `{
"UploadStatusPending": "待使用", "UploadStatusPending": "待使用",
"UploadStatusUsed": "已使用" "UploadStatusUsed": "已使用"
}, },
"x-enum-descriptions": [
"待使用",
"已使用",
"已删除"
],
"x-enum-varnames": [ "x-enum-varnames": [
"UploadStatusPending", "UploadStatusPending",
"UploadStatusUsed", "UploadStatusUsed",
@@ -16256,12 +16220,6 @@ const docTemplate = `{
"footer_html": { "footer_html": {
"type": "string" "type": "string"
}, },
"github_client_id": {
"type": "string"
},
"github_oauth": {
"type": "boolean"
},
"home_page_link": { "home_page_link": {
"type": "string" "type": "string"
}, },
@@ -16279,12 +16237,6 @@ const docTemplate = `{
}, },
"version": { "version": {
"type": "string" "type": "string"
},
"wechat_login": {
"type": "boolean"
},
"wechat_qrcode": {
"type": "string"
} }
} }
}, },
@@ -16692,17 +16644,6 @@ const docTemplate = `{
} }
} }
}, },
"protocol.PagesDeploymentHashResponse": {
"type": "object",
"properties": {
"deployment_id": {
"type": "integer"
},
"hash": {
"type": "string"
}
}
},
"protocol.RelayConfig": { "protocol.RelayConfig": {
"type": "object", "type": "object",
"properties": { "properties": {
+15 -74
View File
@@ -302,7 +302,6 @@
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "认证源 ID 或名称", "description": "认证源 ID 或名称",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -380,7 +379,6 @@
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "认证源 ID 或名称", "description": "认证源 ID 或名称",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -448,7 +446,6 @@
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "认证源 ID 或名称", "description": "认证源 ID 或名称",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -1359,7 +1356,6 @@
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "通道ID", "description": "通道ID",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -1413,7 +1409,6 @@
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "通道ID", "description": "通道ID",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -3366,7 +3361,6 @@
}, },
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "上传用户 ID", "description": "上传用户 ID",
"name": "user_id", "name": "user_id",
"in": "query" "in": "query"
@@ -4345,7 +4339,7 @@
"type": "object", "type": "object",
"properties": { "properties": {
"data": { "data": {
"$ref": "#/definitions/protocol.PagesDeploymentHashResponse" "$ref": "#/definitions/github_com_Rain-kl_Wavelet_pkg_protocol.PagesDeploymentHashResponse"
} }
} }
} }
@@ -4521,38 +4515,6 @@
} }
} }
}, },
"/api/v1/custom/hello": {
"get": {
"description": "A sample business API for customization",
"produces": [
"application/json"
],
"tags": [
"custom"
],
"summary": "Sample Hello API",
"responses": {
"200": {
"description": "成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.Any"
},
{
"type": "object",
"properties": {
"data": {
"type": "string"
}
}
}
]
}
}
}
}
},
"/api/v1/d/access-logs": { "/api/v1/d/access-logs": {
"get": { "get": {
"security": [ "security": [
@@ -11219,7 +11181,6 @@
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
"format": "int64",
"description": "外部帐号绑定记录 ID", "description": "外部帐号绑定记录 ID",
"name": "id", "name": "id",
"in": "path", "in": "path",
@@ -13851,22 +13812,19 @@
"source_countries": { "source_countries": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
"type": "integer", "type": "integer"
"format": "int64"
} }
}, },
"status_codes": { "status_codes": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
"type": "integer", "type": "integer"
"format": "int64"
} }
}, },
"top_domains": { "top_domains": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
"type": "integer", "type": "integer"
"format": "int64"
} }
}, },
"unique_visitor_count": { "unique_visitor_count": {
@@ -13880,6 +13838,17 @@
} }
} }
}, },
"github_com_Rain-kl_Wavelet_pkg_protocol.PagesDeploymentHashResponse": {
"type": "object",
"properties": {
"deployment_id": {
"type": "integer"
},
"hash": {
"type": "string"
}
}
},
"github_com_Rain-kl_Wavelet_pkg_protocol.WAFIPGroup": { "github_com_Rain-kl_Wavelet_pkg_protocol.WAFIPGroup": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -15160,11 +15129,6 @@
"UploadStatusPending": "待使用", "UploadStatusPending": "待使用",
"UploadStatusUsed": "已使用" "UploadStatusUsed": "已使用"
}, },
"x-enum-descriptions": [
"待使用",
"已使用",
"已删除"
],
"x-enum-varnames": [ "x-enum-varnames": [
"UploadStatusPending", "UploadStatusPending",
"UploadStatusUsed", "UploadStatusUsed",
@@ -16249,12 +16213,6 @@
"footer_html": { "footer_html": {
"type": "string" "type": "string"
}, },
"github_client_id": {
"type": "string"
},
"github_oauth": {
"type": "boolean"
},
"home_page_link": { "home_page_link": {
"type": "string" "type": "string"
}, },
@@ -16272,12 +16230,6 @@
}, },
"version": { "version": {
"type": "string" "type": "string"
},
"wechat_login": {
"type": "boolean"
},
"wechat_qrcode": {
"type": "string"
} }
} }
}, },
@@ -16685,17 +16637,6 @@
} }
} }
}, },
"protocol.PagesDeploymentHashResponse": {
"type": "object",
"properties": {
"deployment_id": {
"type": "integer"
},
"hash": {
"type": "string"
}
}
},
"protocol.RelayConfig": { "protocol.RelayConfig": {
"type": "object", "type": "object",
"properties": { "properties": {
+8 -48
View File
@@ -713,17 +713,14 @@ definitions:
type: integer type: integer
source_countries: source_countries:
additionalProperties: additionalProperties:
format: int64
type: integer type: integer
type: object type: object
status_codes: status_codes:
additionalProperties: additionalProperties:
format: int64
type: integer type: integer
type: object type: object
top_domains: top_domains:
additionalProperties: additionalProperties:
format: int64
type: integer type: integer
type: object type: object
unique_visitor_count: unique_visitor_count:
@@ -733,6 +730,13 @@ definitions:
window_started_at_unix: window_started_at_unix:
type: integer type: integer
type: object type: object
github_com_Rain-kl_Wavelet_pkg_protocol.PagesDeploymentHashResponse:
properties:
deployment_id:
type: integer
hash:
type: string
type: object
github_com_Rain-kl_Wavelet_pkg_protocol.WAFIPGroup: github_com_Rain-kl_Wavelet_pkg_protocol.WAFIPGroup:
properties: properties:
checksum: checksum:
@@ -1589,10 +1593,6 @@ definitions:
UploadStatusDeleted: 已删除 UploadStatusDeleted: 已删除
UploadStatusPending: 待使用 UploadStatusPending: 待使用
UploadStatusUsed: 已使用 UploadStatusUsed: 已使用
x-enum-descriptions:
- 待使用
- 已使用
- 已删除
x-enum-varnames: x-enum-varnames:
- UploadStatusPending - UploadStatusPending
- UploadStatusUsed - UploadStatusUsed
@@ -2302,10 +2302,6 @@ definitions:
type: boolean type: boolean
footer_html: footer_html:
type: string type: string
github_client_id:
type: string
github_oauth:
type: boolean
home_page_link: home_page_link:
type: string type: string
password_register_enabled: password_register_enabled:
@@ -2318,10 +2314,6 @@ definitions:
type: string type: string
version: version:
type: string type: string
wechat_login:
type: boolean
wechat_qrcode:
type: string
type: object type: object
origin.DetailView: origin.DetailView:
properties: properties:
@@ -2588,13 +2580,6 @@ definitions:
relay_node_id: relay_node_id:
type: string type: string
type: object type: object
protocol.PagesDeploymentHashResponse:
properties:
deployment_id:
type: integer
hash:
type: string
type: object
protocol.RelayConfig: protocol.RelayConfig:
properties: properties:
auth_token: auth_token:
@@ -4104,7 +4089,6 @@ paths:
description: 删除指定认证源及其关联的所有外部帐号绑定记录,警告:删除后相关用户将无法通过该源登录,需要管理员权限 description: 删除指定认证源及其关联的所有外部帐号绑定记录,警告:删除后相关用户将无法通过该源登录,需要管理员权限
parameters: parameters:
- description: 认证源 ID 或名称 - description: 认证源 ID 或名称
format: int64
in: path in: path
name: id name: id
required: true required: true
@@ -4144,7 +4128,6 @@ paths:
description: 更新指定 ID 的认证源配置。若 client_secret 字段为空,则保留原有密钥不变,需要管理员权限 description: 更新指定 ID 的认证源配置。若 client_secret 字段为空,则保留原有密钥不变,需要管理员权限
parameters: parameters:
- description: 认证源 ID 或名称 - description: 认证源 ID 或名称
format: int64
in: path in: path
name: id name: id
required: true required: true
@@ -4195,7 +4178,6 @@ paths:
description: 启用或禁用指定认证源。尝试启用时将验证 Client ID 和 Client Secret 是否已配置,需要管理员权限 description: 启用或禁用指定认证源。尝试启用时将验证 Client ID 和 Client Secret 是否已配置,需要管理员权限
parameters: parameters:
- description: 认证源 ID 或名称 - description: 认证源 ID 或名称
format: int64
in: path in: path
name: id name: id
required: true required: true
@@ -4692,7 +4674,6 @@ paths:
description: 根据ID删除消息通道,需要管理员权限 description: 根据ID删除消息通道,需要管理员权限
parameters: parameters:
- description: 通道ID - description: 通道ID
format: int64
in: path in: path
name: id name: id
required: true required: true
@@ -4715,7 +4696,6 @@ paths:
description: 修改消息通道配置,需要管理员权限 description: 修改消息通道配置,需要管理员权限
parameters: parameters:
- description: 通道ID - description: 通道ID
format: int64
in: path in: path
name: id name: id
required: true required: true
@@ -5936,7 +5916,6 @@ paths:
name: extension name: extension
type: string type: string
- description: 上传用户 ID - description: 上传用户 ID
format: int64
in: query in: query
name: user_id name: user_id
type: integer type: integer
@@ -6528,7 +6507,7 @@ paths:
- $ref: '#/definitions/response.Any' - $ref: '#/definitions/response.Any'
- properties: - properties:
data: data:
$ref: '#/definitions/protocol.PagesDeploymentHashResponse' $ref: '#/definitions/github_com_Rain-kl_Wavelet_pkg_protocol.PagesDeploymentHashResponse'
type: object type: object
"400": "400":
description: 参数错误 description: 参数错误
@@ -6637,24 +6616,6 @@ paths:
summary: 获取公共配置 summary: 获取公共配置
tags: tags:
- config - config
/api/v1/custom/hello:
get:
description: A sample business API for customization
produces:
- application/json
responses:
"200":
description: 成功
schema:
allOf:
- $ref: '#/definitions/response.Any'
- properties:
data:
type: string
type: object
summary: Sample Hello API
tags:
- custom
/api/v1/d/access-logs: /api/v1/d/access-logs:
get: get:
description: 分页返回 OpenFlare 访问日志,支持按节点、IP、主机与路径筛选,需要管理员权限 description: 分页返回 OpenFlare 访问日志,支持按节点、IP、主机与路径筛选,需要管理员权限
@@ -10711,7 +10672,6 @@ paths:
description: 解除当前登录用户与指定外部帐号的绑定关系,需要登录 description: 解除当前登录用户与指定外部帐号的绑定关系,需要登录
parameters: parameters:
- description: 外部帐号绑定记录 ID - description: 外部帐号绑定记录 ID
format: int64
in: path in: path
name: id name: id
required: true required: true
@@ -6,6 +6,7 @@ import {useMutation, useQueryClient} from '@tanstack/react-query';
import {useState} from 'react'; import {useState} from 'react';
import { import {
Activity, Activity,
Copy,
ExternalLink, ExternalLink,
FileText, FileText,
Fingerprint, Fingerprint,
@@ -38,11 +39,7 @@ import {NodeService} from '@/lib/services/openflare';
import {AgentUpdateDialog} from './agent-update-dialog'; import {AgentUpdateDialog} from './agent-update-dialog';
import {InstallCommand} from './install-command'; import {InstallCommand} from './install-command';
import {NodeDetailShell} from './node-detail-shell'; import {NodeDetailShell} from './node-detail-shell';
import { import {NodeErrorBanner, NodeInfoRow, NodeSectionCard,} from './node-detail-primitives';
NodeErrorBanner,
NodeInfoRow,
NodeSectionCard,
} from './node-detail-primitives';
import {NodeEditorDialog} from './node-editor-dialog'; import {NodeEditorDialog} from './node-editor-dialog';
import {NodeObservability} from './node-observability'; import {NodeObservability} from './node-observability';
import {NodeStatusBadge} from './node-status-badge'; import {NodeStatusBadge} from './node-status-badge';
@@ -278,15 +275,32 @@ export function RelayNodeDetail({ node }: { node: NodeItem }) {
</div> </div>
{webUiUrl ? ( {webUiUrl ? (
<a <div className="flex flex-wrap items-center gap-3 text-sm">
href={webUiUrl} <a
target="_blank" href={webUiUrl}
rel="noreferrer" target="_blank"
className="inline-flex items-center text-sm font-medium text-primary hover:underline" rel="noopener noreferrer"
> className="inline-flex items-center font-medium text-primary hover:underline"
打开 FRPS WebUI >
<ExternalLink className="size-3.5 ml-1.5" /> 打开 FRPS WebUI
</a> <ExternalLink className="size-3.5 ml-1.5" />
</a>
<span className="text-xs text-muted-foreground font-mono bg-muted px-2 py-0.5 rounded border">
{webUiUrl}
</span>
<Button
variant="ghost"
size="icon"
className="size-7 text-muted-foreground hover:text-foreground"
onClick={() => {
void navigator.clipboard.writeText(webUiUrl);
toast.success('链接已复制到剪贴板');
}}
title="复制链接"
>
<Copy className="size-3.5" />
</Button>
</div>
) : ( ) : (
<p className="text-sm text-muted-foreground">WebUI 已禁用或未配置绑定端口。</p> <p className="text-sm text-muted-foreground">WebUI 已禁用或未配置绑定端口。</p>
)} )}
@@ -389,4 +403,4 @@ export function RelayNodeDetail({ node }: { node: NodeItem }) {
</AlertDialog> </AlertDialog>
</> </>
); );
} }
-8
View File
@@ -50,13 +50,9 @@ type statusView struct {
Version string `json:"version"` Version string `json:"version"`
StartTime int64 `json:"start_time"` StartTime int64 `json:"start_time"`
EmailVerification bool `json:"email_verification"` EmailVerification bool `json:"email_verification"`
GitHubOAuth bool `json:"github_oauth"`
GitHubClientID string `json:"github_client_id"`
SystemName string `json:"system_name"` SystemName string `json:"system_name"`
HomePageLink string `json:"home_page_link"` HomePageLink string `json:"home_page_link"`
FooterHTML string `json:"footer_html"` FooterHTML string `json:"footer_html"`
WeChatQRCode string `json:"wechat_qrcode"`
WeChatLogin bool `json:"wechat_login"`
ServerAddress string `json:"server_address"` ServerAddress string `json:"server_address"`
PasswordRegisterEnabled bool `json:"password_register_enabled"` PasswordRegisterEnabled bool `json:"password_register_enabled"`
CapLoginEnabled bool `json:"cap_login_enabled"` CapLoginEnabled bool `json:"cap_login_enabled"`
@@ -168,13 +164,9 @@ func getStatus(ctx context.Context, baseAPIPath string) (*statusView, error) {
Version: buildinfo.Version, Version: buildinfo.Version,
StartTime: model.StartTime, StartTime: model.StartTime,
EmailVerification: model.EmailVerificationEnabled, EmailVerification: model.EmailVerificationEnabled,
GitHubOAuth: model.GitHubOAuthEnabled,
GitHubClientID: model.GitHubClientID,
SystemName: model.SystemName, SystemName: model.SystemName,
HomePageLink: model.HomePageLink, HomePageLink: model.HomePageLink,
FooterHTML: model.Footer, FooterHTML: model.Footer,
WeChatQRCode: model.WeChatAccountQRCodeImageURL,
WeChatLogin: model.WeChatAuthEnabled,
ServerAddress: model.ServerAddress, ServerAddress: model.ServerAddress,
PasswordRegisterEnabled: model.PasswordRegisterEnabled, PasswordRegisterEnabled: model.PasswordRegisterEnabled,
CapLoginEnabled: model.CapLoginEnabled, CapLoginEnabled: model.CapLoginEnabled,
@@ -40,16 +40,6 @@ func buildOptionValidationState(options []model.OpenFlareOption) map[string]stri
} }
func validateOptionWithState(option model.OpenFlareOption, state map[string]string) error { func validateOptionWithState(option model.OpenFlareOption, state map[string]string) error {
switch option.Key {
case "GitHubOAuthEnabled":
if option.Value == optionValueTrue && strings.TrimSpace(state["GitHubClientId"]) == "" {
return fmt.Errorf("无法启用 GitHub OAuth,请先填入 GitHub Client ID 以及 GitHub Client Secret!")
}
case "WeChatAuthEnabled":
if option.Value == optionValueTrue && strings.TrimSpace(state["WeChatServerAddress"]) == "" {
return fmt.Errorf("无法启用微信登录,请先填入微信登录相关配置信息!")
}
}
if err := validateOpenRestyOption(option.Key, option.Value); err != nil { if err := validateOpenRestyOption(option.Key, option.Value); err != nil {
return err return err
+6 -15
View File
@@ -100,8 +100,7 @@ func TestMigrateUpgradesLegacyDatabaseAndPreservesData(t *testing.T) {
`INSERT INTO users (id, username, password, display_name, role, status, email) `INSERT INTO users (id, username, password, display_name, role, status, email)
VALUES (2, 'jack', 'hashed_pass_456', 'Normal User jack', 10, 1, 'jack@example.com');`, VALUES (2, 'jack', 'hashed_pass_456', 'Normal User jack', 10, 1, 'jack@example.com');`,
// Legacy config options // Legacy config options
`INSERT INTO options (key, value) VALUES ('GitHubClientId', 'Ov23lixMKW');`, `INSERT INTO options (key, value) VALUES ('SystemName', 'CustomOpenFlare');`,
`INSERT INTO options (key, value) VALUES ('GitHubClientSecret', 'secret_abc_123');`,
// Legacy origin // Legacy origin
`INSERT INTO origins (id, name, address, remark, created_at, updated_at) `INSERT INTO origins (id, name, address, remark, created_at, updated_at)
VALUES (10, 'my_origin', '127.0.0.1:8080', 'original origin', '2026-06-01 12:00:00', '2026-06-01 12:00:00');`, VALUES (10, 'my_origin', '127.0.0.1:8080', 'original origin', '2026-06-01 12:00:00', '2026-06-01 12:00:00');`,
@@ -183,20 +182,12 @@ func TestMigrateUpgradesLegacyDatabaseAndPreservesData(t *testing.T) {
} }
// Verify options migrated to of_options // Verify options migrated to of_options
var githubClientIDVal string var systemNameVal string
if err := sqliteDB.Table("of_options").Where("key = ?", "GitHubClientId").Select("value").Scan(&githubClientIDVal).Error; err != nil { if err := sqliteDB.Table("of_options").Where("key = ?", "SystemName").Select("value").Scan(&systemNameVal).Error; err != nil {
t.Fatalf("query GitHubClientId failed: %v", err) t.Fatalf("query SystemName failed: %v", err)
} }
if githubClientIDVal != "Ov23lixMKW" { if systemNameVal != "CustomOpenFlare" {
t.Errorf("GitHubClientId value incorrect: got %s, want Ov23lixMKW", githubClientIDVal) t.Errorf("SystemName value incorrect: got %s, want CustomOpenFlare", systemNameVal)
}
var githubClientSecretVal string
if err := sqliteDB.Table("of_options").Where("key = ?", "GitHubClientSecret").Select("value").Scan(&githubClientSecretVal).Error; err != nil {
t.Fatalf("query GitHubClientSecret failed: %v", err)
}
if githubClientSecretVal != "secret_abc_123" {
t.Errorf("GitHubClientSecret value incorrect: got %s, want secret_abc_123", githubClientSecretVal)
} }
// Verify origin migrated to of_origins // Verify origin migrated to of_origins
@@ -0,0 +1,22 @@
-- +goose Up
DELETE FROM of_options
WHERE key IN (
'GitHubOAuthEnabled',
'GitHubClientId',
'GitHubClientSecret',
'WeChatAuthEnabled',
'WeChatServerAddress',
'WeChatServerToken',
'WeChatAccountQRCodeImageURL'
);
-- +goose Down
INSERT INTO of_options (key, value) VALUES
('GitHubOAuthEnabled', 'false'),
('GitHubClientId', ''),
('GitHubClientSecret', ''),
('WeChatAuthEnabled', 'false'),
('WeChatServerAddress', ''),
('WeChatServerToken', ''),
('WeChatAccountQRCodeImageURL', '')
ON CONFLICT (key) DO NOTHING;
@@ -0,0 +1,21 @@
-- +goose Up
DELETE FROM of_options
WHERE key IN (
'GitHubOAuthEnabled',
'GitHubClientId',
'GitHubClientSecret',
'WeChatAuthEnabled',
'WeChatServerAddress',
'WeChatServerToken',
'WeChatAccountQRCodeImageURL'
);
-- +goose Down
INSERT OR IGNORE INTO of_options (key, value) VALUES
('GitHubOAuthEnabled', 'false'),
('GitHubClientId', ''),
('GitHubClientSecret', ''),
('WeChatAuthEnabled', 'false'),
('WeChatServerAddress', ''),
('WeChatServerToken', ''),
('WeChatAccountQRCodeImageURL', '');
-11
View File
@@ -42,10 +42,6 @@ var (
CapLoginEnabled = true CapLoginEnabled = true
PasswordRegisterEnabled = false PasswordRegisterEnabled = false
EmailVerificationEnabled = false EmailVerificationEnabled = false
GitHubOAuthEnabled = false
WeChatAuthEnabled = false
GitHubClientID = ""
WeChatAccountQRCodeImageURL = ""
SMTPPort = 587 SMTPPort = 587
AgentDiscoveryToken = "" AgentDiscoveryToken = ""
AgentHeartbeatInterval = 10000 AgentHeartbeatInterval = 10000
@@ -159,8 +155,6 @@ func DefaultOpenFlareOptions() map[string]string {
"CapLoginEnabled": strconv.FormatBool(CapLoginEnabled), "CapLoginEnabled": strconv.FormatBool(CapLoginEnabled),
"PasswordRegisterEnabled": strconv.FormatBool(PasswordRegisterEnabled), "PasswordRegisterEnabled": strconv.FormatBool(PasswordRegisterEnabled),
"EmailVerificationEnabled": strconv.FormatBool(EmailVerificationEnabled), "EmailVerificationEnabled": strconv.FormatBool(EmailVerificationEnabled),
"GitHubOAuthEnabled": strconv.FormatBool(GitHubOAuthEnabled),
"WeChatAuthEnabled": strconv.FormatBool(WeChatAuthEnabled),
"SMTPServer": "", "SMTPServer": "",
"SMTPPort": strconv.Itoa(SMTPPort), "SMTPPort": strconv.Itoa(SMTPPort),
"SMTPAccount": "", "SMTPAccount": "",
@@ -171,11 +165,6 @@ func DefaultOpenFlareOptions() map[string]string {
"HomePageLink": HomePageLink, "HomePageLink": HomePageLink,
"SystemName": SystemName, "SystemName": SystemName,
"ServerAddress": "", "ServerAddress": "",
"GitHubClientId": "",
"GitHubClientSecret": "",
"WeChatServerAddress": "",
"WeChatServerToken": "",
"WeChatAccountQRCodeImageURL": "",
"AgentDiscoveryToken": "", "AgentDiscoveryToken": "",
"AgentHeartbeatInterval": strconv.Itoa(AgentHeartbeatInterval), "AgentHeartbeatInterval": strconv.Itoa(AgentHeartbeatInterval),
"AgentWebsocketUpgradeEnabled": strconv.FormatBool(AgentWebsocketUpgradeEnabled), "AgentWebsocketUpgradeEnabled": strconv.FormatBool(AgentWebsocketUpgradeEnabled),
+11 -15
View File
@@ -11,27 +11,23 @@ var enabledOptionAppliers = map[string]func(bool){
"PasswordLoginEnabled": func(v bool) { PasswordLoginEnabled = v }, "PasswordLoginEnabled": func(v bool) { PasswordLoginEnabled = v },
"CapLoginEnabled": func(v bool) { CapLoginEnabled = v }, "CapLoginEnabled": func(v bool) { CapLoginEnabled = v },
"EmailVerificationEnabled": func(v bool) { EmailVerificationEnabled = v }, "EmailVerificationEnabled": func(v bool) { EmailVerificationEnabled = v },
"GitHubOAuthEnabled": func(v bool) { GitHubOAuthEnabled = v },
"WeChatAuthEnabled": func(v bool) { WeChatAuthEnabled = v },
"AgentWebsocketUpgradeEnabled": func(v bool) { AgentWebsocketUpgradeEnabled = v }, "AgentWebsocketUpgradeEnabled": func(v bool) { AgentWebsocketUpgradeEnabled = v },
"UptimeKumaEnabled": func(v bool) { UptimeKumaEnabled = v }, "UptimeKumaEnabled": func(v bool) { UptimeKumaEnabled = v },
"DatabaseAutoCleanupEnabled": func(v bool) { DatabaseAutoCleanupEnabled = v }, "DatabaseAutoCleanupEnabled": func(v bool) { DatabaseAutoCleanupEnabled = v },
} }
var stringOptionAppliers = map[string]func(string){ var stringOptionAppliers = map[string]func(string){
"ServerAddress": func(v string) { ServerAddress = v }, "ServerAddress": func(v string) { ServerAddress = v },
"GitHubClientId": func(v string) { GitHubClientID = v }, "Footer": func(v string) { Footer = v },
"Footer": func(v string) { Footer = v }, "HomePageLink": func(v string) { HomePageLink = v },
"HomePageLink": func(v string) { HomePageLink = v }, "SystemName": func(v string) { SystemName = v },
"SystemName": func(v string) { SystemName = v }, "AgentDiscoveryToken": func(v string) { AgentDiscoveryToken = v },
"WeChatAccountQRCodeImageURL": func(v string) { WeChatAccountQRCodeImageURL = v }, "GeoIPProvider": func(v string) { GeoIPProvider = v },
"AgentDiscoveryToken": func(v string) { AgentDiscoveryToken = v }, "UptimeKumaUrl": func(v string) { UptimeKumaURL = v },
"GeoIPProvider": func(v string) { GeoIPProvider = v }, "UptimeKumaUsername": func(v string) { UptimeKumaUsername = v },
"UptimeKumaUrl": func(v string) { UptimeKumaURL = v }, optionKeyUptimeKumaPassword: func(v string) { UptimeKumaPassword = v },
"UptimeKumaUsername": func(v string) { UptimeKumaUsername = v }, "UptimeKumaMonitorScope": func(v string) { UptimeKumaMonitorScope = v },
optionKeyUptimeKumaPassword: func(v string) { UptimeKumaPassword = v }, "UptimeKumaSelectedSites": func(v string) { UptimeKumaSelectedSites = v },
"UptimeKumaMonitorScope": func(v string) { UptimeKumaMonitorScope = v },
"UptimeKumaSelectedSites": func(v string) { UptimeKumaSelectedSites = v },
} }
func applyEnabledOptionMirror(key, value string) { func applyEnabledOptionMirror(key, value string) {