mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 05:56:38 +08:00
fix relay
This commit is contained in:
@@ -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`)。
|
||||
|
||||
- 前端页面鉴权改为默认私域:除 `/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` 的问题。
|
||||
|
||||
- 修复 Agent 升级版本比对逻辑:使用统一的 `pkg/utils.CompareVersions` 对比版本,正确处理预览/预发布版本(如 `v3.0.0-beta` 升级到 `v3.0.0-beta.1`),避免升级按钮非预期禁用的问题。
|
||||
|
||||
+15
-74
@@ -309,7 +309,6 @@ const docTemplate = `{
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "认证源 ID 或名称",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -387,7 +386,6 @@ const docTemplate = `{
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "认证源 ID 或名称",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -455,7 +453,6 @@ const docTemplate = `{
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "认证源 ID 或名称",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -1366,7 +1363,6 @@ const docTemplate = `{
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "通道ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -1420,7 +1416,6 @@ const docTemplate = `{
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "通道ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -3373,7 +3368,6 @@ const docTemplate = `{
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "上传用户 ID",
|
||||
"name": "user_id",
|
||||
"in": "query"
|
||||
@@ -4352,7 +4346,7 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"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": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -11226,7 +11188,6 @@ const docTemplate = `{
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "外部帐号绑定记录 ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -13858,22 +13819,19 @@ const docTemplate = `{
|
||||
"source_countries": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"status_codes": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"top_domains": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -15167,11 +15136,6 @@ const docTemplate = `{
|
||||
"UploadStatusPending": "待使用",
|
||||
"UploadStatusUsed": "已使用"
|
||||
},
|
||||
"x-enum-descriptions": [
|
||||
"待使用",
|
||||
"已使用",
|
||||
"已删除"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"UploadStatusPending",
|
||||
"UploadStatusUsed",
|
||||
@@ -16256,12 +16220,6 @@ const docTemplate = `{
|
||||
"footer_html": {
|
||||
"type": "string"
|
||||
},
|
||||
"github_client_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"github_oauth": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"home_page_link": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16279,12 +16237,6 @@ const docTemplate = `{
|
||||
},
|
||||
"version": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
+15
-74
@@ -302,7 +302,6 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "认证源 ID 或名称",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -380,7 +379,6 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "认证源 ID 或名称",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -448,7 +446,6 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "认证源 ID 或名称",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -1359,7 +1356,6 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "通道ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -1413,7 +1409,6 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "通道ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -3366,7 +3361,6 @@
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "上传用户 ID",
|
||||
"name": "user_id",
|
||||
"in": "query"
|
||||
@@ -4345,7 +4339,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"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": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -11219,7 +11181,6 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "外部帐号绑定记录 ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
@@ -13851,22 +13812,19 @@
|
||||
"source_countries": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"status_codes": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"top_domains": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -15160,11 +15129,6 @@
|
||||
"UploadStatusPending": "待使用",
|
||||
"UploadStatusUsed": "已使用"
|
||||
},
|
||||
"x-enum-descriptions": [
|
||||
"待使用",
|
||||
"已使用",
|
||||
"已删除"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"UploadStatusPending",
|
||||
"UploadStatusUsed",
|
||||
@@ -16249,12 +16213,6 @@
|
||||
"footer_html": {
|
||||
"type": "string"
|
||||
},
|
||||
"github_client_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"github_oauth": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"home_page_link": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16272,12 +16230,6 @@
|
||||
},
|
||||
"version": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
+8
-48
@@ -713,17 +713,14 @@ definitions:
|
||||
type: integer
|
||||
source_countries:
|
||||
additionalProperties:
|
||||
format: int64
|
||||
type: integer
|
||||
type: object
|
||||
status_codes:
|
||||
additionalProperties:
|
||||
format: int64
|
||||
type: integer
|
||||
type: object
|
||||
top_domains:
|
||||
additionalProperties:
|
||||
format: int64
|
||||
type: integer
|
||||
type: object
|
||||
unique_visitor_count:
|
||||
@@ -733,6 +730,13 @@ definitions:
|
||||
window_started_at_unix:
|
||||
type: integer
|
||||
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:
|
||||
properties:
|
||||
checksum:
|
||||
@@ -1589,10 +1593,6 @@ definitions:
|
||||
UploadStatusDeleted: 已删除
|
||||
UploadStatusPending: 待使用
|
||||
UploadStatusUsed: 已使用
|
||||
x-enum-descriptions:
|
||||
- 待使用
|
||||
- 已使用
|
||||
- 已删除
|
||||
x-enum-varnames:
|
||||
- UploadStatusPending
|
||||
- UploadStatusUsed
|
||||
@@ -2302,10 +2302,6 @@ definitions:
|
||||
type: boolean
|
||||
footer_html:
|
||||
type: string
|
||||
github_client_id:
|
||||
type: string
|
||||
github_oauth:
|
||||
type: boolean
|
||||
home_page_link:
|
||||
type: string
|
||||
password_register_enabled:
|
||||
@@ -2318,10 +2314,6 @@ definitions:
|
||||
type: string
|
||||
version:
|
||||
type: string
|
||||
wechat_login:
|
||||
type: boolean
|
||||
wechat_qrcode:
|
||||
type: string
|
||||
type: object
|
||||
origin.DetailView:
|
||||
properties:
|
||||
@@ -2588,13 +2580,6 @@ definitions:
|
||||
relay_node_id:
|
||||
type: string
|
||||
type: object
|
||||
protocol.PagesDeploymentHashResponse:
|
||||
properties:
|
||||
deployment_id:
|
||||
type: integer
|
||||
hash:
|
||||
type: string
|
||||
type: object
|
||||
protocol.RelayConfig:
|
||||
properties:
|
||||
auth_token:
|
||||
@@ -4104,7 +4089,6 @@ paths:
|
||||
description: 删除指定认证源及其关联的所有外部帐号绑定记录,警告:删除后相关用户将无法通过该源登录,需要管理员权限
|
||||
parameters:
|
||||
- description: 认证源 ID 或名称
|
||||
format: int64
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
@@ -4144,7 +4128,6 @@ paths:
|
||||
description: 更新指定 ID 的认证源配置。若 client_secret 字段为空,则保留原有密钥不变,需要管理员权限
|
||||
parameters:
|
||||
- description: 认证源 ID 或名称
|
||||
format: int64
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
@@ -4195,7 +4178,6 @@ paths:
|
||||
description: 启用或禁用指定认证源。尝试启用时将验证 Client ID 和 Client Secret 是否已配置,需要管理员权限
|
||||
parameters:
|
||||
- description: 认证源 ID 或名称
|
||||
format: int64
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
@@ -4692,7 +4674,6 @@ paths:
|
||||
description: 根据ID删除消息通道,需要管理员权限
|
||||
parameters:
|
||||
- description: 通道ID
|
||||
format: int64
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
@@ -4715,7 +4696,6 @@ paths:
|
||||
description: 修改消息通道配置,需要管理员权限
|
||||
parameters:
|
||||
- description: 通道ID
|
||||
format: int64
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
@@ -5936,7 +5916,6 @@ paths:
|
||||
name: extension
|
||||
type: string
|
||||
- description: 上传用户 ID
|
||||
format: int64
|
||||
in: query
|
||||
name: user_id
|
||||
type: integer
|
||||
@@ -6528,7 +6507,7 @@ paths:
|
||||
- $ref: '#/definitions/response.Any'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/protocol.PagesDeploymentHashResponse'
|
||||
$ref: '#/definitions/github_com_Rain-kl_Wavelet_pkg_protocol.PagesDeploymentHashResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: 参数错误
|
||||
@@ -6637,24 +6616,6 @@ paths:
|
||||
summary: 获取公共配置
|
||||
tags:
|
||||
- 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:
|
||||
get:
|
||||
description: 分页返回 OpenFlare 访问日志,支持按节点、IP、主机与路径筛选,需要管理员权限
|
||||
@@ -10711,7 +10672,6 @@ paths:
|
||||
description: 解除当前登录用户与指定外部帐号的绑定关系,需要登录
|
||||
parameters:
|
||||
- description: 外部帐号绑定记录 ID
|
||||
format: int64
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
|
||||
@@ -6,6 +6,7 @@ import {useMutation, useQueryClient} from '@tanstack/react-query';
|
||||
import {useState} from 'react';
|
||||
import {
|
||||
Activity,
|
||||
Copy,
|
||||
ExternalLink,
|
||||
FileText,
|
||||
Fingerprint,
|
||||
@@ -38,11 +39,7 @@ import {NodeService} from '@/lib/services/openflare';
|
||||
import {AgentUpdateDialog} from './agent-update-dialog';
|
||||
import {InstallCommand} from './install-command';
|
||||
import {NodeDetailShell} from './node-detail-shell';
|
||||
import {
|
||||
NodeErrorBanner,
|
||||
NodeInfoRow,
|
||||
NodeSectionCard,
|
||||
} from './node-detail-primitives';
|
||||
import {NodeErrorBanner, NodeInfoRow, NodeSectionCard,} from './node-detail-primitives';
|
||||
import {NodeEditorDialog} from './node-editor-dialog';
|
||||
import {NodeObservability} from './node-observability';
|
||||
import {NodeStatusBadge} from './node-status-badge';
|
||||
@@ -278,15 +275,32 @@ export function RelayNodeDetail({ node }: { node: NodeItem }) {
|
||||
</div>
|
||||
|
||||
{webUiUrl ? (
|
||||
<a
|
||||
href={webUiUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center text-sm font-medium text-primary hover:underline"
|
||||
>
|
||||
打开 FRPS WebUI
|
||||
<ExternalLink className="size-3.5 ml-1.5" />
|
||||
</a>
|
||||
<div className="flex flex-wrap items-center gap-3 text-sm">
|
||||
<a
|
||||
href={webUiUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center font-medium text-primary hover:underline"
|
||||
>
|
||||
打开 FRPS WebUI
|
||||
<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>
|
||||
)}
|
||||
@@ -389,4 +403,4 @@ export function RelayNodeDetail({ node }: { node: NodeItem }) {
|
||||
</AlertDialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,13 +50,9 @@ type statusView struct {
|
||||
Version string `json:"version"`
|
||||
StartTime int64 `json:"start_time"`
|
||||
EmailVerification bool `json:"email_verification"`
|
||||
GitHubOAuth bool `json:"github_oauth"`
|
||||
GitHubClientID string `json:"github_client_id"`
|
||||
SystemName string `json:"system_name"`
|
||||
HomePageLink string `json:"home_page_link"`
|
||||
FooterHTML string `json:"footer_html"`
|
||||
WeChatQRCode string `json:"wechat_qrcode"`
|
||||
WeChatLogin bool `json:"wechat_login"`
|
||||
ServerAddress string `json:"server_address"`
|
||||
PasswordRegisterEnabled bool `json:"password_register_enabled"`
|
||||
CapLoginEnabled bool `json:"cap_login_enabled"`
|
||||
@@ -168,13 +164,9 @@ func getStatus(ctx context.Context, baseAPIPath string) (*statusView, error) {
|
||||
Version: buildinfo.Version,
|
||||
StartTime: model.StartTime,
|
||||
EmailVerification: model.EmailVerificationEnabled,
|
||||
GitHubOAuth: model.GitHubOAuthEnabled,
|
||||
GitHubClientID: model.GitHubClientID,
|
||||
SystemName: model.SystemName,
|
||||
HomePageLink: model.HomePageLink,
|
||||
FooterHTML: model.Footer,
|
||||
WeChatQRCode: model.WeChatAccountQRCodeImageURL,
|
||||
WeChatLogin: model.WeChatAuthEnabled,
|
||||
ServerAddress: model.ServerAddress,
|
||||
PasswordRegisterEnabled: model.PasswordRegisterEnabled,
|
||||
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 {
|
||||
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 {
|
||||
return err
|
||||
|
||||
@@ -100,8 +100,7 @@ func TestMigrateUpgradesLegacyDatabaseAndPreservesData(t *testing.T) {
|
||||
`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');`,
|
||||
// Legacy config options
|
||||
`INSERT INTO options (key, value) VALUES ('GitHubClientId', 'Ov23lixMKW');`,
|
||||
`INSERT INTO options (key, value) VALUES ('GitHubClientSecret', 'secret_abc_123');`,
|
||||
`INSERT INTO options (key, value) VALUES ('SystemName', 'CustomOpenFlare');`,
|
||||
// Legacy origin
|
||||
`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');`,
|
||||
@@ -183,20 +182,12 @@ func TestMigrateUpgradesLegacyDatabaseAndPreservesData(t *testing.T) {
|
||||
}
|
||||
|
||||
// Verify options migrated to of_options
|
||||
var githubClientIDVal string
|
||||
if err := sqliteDB.Table("of_options").Where("key = ?", "GitHubClientId").Select("value").Scan(&githubClientIDVal).Error; err != nil {
|
||||
t.Fatalf("query GitHubClientId failed: %v", err)
|
||||
var systemNameVal string
|
||||
if err := sqliteDB.Table("of_options").Where("key = ?", "SystemName").Select("value").Scan(&systemNameVal).Error; err != nil {
|
||||
t.Fatalf("query SystemName failed: %v", err)
|
||||
}
|
||||
if githubClientIDVal != "Ov23lixMKW" {
|
||||
t.Errorf("GitHubClientId value incorrect: got %s, want Ov23lixMKW", githubClientIDVal)
|
||||
}
|
||||
|
||||
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)
|
||||
if systemNameVal != "CustomOpenFlare" {
|
||||
t.Errorf("SystemName value incorrect: got %s, want CustomOpenFlare", systemNameVal)
|
||||
}
|
||||
|
||||
// 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', '');
|
||||
@@ -42,10 +42,6 @@ var (
|
||||
CapLoginEnabled = true
|
||||
PasswordRegisterEnabled = false
|
||||
EmailVerificationEnabled = false
|
||||
GitHubOAuthEnabled = false
|
||||
WeChatAuthEnabled = false
|
||||
GitHubClientID = ""
|
||||
WeChatAccountQRCodeImageURL = ""
|
||||
SMTPPort = 587
|
||||
AgentDiscoveryToken = ""
|
||||
AgentHeartbeatInterval = 10000
|
||||
@@ -159,8 +155,6 @@ func DefaultOpenFlareOptions() map[string]string {
|
||||
"CapLoginEnabled": strconv.FormatBool(CapLoginEnabled),
|
||||
"PasswordRegisterEnabled": strconv.FormatBool(PasswordRegisterEnabled),
|
||||
"EmailVerificationEnabled": strconv.FormatBool(EmailVerificationEnabled),
|
||||
"GitHubOAuthEnabled": strconv.FormatBool(GitHubOAuthEnabled),
|
||||
"WeChatAuthEnabled": strconv.FormatBool(WeChatAuthEnabled),
|
||||
"SMTPServer": "",
|
||||
"SMTPPort": strconv.Itoa(SMTPPort),
|
||||
"SMTPAccount": "",
|
||||
@@ -171,11 +165,6 @@ func DefaultOpenFlareOptions() map[string]string {
|
||||
"HomePageLink": HomePageLink,
|
||||
"SystemName": SystemName,
|
||||
"ServerAddress": "",
|
||||
"GitHubClientId": "",
|
||||
"GitHubClientSecret": "",
|
||||
"WeChatServerAddress": "",
|
||||
"WeChatServerToken": "",
|
||||
"WeChatAccountQRCodeImageURL": "",
|
||||
"AgentDiscoveryToken": "",
|
||||
"AgentHeartbeatInterval": strconv.Itoa(AgentHeartbeatInterval),
|
||||
"AgentWebsocketUpgradeEnabled": strconv.FormatBool(AgentWebsocketUpgradeEnabled),
|
||||
|
||||
@@ -11,27 +11,23 @@ var enabledOptionAppliers = map[string]func(bool){
|
||||
"PasswordLoginEnabled": func(v bool) { PasswordLoginEnabled = v },
|
||||
"CapLoginEnabled": func(v bool) { CapLoginEnabled = 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 },
|
||||
"UptimeKumaEnabled": func(v bool) { UptimeKumaEnabled = v },
|
||||
"DatabaseAutoCleanupEnabled": func(v bool) { DatabaseAutoCleanupEnabled = v },
|
||||
}
|
||||
|
||||
var stringOptionAppliers = map[string]func(string){
|
||||
"ServerAddress": func(v string) { ServerAddress = v },
|
||||
"GitHubClientId": func(v string) { GitHubClientID = v },
|
||||
"Footer": func(v string) { Footer = v },
|
||||
"HomePageLink": func(v string) { HomePageLink = v },
|
||||
"SystemName": func(v string) { SystemName = v },
|
||||
"WeChatAccountQRCodeImageURL": func(v string) { WeChatAccountQRCodeImageURL = v },
|
||||
"AgentDiscoveryToken": func(v string) { AgentDiscoveryToken = v },
|
||||
"GeoIPProvider": func(v string) { GeoIPProvider = v },
|
||||
"UptimeKumaUrl": func(v string) { UptimeKumaURL = v },
|
||||
"UptimeKumaUsername": func(v string) { UptimeKumaUsername = v },
|
||||
optionKeyUptimeKumaPassword: func(v string) { UptimeKumaPassword = v },
|
||||
"UptimeKumaMonitorScope": func(v string) { UptimeKumaMonitorScope = v },
|
||||
"UptimeKumaSelectedSites": func(v string) { UptimeKumaSelectedSites = v },
|
||||
"ServerAddress": func(v string) { ServerAddress = v },
|
||||
"Footer": func(v string) { Footer = v },
|
||||
"HomePageLink": func(v string) { HomePageLink = v },
|
||||
"SystemName": func(v string) { SystemName = v },
|
||||
"AgentDiscoveryToken": func(v string) { AgentDiscoveryToken = v },
|
||||
"GeoIPProvider": func(v string) { GeoIPProvider = v },
|
||||
"UptimeKumaUrl": func(v string) { UptimeKumaURL = v },
|
||||
"UptimeKumaUsername": func(v string) { UptimeKumaUsername = v },
|
||||
optionKeyUptimeKumaPassword: func(v string) { UptimeKumaPassword = v },
|
||||
"UptimeKumaMonitorScope": func(v string) { UptimeKumaMonitorScope = v },
|
||||
"UptimeKumaSelectedSites": func(v string) { UptimeKumaSelectedSites = v },
|
||||
}
|
||||
|
||||
func applyEnabledOptionMirror(key, value string) {
|
||||
|
||||
Reference in New Issue
Block a user