From 19db661c1c45a00c0d5dec20afdabc623b0d7cad Mon Sep 17 00:00:00 2001 From: "lalitdeore12@gmail.com" Date: Fri, 9 Jan 2026 17:20:54 +0530 Subject: [PATCH 1/2] add multi region support for cloud sync --- backend/go-app/main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index b889cd96..271a545d 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -79,6 +79,7 @@ type retStruct struct { Reason string `json:"reason"` Subscriptions []shuffle.PaymentSubscription `json:"subscriptions"` Licensed bool `json:"licensed"` + CloudSyncUrl string `json:"cloud_sync_url,omitempty"` } type Contact struct { @@ -3906,6 +3907,7 @@ func remoteOrgJobController(org shuffle.Org, body []byte) error { SyncFeatures shuffle.SyncFeatures `json:"sync_features"` Subscriptions []shuffle.PaymentSubscription `json:"subscriptions"` Licensed bool `json:"licensed"` + CloudSyncUrl string `json:"cloud_sync_url,omitempty"` } responseData := retStruct{} @@ -4083,6 +4085,19 @@ func remoteOrgJobHandler(org shuffle.Org, interval int) error { backupJobData = []byte{} } + cloudSyncRegionUrlCacheKey := fmt.Sprintf("org_cloudsync_region_url_%s", org.Id) + cloudSyncRegionUrlCached, err := shuffle.GetCache(ctx, cloudSyncRegionUrlCacheKey) + if err == nil { + if cachedBytes, ok := cloudSyncRegionUrlCached.([]byte); ok && len(cachedBytes) > 0 { + syncUrl = string(cachedBytes) + log.Printf("[DEBUG] Using cached cloud sync region url for org %s: %s", org.Id, syncUrl) + } + } + + if len(syncUrl) == 0 || !strings.HasPrefix(syncUrl, "http") { + syncUrl = "https://shuffler.io" + } + syncUrl := fmt.Sprintf("%s/api/v1/cloud/sync", syncUrl) client := shuffle.GetExternalClient(syncUrl) req, err := http.NewRequest( @@ -5075,6 +5090,11 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) { shuffle.SetCache(ctx, licenseCacheKey, licensedBytes, 1800) } + if len(responseData.CloudSyncUrl) > 0 { + cloudSyncRegionUrlCacheKey := fmt.Sprintf("org_cloudsync_region_url_%s", org.Id) + shuffle.SetCache(ctx, cloudSyncRegionUrlCacheKey, []byte(responseData.CloudSyncUrl), 1800) + } + org.SyncConfig = shuffle.SyncConfig{ Apikey: responseData.SessionKey, Interval: responseData.IntervalSeconds, From ba3d6c01b2cfb81e3d81917ad08c0432bf98c731 Mon Sep 17 00:00:00 2001 From: "lalitdeore12@gmail.com" Date: Wed, 14 Jan 2026 19:41:06 +0530 Subject: [PATCH 2/2] add validation for sync url --- backend/go-app/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 271a545d..2235ec0a 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4942,6 +4942,12 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) { //log.Printf("Apidata: %s", tmpData.Apikey) // FIXME: Path + + // just in case setup/stop URL is overwritten by region url + if syncUrl != "https://shuffler.io" || syncUrl != "http://localhost:5002" { + syncUrl = "https://shuffler.io" + } + apiPath := "/api/v1/cloud/sync/setup" if tmpData.Disable { if !org.CloudSync {