feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/QuantumNous/new-api/common"
|
||||
"github.com/QuantumNous/new-api/logger"
|
||||
"github.com/QuantumNous/new-api/relaykit/dto"
|
||||
)
|
||||
@@ -13,8 +14,9 @@ import (
|
||||
// HTTPTransportPolicy is the runtime-normalized outbound HTTP transport policy
|
||||
// for a channel. Unknown or out-of-range stored values are clamped safely.
|
||||
type HTTPTransportPolicy struct {
|
||||
Protocol string // dto.HTTPProtocolAuto or dto.HTTPProtocolHTTP1
|
||||
Shards int // 1..dto.MaxHTTP2ConnectionShards
|
||||
Protocol string // dto.HTTPProtocolAuto or dto.HTTPProtocolHTTP1
|
||||
Shards int // 1..dto.MaxHTTP2ConnectionShards
|
||||
TLSInsecureSkipVerify bool
|
||||
}
|
||||
|
||||
var httpTransportPolicyWarnings sync.Map
|
||||
@@ -30,6 +32,7 @@ func defaultHTTPTransportPolicy() HTTPTransportPolicy {
|
||||
// Invalid stored values never panic; they clamp to defaults and warn once per bad value.
|
||||
func NormalizeHTTPTransportPolicy(settings dto.ChannelSettings) HTTPTransportPolicy {
|
||||
policy := defaultHTTPTransportPolicy()
|
||||
policy.TLSInsecureSkipVerify = settings.TLSInsecureSkipVerify
|
||||
|
||||
protocol := strings.ToLower(strings.TrimSpace(settings.HTTPProtocol))
|
||||
switch protocol {
|
||||
@@ -78,12 +81,12 @@ func warnHTTPTransportPolicyOnce(field, value string) {
|
||||
}
|
||||
logger.LogWarn(
|
||||
context.Background(),
|
||||
fmt.Sprintf("invalid channel http transport setting clamped: %s=%q", field, value),
|
||||
common.LogText("invalid channel http transport setting clamped: %s=%q", field, value),
|
||||
)
|
||||
}
|
||||
|
||||
func (p HTTPTransportPolicy) cacheKeyPart() string {
|
||||
return fmt.Sprintf("%s|%d", p.Protocol, p.Shards)
|
||||
return fmt.Sprintf("%s|%d|%t", p.Protocol, p.Shards, p.TLSInsecureSkipVerify)
|
||||
}
|
||||
|
||||
func (p HTTPTransportPolicy) String() string {
|
||||
|
||||
Reference in new issue
Block a user