merge(wavelet): sync upstream changes

This commit is contained in:
ryan
2026-09-03 09:29:28 +08:00
220 changed files with 12924 additions and 15487 deletions
@@ -12,6 +12,8 @@ import (
"time"
"github.com/gin-gonic/gin"
"Wavelet/pkg/util"
)
const (
@@ -64,7 +66,7 @@ func ServeAgent(c *gin.Context, nodeID string, onStatus AgentStatusHandler) {
slog.Debug("agent ws connected", "node_id", nodeID, "remote", client.remoteAddr)
go client.writePump()
util.Go(client.writePump)
client.readPump()
}
@@ -8,6 +8,8 @@ import (
"sync"
"github.com/gin-gonic/gin"
"Wavelet/pkg/util"
)
const (
@@ -51,7 +53,7 @@ func ServeFlared(c *gin.Context, nodeID string) {
slog.Debug("flared ws connected", "node_id", nodeID, "remote", c.Request.RemoteAddr)
go client.writePump()
util.Go(client.writePump)
client.readPump()
}
@@ -8,6 +8,8 @@ import (
"sync"
"github.com/gin-gonic/gin"
"Wavelet/pkg/util"
)
// RelayWSConnectedLastSeenValue is the sentinel last_seen_at value when relay WS is connected.
@@ -45,7 +47,7 @@ func ServeRelay(c *gin.Context, nodeID string) {
slog.Debug("relay ws connected", "node_id", nodeID, "remote", c.Request.RemoteAddr)
go client.writePump()
util.Go(client.writePump)
client.readPump()
}
@@ -16,6 +16,8 @@ import (
"strings"
"sync"
"time"
"Wavelet/pkg/util"
)
const emitAckTimeout = 10 * time.Second
@@ -137,7 +139,7 @@ func (c *SocketIOClient) Connect() error {
_ = respConnect.Body.Close()
slog.Debug("Namespace connected successfully to Uptime Kuma", "sid", c.sid)
go c.pollLoop()
util.Go(c.pollLoop)
return nil
}
@@ -12,10 +12,10 @@ import (
"mime/multipart"
"strings"
"Wavelet/openflare/plugins/server/kernel/repository"
"Wavelet/openflare/plugins/server/kernel/model"
"Wavelet/openflare/plugins/server/kernel/repository"
"Wavelet/openflare/plugins/server/kernel/task"
"Wavelet/pkg/util"
)
// CertificateInput TLS 证书创建/更新请求。
@@ -202,10 +202,10 @@ func ApplyCertificate(ctx context.Context, input ApplyInput) (*model.TLSCertific
returned := sanitizeCertificateForResponse(cert)
obtainFn := obtainTLSCertificate // 捕获当前实现,避免 goroutine 内读可变包变量(测试热替换)
go func(c *model.TLSCertificate) {
util.Go(func() {
asyncCtx := context.WithoutCancel(ctx)
_ = obtainFn(asyncCtx, c)
}(cert)
_ = obtainFn(asyncCtx, cert)
})
return returned, nil
}
@@ -233,10 +233,10 @@ func UpdateACMECertificate(ctx context.Context, id uint, input ApplyInput) (*mod
returned := sanitizeCertificateForResponse(cert)
obtainFn := obtainTLSCertificate // 捕获当前实现,避免 goroutine 内读可变包变量(测试热替换)
go func(c *model.TLSCertificate) {
util.Go(func() {
asyncCtx := context.WithoutCancel(ctx)
_ = obtainFn(asyncCtx, c)
}(cert)
_ = obtainFn(asyncCtx, cert)
})
return returned, nil
}
@@ -266,12 +266,12 @@ func ConvertCertificateToACME(ctx context.Context, id uint, input ApplyInput) (*
}
obtainFn := obtainTLSCertificate // 捕获当前实现,避免 goroutine 内读可变包变量(测试热替换)
go func(c *model.TLSCertificate) {
util.Go(func() {
asyncCtx := context.WithoutCancel(ctx)
if err := obtainFn(asyncCtx, c); err != nil {
if err := obtainFn(asyncCtx, cert); err != nil {
return
}
latest, err := repository.GetTLSCertificateByID(asyncCtx, c.ID)
latest, err := repository.GetTLSCertificateByID(asyncCtx, cert.ID)
if err != nil {
return
}
@@ -279,7 +279,7 @@ func ConvertCertificateToACME(ctx context.Context, id uint, input ApplyInput) (*
latest.ApplyStatus = tlsApplyStatusReady
latest.ApplyMessage = ""
_ = repository.SaveTLSCertificate(asyncCtx, latest)
}(cert)
})
return sanitizeCertificateForResponse(cert), nil
}
@@ -22,7 +22,7 @@ func New(_ *core.Context) *Provider {
}
// PublicConfig returns visibility=1 keys as map[string]string.
func (p *Provider) PublicConfig(ctx context.Context) (any, error) {
func (p *Provider) PublicConfig(ctx context.Context) (map[string]string, error) {
configs, err := repository.ListVisibleSystemConfigs(ctx)
if err != nil {
return nil, err
@@ -23,11 +23,7 @@ func TestPublicConfigSeesSaveOrUpdateThroughAdminCache(t *testing.T) {
if err != nil {
t.Fatalf("PublicConfig() warm error = %v", err)
}
firstMap, ok := first.(map[string]string)
if !ok {
t.Fatalf("PublicConfig() = %T, want map[string]string", first)
}
if got := firstMap[model.ConfigKeySiteName]; got != "OpenFlare" {
if got := first[model.ConfigKeySiteName]; got != "OpenFlare" {
t.Fatalf("PublicConfig()[%q] = %q, want %q", model.ConfigKeySiteName, got, "OpenFlare")
}
@@ -47,14 +43,10 @@ func TestPublicConfigSeesSaveOrUpdateThroughAdminCache(t *testing.T) {
if err != nil {
t.Fatalf("PublicConfig() after save error = %v", err)
}
secondMap, ok := second.(map[string]string)
if !ok {
t.Fatalf("PublicConfig() after save = %T, want map[string]string", second)
}
if got := secondMap[model.ConfigKeySiteName]; got == "OpenFlare" {
if got := second[model.ConfigKeySiteName]; got == "OpenFlare" {
t.Fatalf("PublicConfig() after save [%q] stayed stale at %q", model.ConfigKeySiteName, got)
}
if got := secondMap[model.ConfigKeySiteName]; got != "Updated" {
if got := second[model.ConfigKeySiteName]; got != "Updated" {
t.Fatalf("PublicConfig() after save [%q] = %q, want %q", model.ConfigKeySiteName, got, "Updated")
}
}