增加 DisablePing 字段以控制是否发送自定义 Ping
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user