Skip to content

Commit

Permalink
Merge branch 'master' into 6541-hosts-nodata
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Dec 18, 2023
2 parents 1a09de9 + d328327 commit e79507f
Show file tree
Hide file tree
Showing 92 changed files with 86 additions and 80 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -25,6 +25,9 @@ NOTE: Add new changes BELOW THIS COMMENT.

### Added

- The schema version of the configuration file to the output of running
`AdGuardHome` (or `AdGuardHome.exe) with `-v --version` command-line options
([#6545]).
- Ability to disable plain-DNS serving via UI if an encrypted protocol is
already used ([#1660]).

Expand All @@ -37,6 +40,7 @@ NOTE: Add new changes BELOW THIS COMMENT.

[#6352]: https://github.com/AdguardTeam/AdGuardHome/issues/6352
[#6541]: https://github.com/AdguardTeam/AdGuardHome/issues/6541
[#6545]: https://github.com/AdguardTeam/AdGuardHome/issues/6545

<!--
NOTE: Add new changes ABOVE THIS COMMENT.
Expand Down
5 changes: 5 additions & 0 deletions internal/configmigrate/configmigrate.go
@@ -0,0 +1,5 @@
// Package configmigrate provides a way to upgrade the YAML configuration file.
package configmigrate

// LastSchemaVersion is the most recent schema version.
const LastSchemaVersion uint = 27
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"testing"
Expand Down
@@ -1,5 +1,4 @@
// Package confmigrate provides a way to upgrade the YAML configuration file.
package confmigrate
package configmigrate

import (
"bytes"
Expand All @@ -9,9 +8,6 @@ import (
yaml "gopkg.in/yaml.v3"
)

// LastSchemaVersion is the most recent schema version.
const LastSchemaVersion uint = 27

// Config is a the configuration for initializing a [Migrator].
type Config struct {
// WorkingDir is an absolute path to the working directory of AdGuardHome.
Expand Down
@@ -1,12 +1,12 @@
package confmigrate_test
package configmigrate_test

import (
"io/fs"
"os"
"path"
"testing"

"github.com/AdguardTeam/AdGuardHome/internal/confmigrate"
"github.com/AdguardTeam/AdGuardHome/internal/configmigrate"
"github.com/AdguardTeam/golibs/testutil"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/bcrypt"
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestMigrateConfig_Migrate(t *testing.T) {
wantBody, err := fs.ReadFile(testdata, path.Join(t.Name(), outputFileName))
require.NoError(t, err)

migrator := confmigrate.New(&confmigrate.Config{
migrator := configmigrate.New(&configmigrate.Config{
WorkingDir: t.Name(),
})
newBody, upgraded, err := migrator.Migrate(body, tc.targetVersion)
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"os"
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"fmt"
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo11 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"time"
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo13 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo14 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo15 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo16 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo17 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo18 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import "github.com/AdguardTeam/golibs/log"

Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"os"
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"time"
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo21 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"fmt"
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"fmt"
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo24 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo25 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo26 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo27 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo3 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo4 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"fmt"
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import "fmt"

Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo7 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo8 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

// migrateTo9 performs the following changes:
//
Expand Down
@@ -1,4 +1,4 @@
package confmigrate
package configmigrate

import (
"fmt"
Expand Down
10 changes: 5 additions & 5 deletions internal/home/config.go
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
"github.com/AdguardTeam/AdGuardHome/internal/aghtls"
"github.com/AdguardTeam/AdGuardHome/internal/confmigrate"
"github.com/AdguardTeam/AdGuardHome/internal/configmigrate"
"github.com/AdguardTeam/AdGuardHome/internal/dhcpd"
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
Expand Down Expand Up @@ -149,7 +149,7 @@ type configuration struct {
sync.RWMutex `yaml:"-"`

// SchemaVersion is the version of the configuration schema. See
// [confmigrate.LastSchemaVersion].
// [configmigrate.LastSchemaVersion].
SchemaVersion uint `yaml:"schema_version"`
}

Expand Down Expand Up @@ -434,7 +434,7 @@ var config = &configuration{
MaxAge: 3,
},
OSConfig: &osConfig{},
SchemaVersion: confmigrate.LastSchemaVersion,
SchemaVersion: configmigrate.LastSchemaVersion,
Theme: ThemeAuto,
}

Expand Down Expand Up @@ -479,14 +479,14 @@ func parseConfig() (err error) {
return err
}

migrator := confmigrate.New(&confmigrate.Config{
migrator := configmigrate.New(&configmigrate.Config{
WorkingDir: Context.workDir,
})

var upgraded bool
config.fileData, upgraded, err = migrator.Migrate(
config.fileData,
confmigrate.LastSchemaVersion,
configmigrate.LastSchemaVersion,
)
if err != nil {
// Don't wrap the error, because it's informative enough as is.
Expand Down
3 changes: 2 additions & 1 deletion internal/home/options.go
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"strings"

"github.com/AdguardTeam/AdGuardHome/internal/configmigrate"
"github.com/AdguardTeam/AdGuardHome/internal/version"
"github.com/AdguardTeam/golibs/log"
"github.com/AdguardTeam/golibs/stringutil"
Expand Down Expand Up @@ -308,7 +309,7 @@ var cmdLineOpts = []cmdLineOpt{{
effect: func(o options, exec string) (effect, error) {
return func() error {
if o.verbose {
fmt.Println(version.Verbose())
fmt.Print(version.Verbose(configmigrate.LastSchemaVersion))
} else {
fmt.Println(version.Full())
}
Expand Down
3 changes: 2 additions & 1 deletion internal/next/cmd/opt.go
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"strings"

"github.com/AdguardTeam/AdGuardHome/internal/configmigrate"
"github.com/AdguardTeam/AdGuardHome/internal/next/configmgr"
"github.com/AdguardTeam/AdGuardHome/internal/version"
"github.com/AdguardTeam/golibs/log"
Expand Down Expand Up @@ -382,7 +383,7 @@ func processOptions(

if opts.version {
if opts.verbose {
fmt.Println(version.Verbose())
fmt.Print(version.Verbose(configmigrate.LastSchemaVersion))
} else {
fmt.Printf("AdGuard Home %s\n", version.Version())
}
Expand Down

0 comments on commit e79507f

Please sign in to comment.