feat: sync httpdns sdk/platform updates without large binaries

This commit is contained in:
robin
2026-03-04 17:59:14 +08:00
parent 853897a6f8
commit 532891fad0
700 changed files with 6096 additions and 2712 deletions

View File

@@ -37,6 +37,8 @@ type SnapshotManager struct {
locker sync.RWMutex
snapshot *LoadedSnapshot
timezone string
}
func NewSnapshotManager(quitCh <-chan struct{}) *SnapshotManager {
@@ -144,7 +146,7 @@ func (m *SnapshotManager) RefreshNow(reason string) error {
}
snapshot := &LoadedSnapshot{
LoadedAt: time.Now().Unix(),
LoadedAt: time.Now().UnixNano(),
NodeID: nodeResp.GetNode().GetId(),
ClusterID: nodeResp.GetNode().GetClusterId(),
Clusters: clusters,
@@ -156,5 +158,36 @@ func (m *SnapshotManager) RefreshNow(reason string) error {
m.locker.Unlock()
reportRuntimeLog("info", "config", "snapshot", "snapshot refreshed: "+reason, fmt.Sprintf("snapshot-%d", time.Now().UnixNano()))
// timezone sync - prefer current node's cluster timezone
var timeZone string
if snapshot.ClusterID > 0 {
if cluster := clusters[snapshot.ClusterID]; cluster != nil && len(cluster.GetTimeZone()) > 0 {
timeZone = cluster.GetTimeZone()
}
}
// fallback to any non-empty cluster timezone for compatibility
if len(timeZone) == 0 {
for _, cluster := range clusters {
if cluster != nil && len(cluster.GetTimeZone()) > 0 {
timeZone = cluster.GetTimeZone()
break
}
}
}
if len(timeZone) == 0 {
timeZone = "Asia/Shanghai"
}
if m.timezone != timeZone {
location, err := time.LoadLocation(timeZone)
if err != nil {
log.Println("[HTTPDNS_NODE][TIMEZONE]change time zone failed:", err.Error())
} else {
log.Println("[HTTPDNS_NODE][TIMEZONE]change time zone to '" + timeZone + "'")
time.Local = location
m.timezone = timeZone
}
}
return nil
}