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
4d9b5bcf
authored
Jul 18, 2025
by
RedwindA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加 DisablePing 字段以控制是否发送自定义 Ping
parent
af652718
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
2 deletions
+3
-2
relay/channel/api_request.go
+1
-1
relay/common/relay_info.go
+1
-0
relay/helper/stream_scanner.go
+1
-1
No files found.
relay/channel/api_request.go
View file @
4d9b5bcf
...
@@ -223,7 +223,7 @@ func doRequest(c *gin.Context, req *http.Request, info *common.RelayInfo) (*http
...
@@ -223,7 +223,7 @@ func doRequest(c *gin.Context, req *http.Request, info *common.RelayInfo) (*http
helper
.
SetEventStreamHeaders
(
c
)
helper
.
SetEventStreamHeaders
(
c
)
// 处理流式请求的 ping 保活
// 处理流式请求的 ping 保活
generalSettings
:=
operation_setting
.
GetGeneralSetting
()
generalSettings
:=
operation_setting
.
GetGeneralSetting
()
if
generalSettings
.
PingIntervalEnabled
{
if
generalSettings
.
PingIntervalEnabled
&&
!
info
.
DisablePing
{
pingInterval
:=
time
.
Duration
(
generalSettings
.
PingIntervalSeconds
)
*
time
.
Second
pingInterval
:=
time
.
Duration
(
generalSettings
.
PingIntervalSeconds
)
*
time
.
Second
stopPinger
=
startPingKeepAlive
(
c
,
pingInterval
)
stopPinger
=
startPingKeepAlive
(
c
,
pingInterval
)
// 使用defer确保在任何情况下都能停止ping goroutine
// 使用defer确保在任何情况下都能停止ping goroutine
...
...
relay/common/relay_info.go
View file @
4d9b5bcf
...
@@ -88,6 +88,7 @@ type RelayInfo struct {
...
@@ -88,6 +88,7 @@ type RelayInfo struct {
BaseUrl
string
BaseUrl
string
SupportStreamOptions
bool
SupportStreamOptions
bool
ShouldIncludeUsage
bool
ShouldIncludeUsage
bool
DisablePing
bool
// 是否禁止向下游发送自定义 Ping
IsModelMapped
bool
IsModelMapped
bool
ClientWs
*
websocket
.
Conn
ClientWs
*
websocket
.
Conn
TargetWs
*
websocket
.
Conn
TargetWs
*
websocket
.
Conn
...
...
relay/helper/stream_scanner.go
View file @
4d9b5bcf
...
@@ -54,7 +54,7 @@ func StreamScannerHandler(c *gin.Context, resp *http.Response, info *relaycommon
...
@@ -54,7 +54,7 @@ func StreamScannerHandler(c *gin.Context, resp *http.Response, info *relaycommon
)
)
generalSettings
:=
operation_setting
.
GetGeneralSetting
()
generalSettings
:=
operation_setting
.
GetGeneralSetting
()
pingEnabled
:=
generalSettings
.
PingIntervalEnabled
pingEnabled
:=
generalSettings
.
PingIntervalEnabled
&&
!
info
.
DisablePing
pingInterval
:=
time
.
Duration
(
generalSettings
.
PingIntervalSeconds
)
*
time
.
Second
pingInterval
:=
time
.
Duration
(
generalSettings
.
PingIntervalSeconds
)
*
time
.
Second
if
pingInterval
<=
0
{
if
pingInterval
<=
0
{
pingInterval
=
DefaultPingInterval
pingInterval
=
DefaultPingInterval
...
...
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