Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
97f98a0c
authored
May 09, 2025
by
Calcium-Ion
Committed by
GitHub
May 09, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1046 from QuantumNous/workerHttpRequest
feat: add option to allow worker HTTP image requests
parents
86d1e416
285c4a7e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
5 deletions
+28
-5
model/option.go
+3
-0
service/cf_worker.go
+1
-1
setting/system_setting.go
+1
-0
web/src/components/SystemSetting.js
+23
-4
No files found.
model/option.go
View file @
97f98a0c
...
...
@@ -67,6 +67,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"ServerAddress"
]
=
""
common
.
OptionMap
[
"WorkerUrl"
]
=
setting
.
WorkerUrl
common
.
OptionMap
[
"WorkerValidKey"
]
=
setting
.
WorkerValidKey
common
.
OptionMap
[
"WorkerAllowHttpImageRequestEnabled"
]
=
strconv
.
FormatBool
(
setting
.
WorkerAllowHttpImageRequestEnabled
)
common
.
OptionMap
[
"PayAddress"
]
=
""
common
.
OptionMap
[
"CustomCallbackAddress"
]
=
""
common
.
OptionMap
[
"EpayId"
]
=
""
...
...
@@ -257,6 +258,8 @@ func updateOptionMap(key string, value string) (err error) {
setting
.
StopOnSensitiveEnabled
=
boolValue
case
"SMTPSSLEnabled"
:
common
.
SMTPSSLEnabled
=
boolValue
case
"WorkerAllowHttpImageRequestEnabled"
:
setting
.
WorkerAllowHttpImageRequestEnabled
=
boolValue
}
}
switch
key
{
...
...
service/cf_worker.go
View file @
97f98a0c
...
...
@@ -24,7 +24,7 @@ func DoWorkerRequest(req *WorkerRequest) (*http.Response, error) {
if
!
setting
.
EnableWorker
()
{
return
nil
,
fmt
.
Errorf
(
"worker not enabled"
)
}
if
!
strings
.
HasPrefix
(
req
.
URL
,
"https"
)
{
if
!
s
etting
.
WorkerAllowHttpImageRequestEnabled
&&
!
s
trings
.
HasPrefix
(
req
.
URL
,
"https"
)
{
return
nil
,
fmt
.
Errorf
(
"only support https url"
)
}
...
...
setting/system_setting.go
View file @
97f98a0c
...
...
@@ -3,6 +3,7 @@ package setting
var
ServerAddress
=
"http://localhost:3000"
var
WorkerUrl
=
""
var
WorkerValidKey
=
""
var
WorkerAllowHttpImageRequestEnabled
=
false
func
EnableWorker
()
bool
{
return
WorkerUrl
!=
""
...
...
web/src/components/SystemSetting.js
View file @
97f98a0c
...
...
@@ -19,7 +19,7 @@ import {
verifyJSON
,
}
from
'../helpers/utils'
;
import
{
API
}
from
'../helpers/api'
;
import
axios
from
"axios"
;
import
axios
from
'axios'
;
const
SystemSetting
=
()
=>
{
let
[
inputs
,
setInputs
]
=
useState
({
...
...
@@ -45,6 +45,7 @@ const SystemSetting = () => {
ServerAddress
:
''
,
WorkerUrl
:
''
,
WorkerValidKey
:
''
,
WorkerAllowHttpImageRequestEnabled
:
''
,
EpayId
:
''
,
EpayKey
:
''
,
Price
:
7.3
,
...
...
@@ -111,6 +112,7 @@ const SystemSetting = () => {
case
'SMTPSSLEnabled'
:
case
'LinuxDOOAuthEnabled'
:
case
'oidc.enabled'
:
case
'WorkerAllowHttpImageRequestEnabled'
:
item
.
value
=
item
.
value
===
'true'
;
break
;
case
'Price'
:
...
...
@@ -206,7 +208,11 @@ const SystemSetting = () => {
let
WorkerUrl
=
removeTrailingSlash
(
inputs
.
WorkerUrl
);
const
options
=
[
{
key
:
'WorkerUrl'
,
value
:
WorkerUrl
},
]
{
key
:
'WorkerAllowHttpImageRequestEnabled'
,
value
:
inputs
.
WorkerAllowHttpImageRequestEnabled
?
'true'
:
'false'
,
},
];
if
(
inputs
.
WorkerValidKey
!==
''
||
WorkerUrl
===
''
)
{
options
.
push
({
key
:
'WorkerValidKey'
,
value
:
inputs
.
WorkerValidKey
});
}
...
...
@@ -302,7 +308,8 @@ const SystemSetting = () => {
const
domain
=
emailToAdd
.
trim
();
// 验证域名格式
const
domainRegex
=
/^
([
a-zA-Z0-9
]([
a-zA-Z0-9
\-]{0,61}[
a-zA-Z0-9
])?\.)
+
[
a-zA-Z
]{2,}
$/
;
const
domainRegex
=
/^
([
a-zA-Z0-9
]([
a-zA-Z0-9
\-]{0,61}[
a-zA-Z0-9
])?\.)
+
[
a-zA-Z
]{2,}
$/
;
if
(
!
domainRegex
.
test
(
domain
))
{
showError
(
'邮箱域名格式不正确,请输入有效的域名,如 gmail.com'
);
return
;
...
...
@@ -577,6 +584,12 @@ const SystemSetting = () => {
/>
<
/Col
>
<
/Row
>
<
Form
.
Checkbox
field
=
'WorkerAllowHttpImageRequestEnabled'
noLabel
>
允许
HTTP
协议图片请求(适用于自部署代理)
<
/Form.Checkbox
>
<
Button
onClick
=
{
submitWorker
}
>
更新
Worker
设置
<
/Button
>
<
/Form.Section
>
<
/Card
>
...
...
@@ -799,7 +812,13 @@ const SystemSetting = () => {
onChange
=
{(
value
)
=>
setEmailToAdd
(
value
)}
style
=
{{
marginTop
:
16
}}
suffix
=
{
<
Button
theme
=
"solid"
type
=
"primary"
onClick
=
{
handleAddEmail
}
>
添加
<
/Button
>
<
Button
theme
=
'solid'
type
=
'primary'
onClick
=
{
handleAddEmail
}
>
添加
<
/Button
>
}
onEnterPress
=
{
handleAddEmail
}
/
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment