Skip to content

Commit 0fab993

Browse files
committed
chore: collect assets for discosrv and relaysrv as well
1 parent c8b0b57 commit 0fab993

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

main.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/json"
88
"io/fs"
99
"log/slog"
10+
"maps"
1011
"net/http"
1112
"net/http/httputil"
1213
"net/url"
@@ -48,7 +49,11 @@ func main() {
4849

4950
// The GitHub redirector serves assets from GitHub releases
5051
github := &githubRedirector{
51-
releasesURL: "https://api.github.com/repos/syncthing/syncthing/releases?per_page=25",
52+
releasesURLs: []string{
53+
"https://api.github.com/repos/syncthing/syncthing/releases?per_page=15",
54+
"https://api.github.com/repos/syncthing/discosrv/releases?per_page=5",
55+
"https://api.github.com/repos/syncthing/relaysrv/releases?per_page=5",
56+
},
5257
refreshInterval: 5 * time.Minute,
5358
next: proxy,
5459
}
@@ -107,7 +112,7 @@ func newCachingProxy(next string, cacheTime time.Duration) (http.Handler, error)
107112
}
108113

109114
type githubRedirector struct {
110-
releasesURL string
115+
releasesURLs []string
111116
refreshInterval time.Duration
112117
next http.Handler
113118

@@ -121,12 +126,16 @@ func (r *githubRedirector) Serve(ctx context.Context) error {
121126
for {
122127
select {
123128
case <-timer.C:
124-
assets, err := r.fetchGithubReleaseAssets(ctx, r.releasesURL)
125-
if err != nil {
126-
return err
129+
newAssets := make(map[string]string)
130+
for _, url := range r.releasesURLs {
131+
assets, err := r.fetchGithubReleaseAssets(ctx, url)
132+
if err != nil {
133+
return err
134+
}
135+
maps.Copy(newAssets, assets)
127136
}
128137
r.mut.Lock()
129-
r.assets = assets
138+
r.assets = newAssets
130139
r.mut.Unlock()
131140
timer.Reset(r.refreshInterval)
132141
case <-ctx.Done():

0 commit comments

Comments
 (0)