diff --git a/internal/home/config.go b/internal/home/config.go index 6c8381ab..afe96812 100644 --- a/internal/home/config.go +++ b/internal/home/config.go @@ -179,7 +179,7 @@ func initConfig() { config.DHCP.Conf4.ICMPTimeout = 1000 config.DHCP.Conf6.LeaseDuration = 86400 - if ch := version.Channel(); ch == "edge" || ch == "development" { + if ch := version.Channel(); ch == version.ChannelEdge || ch == version.ChannelDevelopment { config.BetaBindPort = 3001 } } diff --git a/internal/home/home.go b/internal/home/home.go index 55d6c20d..4ece8f85 100644 --- a/internal/home/home.go +++ b/internal/home/home.go @@ -126,7 +126,8 @@ func Main() { func setupContext(args options) { Context.runningAsService = args.runningAsService - Context.disableUpdate = args.disableUpdate + Context.disableUpdate = args.disableUpdate || + version.Channel() == version.ChannelDevelopment Context.firstRun = detectFirstRun() if Context.firstRun { diff --git a/internal/updater/updater_test.go b/internal/updater/updater_test.go index adb12c2d..a8923ee2 100644 --- a/internal/updater/updater_test.go +++ b/internal/updater/updater_test.go @@ -12,6 +12,7 @@ import ( "testing" "github.com/AdguardTeam/AdGuardHome/internal/testutil" + "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/stretchr/testify/assert" ) @@ -72,7 +73,7 @@ func TestUpdateGetVersion(t *testing.T) { u := NewUpdater(&Config{ Client: &http.Client{}, Version: "v0.103.0-beta.1", - Channel: "beta", + Channel: version.ChannelBeta, GOARCH: "arm", GOOS: "linux", }) @@ -80,7 +81,7 @@ func TestUpdateGetVersion(t *testing.T) { fakeURL := &url.URL{ Scheme: "http", Host: net.JoinHostPort("127.0.0.1", lport), - Path: path.Join("adguardhome", "beta", "version.json"), + Path: path.Join("adguardhome", version.ChannelBeta, "version.json"), } u.versionCheckURL = fakeURL.String() @@ -258,7 +259,7 @@ func TestUpdater_VersionInto_ARM(t *testing.T) { u := NewUpdater(&Config{ Client: &http.Client{}, Version: "v0.103.0-beta.1", - Channel: "beta", + Channel: version.ChannelBeta, GOARCH: "arm", GOOS: "linux", GOARM: "7", @@ -267,7 +268,7 @@ func TestUpdater_VersionInto_ARM(t *testing.T) { fakeURL := &url.URL{ Scheme: "http", Host: net.JoinHostPort("127.0.0.1", lport), - Path: path.Join("adguardhome", "beta", "version.json"), + Path: path.Join("adguardhome", version.ChannelBeta, "version.json"), } u.versionCheckURL = fakeURL.String() @@ -297,7 +298,7 @@ func TestUpdater_VersionInto_MIPS(t *testing.T) { u := NewUpdater(&Config{ Client: &http.Client{}, Version: "v0.103.0-beta.1", - Channel: "beta", + Channel: version.ChannelBeta, GOARCH: "mips", GOOS: "linux", GOMIPS: "softfloat", @@ -306,7 +307,7 @@ func TestUpdater_VersionInto_MIPS(t *testing.T) { fakeURL := &url.URL{ Scheme: "http", Host: net.JoinHostPort("127.0.0.1", lport), - Path: path.Join("adguardhome", "beta", "version.json"), + Path: path.Join("adguardhome", version.ChannelBeta, "version.json"), } u.versionCheckURL = fakeURL.String() diff --git a/internal/version/version.go b/internal/version/version.go index 25fff528..df79a9c0 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -13,12 +13,20 @@ import ( // TODO(a.garipov): Find out if we can get GOARM and GOMIPS values the same way // we can GOARCH and GOOS. var ( - channel string + channel string = ChannelDevelopment goarm string gomips string version string ) +// Channel constants. +const ( + ChannelDevelopment = "development" + ChannelEdge = "edge" + ChannelBeta = "beta" + ChannelRelease = "release" +) + // Channel returns the current AdGuard Home release channel. func Channel() (v string) { return channel