Merge branch 'master' into AG-27492-client-persistent-runtime-storage

This commit is contained in:
Stanislav Chzhen 2024-06-17 18:40:43 +03:00
commit 702467f7ca
6 changed files with 29 additions and 28 deletions

View File

@ -30,11 +30,29 @@ NOTE: Add new changes BELOW THIS COMMENT.
### Changed ### Changed
- Frontend rewritten in TypeScript. - Frontend rewritten in TypeScript.
- The `systemd`-based service now uses `journal` for logging by default. It
also doesn't create the `/var/log/` directory anymore ([#7053]).
**NOTE:** With an installed service for changes to take effect, you need to
reinstall the service using `-r` flag of the [install script][install-script]
or via the CLI (with root privileges):
```sh
./AdGuardHome -s uninstall
./AdGuardHome -s install
```
Don't forget to backup your configuration file and other important data before
reinstalling the service.
### Deprecated ### Deprecated
- Node 18 support, Node 20 will be required in future releases. - Node 18 support, Node 20 will be required in future releases.
[#7053]: https://github.com/AdguardTeam/AdGuardHome/issues/7053
[install-script]: https://github.com/AdguardTeam/AdGuardHome/?tab=readme-ov-file#automated-install-linux-and-mac
<!-- <!--
NOTE: Add new changes ABOVE THIS COMMENT. NOTE: Add new changes ABOVE THIS COMMENT.
--> -->

View File

@ -19,25 +19,9 @@ import (
"github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/log"
) )
// UnsupportedError is returned by functions and methods when a particular // Unsupported is a helper that returns a wrapped [errors.ErrUnsupported].
// operation Op cannot be performed on the current OS.
type UnsupportedError struct {
Op string
OS string
}
// Error implements the error interface for *UnsupportedError.
func (err *UnsupportedError) Error() (msg string) {
return fmt.Sprintf("%s is unsupported on %s", err.Op, err.OS)
}
// Unsupported is a helper that returns an *UnsupportedError with the Op field
// set to op and the OS field set to the current OS.
func Unsupported(op string) (err error) { func Unsupported(op string) (err error) {
return &UnsupportedError{ return fmt.Errorf("%s: not supported on %s: %w", op, runtime.GOOS, errors.ErrUnsupported)
Op: op,
OS: runtime.GOOS,
}
} }
// SetRlimit sets user-specified limit of how many fd's we can use. // SetRlimit sets user-specified limit of how many fd's we can use.

View File

@ -6,7 +6,6 @@ import (
"os" "os"
"strings" "strings"
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
"github.com/AdguardTeam/AdGuardHome/internal/ipset" "github.com/AdguardTeam/AdGuardHome/internal/ipset"
"github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/log"
@ -35,7 +34,7 @@ func (c *ipsetCtx) init(ipsetConf []string) (err error) {
log.Info("ipset: warning: cannot initialize: %s", err) log.Info("ipset: warning: cannot initialize: %s", err)
return nil return nil
} else if unsupErr := (&aghos.UnsupportedError{}); errors.As(err, &unsupErr) { } else if errors.Is(err, errors.ErrUnsupported) {
log.Info("ipset: warning: %s", err) log.Info("ipset: warning: %s", err)
return nil return nil

View File

@ -178,7 +178,7 @@ func setupContext(opts options) (err error) {
// unsupported errors and returns nil. If err is nil, logIfUnsupported returns // unsupported errors and returns nil. If err is nil, logIfUnsupported returns
// nil. Otherwise, it returns err. // nil. Otherwise, it returns err.
func logIfUnsupported(msg string, err error) (outErr error) { func logIfUnsupported(msg string, err error) (outErr error) {
if errors.As(err, new(*aghos.UnsupportedError)) { if errors.Is(err, errors.ErrUnsupported) {
log.Debug(msg, err) log.Debug(msg, err)
return nil return nil

View File

@ -460,8 +460,9 @@ var launchdConfig = `<?xml version='1.0' encoding='UTF-8'?>
// 1. The RestartSec setting is set to a lower value of 10 to make sure we // 1. The RestartSec setting is set to a lower value of 10 to make sure we
// always restart quickly. // always restart quickly.
// //
// 2. The ExecStartPre setting is added to make sure that the log directory is // 2. The StandardOutput and StandardError settings are set to redirect the
// always created to prevent the 209/STDOUT errors. // output to the systemd journal, see
// https://man7.org/linux/man-pages/man5/systemd.exec.5.html#LOGGING_AND_STANDARD_INPUT/OUTPUT.
const systemdScript = `[Unit] const systemdScript = `[Unit]
Description={{.Description}} Description={{.Description}}
ConditionFileIsExecutable={{.Path|cmdEscape}} ConditionFileIsExecutable={{.Path|cmdEscape}}
@ -471,7 +472,6 @@ ConditionFileIsExecutable={{.Path|cmdEscape}}
[Service] [Service]
StartLimitInterval=5 StartLimitInterval=5
StartLimitBurst=10 StartLimitBurst=10
ExecStartPre=/bin/mkdir -p /var/log/
ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}} ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
{{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}} {{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}}
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmdEscape}}{{end}} {{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmdEscape}}{{end}}
@ -479,8 +479,8 @@ ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
{{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}} {{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}}
{{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}} {{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}}
{{if and .LogOutput .HasOutputFileSupport -}} {{if and .LogOutput .HasOutputFileSupport -}}
StandardOutput=file:/var/log/{{.Name}}.out StandardOutput=journal
StandardError=file:/var/log/{{.Name}}.err StandardError=journal
{{- end}} {{- end}}
{{if gt .LimitNOFILE -1 }}LimitNOFILE={{.LimitNOFILE}}{{end}} {{if gt .LimitNOFILE -1 }}LimitNOFILE={{.LimitNOFILE}}{{end}}
{{if .Restart}}Restart={{.Restart}}{{end}} {{if .Restart}}Restart={{.Restart}}{{end}}

View File

@ -22,8 +22,8 @@ type Manager interface {
// //
// DOMAIN[,DOMAIN].../IPSET_NAME[,IPSET_NAME]... // DOMAIN[,DOMAIN].../IPSET_NAME[,IPSET_NAME]...
// //
// If ipsetConf is empty, msg and err are nil. The error is of type // If ipsetConf is empty, msg and err are nil. The error's chain contains
// *aghos.UnsupportedError if the OS is not supported. // [errors.ErrUnsupported] if current OS is not supported.
func NewManager(ipsetConf []string) (mgr Manager, err error) { func NewManager(ipsetConf []string) (mgr Manager, err error) {
if len(ipsetConf) == 0 { if len(ipsetConf) == 0 {
return nil, nil return nil, nil