feat: multi-feature update

This commit is contained in:
chaos
2026-06-15 06:16:16 +08:00
parent 6f415428d3
commit 04d30f9dd1
58 changed files with 4610 additions and 419 deletions
+5
View File
@@ -173,6 +173,11 @@ var RelayTimeout int // unit is second
var RelayIdleConnTimeout int // unit is second
var RelayMaxIdleConns int
var RelayMaxIdleConnsPerHost int
var RelayResponseHeaderTimeout int // unit is second
var RelayTLSHandshakeTimeout int // unit is second
var RelayExpectContinueTimeout int // unit is second
var RelayForceIPv4 bool
var RelayDisableHTTP2 bool
var GeminiSafetySetting string
+12 -1
View File
@@ -5,6 +5,7 @@ import (
"io/fs"
"net/http"
"os"
"strings"
"github.com/gin-contrib/static"
)
@@ -16,7 +17,17 @@ type embedFileSystem struct {
}
func (e *embedFileSystem) Exists(prefix string, path string) bool {
_, err := e.Open(path)
// gin-contrib/static passes the raw URL path (e.g. "/image-gen/assets/x.js")
// together with the URL prefix we registered (e.g. "/image-gen"). The
// underlying fs.Sub FS only knows about the sub-tree (no prefix), so we
// must strip the prefix before asking it whether the file exists. An
// empty prefix means "served at /" — nothing to strip.
p := strings.TrimPrefix(path, prefix)
if p == path {
// prefix didn't match — definitely not in this FS
return false
}
_, err := e.Open(p)
if err != nil {
return false
}
+5
View File
@@ -105,6 +105,11 @@ func InitEnv() {
RelayIdleConnTimeout = GetEnvOrDefault("RELAY_IDLE_CONN_TIMEOUT", 90)
RelayMaxIdleConns = GetEnvOrDefault("RELAY_MAX_IDLE_CONNS", 500)
RelayMaxIdleConnsPerHost = GetEnvOrDefault("RELAY_MAX_IDLE_CONNS_PER_HOST", 100)
RelayResponseHeaderTimeout = GetEnvOrDefault("RELAY_RESPONSE_HEADER_TIMEOUT", 60)
RelayTLSHandshakeTimeout = GetEnvOrDefault("RELAY_TLS_HANDSHAKE_TIMEOUT", 10)
RelayExpectContinueTimeout = GetEnvOrDefault("RELAY_EXPECT_CONTINUE_TIMEOUT", 1)
RelayForceIPv4 = GetEnvOrDefaultBool("RELAY_FORCE_IPV4", false)
RelayDisableHTTP2 = GetEnvOrDefaultBool("RELAY_DISABLE_HTTP2", false)
// Initialize string variables with GetEnvOrDefaultString
GeminiSafetySetting = GetEnvOrDefaultString("GEMINI_SAFETY_SETTING", "BLOCK_NONE")