mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
Allow configuration of releases URL
This commit is contained in:
parent
46364a38c6
commit
9dae87c80c
@ -773,7 +773,7 @@ func (s *apiSvc) getSystemUpgrade(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, upgrade.ErrUpgradeUnsupported.Error(), 500)
|
http.Error(w, upgrade.ErrUpgradeUnsupported.Error(), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rel, err := upgrade.LatestRelease(Version)
|
rel, err := upgrade.LatestRelease(cfg.Options().ReleasesURL, Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
@ -816,7 +816,7 @@ func (s *apiSvc) getLang(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *apiSvc) postSystemUpgrade(w http.ResponseWriter, r *http.Request) {
|
func (s *apiSvc) postSystemUpgrade(w http.ResponseWriter, r *http.Request) {
|
||||||
rel, err := upgrade.LatestRelease(Version)
|
rel, err := upgrade.LatestRelease(cfg.Options().ReleasesURL, Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Warnln("getting latest release:", err)
|
l.Warnln("getting latest release:", err)
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
@ -347,7 +347,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if doUpgrade || doUpgradeCheck {
|
if doUpgrade || doUpgradeCheck {
|
||||||
rel, err := upgrade.LatestRelease(Version)
|
rel, err := upgrade.LatestRelease(cfg.Options().ReleasesURL, Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Fatalln("Upgrade:", err) // exits 1
|
l.Fatalln("Upgrade:", err) // exits 1
|
||||||
}
|
}
|
||||||
@ -1060,7 +1060,7 @@ func autoUpgrade() {
|
|||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
}
|
}
|
||||||
|
|
||||||
rel, err := upgrade.LatestRelease(Version)
|
rel, err := upgrade.LatestRelease(cfg.Options().ReleasesURL, Version)
|
||||||
if err == upgrade.ErrUpgradeUnsupported {
|
if err == upgrade.ErrUpgradeUnsupported {
|
||||||
events.Default.Unsubscribe(sub)
|
events.Default.Unsubscribe(sub)
|
||||||
return
|
return
|
||||||
|
@ -248,6 +248,7 @@ type OptionsConfiguration struct {
|
|||||||
PingTimeoutS int `xml:"pingTimeoutS" json:"pingTimeoutS" default:"30"`
|
PingTimeoutS int `xml:"pingTimeoutS" json:"pingTimeoutS" default:"30"`
|
||||||
PingIdleTimeS int `xml:"pingIdleTimeS" json:"pingIdleTimeS" default:"60"`
|
PingIdleTimeS int `xml:"pingIdleTimeS" json:"pingIdleTimeS" default:"60"`
|
||||||
MinHomeDiskFreePct float64 `xml:"minHomeDiskFreePct" json:"minHomeDiskFreePct" default:"1"`
|
MinHomeDiskFreePct float64 `xml:"minHomeDiskFreePct" json:"minHomeDiskFreePct" default:"1"`
|
||||||
|
ReleasesURL string `xml:"releasesURL" json:"releasesURL" default:"https://api.github.com/repos/syncthing/syncthing/releases?per_page=30"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (orig OptionsConfiguration) Copy() OptionsConfiguration {
|
func (orig OptionsConfiguration) Copy() OptionsConfiguration {
|
||||||
|
@ -63,6 +63,7 @@ func TestDefaultValues(t *testing.T) {
|
|||||||
URURL: "https://data.syncthing.net/newdata",
|
URURL: "https://data.syncthing.net/newdata",
|
||||||
URInitialDelayS: 1800,
|
URInitialDelayS: 1800,
|
||||||
URPostInsecurely: false,
|
URPostInsecurely: false,
|
||||||
|
ReleasesURL: "https://api.github.com/repos/syncthing/syncthing/releases?per_page=30",
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := New(device1)
|
cfg := New(device1)
|
||||||
@ -181,6 +182,7 @@ func TestOverriddenValues(t *testing.T) {
|
|||||||
URURL: "https://localhost/newdata",
|
URURL: "https://localhost/newdata",
|
||||||
URInitialDelayS: 800,
|
URInitialDelayS: 800,
|
||||||
URPostInsecurely: true,
|
URPostInsecurely: true,
|
||||||
|
ReleasesURL: "https://localhost/releases",
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := Load("testdata/overridenvalues.xml", device1)
|
cfg, err := Load("testdata/overridenvalues.xml", device1)
|
||||||
|
1
lib/config/testdata/overridenvalues.xml
vendored
1
lib/config/testdata/overridenvalues.xml
vendored
@ -35,5 +35,6 @@
|
|||||||
<urURL>https://localhost/newdata</urURL>
|
<urURL>https://localhost/newdata</urURL>
|
||||||
<urInitialDelayS>800</urInitialDelayS>
|
<urInitialDelayS>800</urInitialDelayS>
|
||||||
<urPostInsecurely>true</urPostInsecurely>
|
<urPostInsecurely>true</urPostInsecurely>
|
||||||
|
<releasesURL>https://localhost/releases</releasesURL>
|
||||||
</options>
|
</options>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -46,8 +46,8 @@ var insecureHTTP = &http.Client{
|
|||||||
|
|
||||||
// LatestGithubReleases returns the latest releases, including prereleases or
|
// LatestGithubReleases returns the latest releases, including prereleases or
|
||||||
// not depending on the argument
|
// not depending on the argument
|
||||||
func LatestGithubReleases(version string) ([]Release, error) {
|
func LatestGithubReleases(releasesURL, version string) ([]Release, error) {
|
||||||
resp, err := insecureHTTP.Get("https://api.github.com/repos/syncthing/syncthing/releases?per_page=30")
|
resp, err := insecureHTTP.Get(releasesURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -74,8 +74,8 @@ func (s SortByRelease) Less(i, j int) bool {
|
|||||||
return CompareVersions(s[i].Tag, s[j].Tag) > 0
|
return CompareVersions(s[i].Tag, s[j].Tag) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func LatestRelease(version string) (Release, error) {
|
func LatestRelease(releasesURL, version string) (Release, error) {
|
||||||
rels, _ := LatestGithubReleases(version)
|
rels, _ := LatestGithubReleases(releasesURL, version)
|
||||||
return SelectLatestRelease(version, rels)
|
return SelectLatestRelease(version, rels)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user