mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-18 04:51:45 +03:00
Pull request: web-addr-cmdline
Merge in DNS/adguard-home from web-addr-cmdline to master Squashed commit of the following: commit 27652dbfae227f9a9f4d921f14af1e5897d7830d Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Jun 22 17:51:43 2023 +0400 home: web-addr opt commit b234d108e70fed3ff11eeb4986946f8a50dda515 Merge: eef1b5cbb66345e855
Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Jun 22 17:10:57 2023 +0400 Merge remote-tracking branch 'origin/master' into web-addr-cmdline # Conflicts: # CHANGELOG.md commit eef1b5cbb9f7dd9819c8038800a4bbcf3ff575aa Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Jun 22 17:04:12 2023 +0400 all: docs Updates #4231. commit b4adb0bae82e44101f7b6685a29926c3d02e95af Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Jun 22 16:58:12 2023 +0400 all: docker Updates #4231. commit a4012fddc50a3f5143136df8f3b865d7e1b9087c Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Jun 22 11:24:02 2023 +0400 all: docker commit bd5cc3308298b1022dea501c2fe79d96df24ce2a Merge: 36841dd85123ca8738
Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Jun 22 11:22:51 2023 +0400 Merge remote-tracking branch 'origin/master' into web-addr-cmdline commit 36841dd85fe1d006e6ec518329cb8ceea0915599 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Wed Jun 21 11:53:40 2023 +0400 all: docker commit 5c4756a56d251f1486b92f333f11485b5f4807f4 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Wed Jun 21 11:50:41 2023 +0400 all: imp docs commit 7b6fba81f2d5a354bdf259d812d04f3bd64de0c6 Merge: 54c119024ca313521d
Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Wed Jun 21 11:47:36 2023 +0400 Merge remote-tracking branch 'origin/master' into web-addr-cmdline commit 54c119024f3999d5c4dec06b21e3bb78803bf388 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Tue Jun 20 15:57:54 2023 +0400 home: imp code commit c87e0a690376aa6a28a018c3cbbb5de0ad16333d Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Tue Jun 20 15:56:45 2023 +0400 all: imp docs commit de240d00e334f7fd3dbf39ac08472183deeb32db Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Tue Jun 20 15:54:27 2023 +0400 all: docker commit 568d5371e73fb6c5ba19a036e7a5135764f6538b Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Tue Jun 20 13:38:53 2023 +0400 all: docs commit 407e230c8e3bc293e8d533ca5db1f28fec4b3c54 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Tue Jun 20 13:24:23 2023 +0400 home: deprecate opts commit 6e628fad6f4ee9f23213eeb55bec500db4435175 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Tue Jun 20 13:18:10 2023 +0400 home: web-addr opt
This commit is contained in:
parent
66345e855e
commit
e54fc9b1e9
5 changed files with 70 additions and 5 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -25,6 +25,8 @@ NOTE: Add new changes BELOW THIS COMMENT.
|
|||
|
||||
### Added
|
||||
|
||||
- The new command-line flag `--web-addr` is the address to serve the web UI on,
|
||||
in the host:port format.
|
||||
- The ability to set inactivity periods for filtering blocked services in the
|
||||
configuration file ([#951]). The UI changes are coming in the upcoming
|
||||
releases.
|
||||
|
@ -80,8 +82,15 @@ In this release, the schema version has changed from 20 to 21.
|
|||
To rollback this change, replace `dns.blocked_services` object with the list
|
||||
of ids of blocked services and change the `schema_version` back to `20`.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Flags `-h`, `--host`, `-p`, `--port` have been deprecated. The `-h` flag
|
||||
will work as an alias for `--help`, instead of the deprecated `--host` in the
|
||||
future releases.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Cannot set `bind_host` in AdGuardHome.yaml (docker version) ([#4231]).
|
||||
- The blocklists can now be deleted properly ([#5700]).
|
||||
- Queries with the question-section target `.`, for example `NS .`, are now
|
||||
counted in the statistics and correctly shown in the query log ([#5910]).
|
||||
|
@ -90,6 +99,7 @@ In this release, the schema version has changed from 20 to 21.
|
|||
|
||||
[#951]: https://github.com/AdguardTeam/AdGuardHome/issues/951
|
||||
[#1577]: https://github.com/AdguardTeam/AdGuardHome/issues/1577
|
||||
[#4231]: https://github.com/AdguardTeam/AdGuardHome/issues/4231
|
||||
[#5700]: https://github.com/AdguardTeam/AdGuardHome/issues/5700
|
||||
[#5910]: https://github.com/AdguardTeam/AdGuardHome/issues/5910
|
||||
[#5913]: https://github.com/AdguardTeam/AdGuardHome/issues/5913
|
||||
|
|
|
@ -82,6 +82,5 @@ CMD [ \
|
|||
"/opt/adguardhome/AdGuardHome", \
|
||||
"--no-check-update", \
|
||||
"-c", "/opt/adguardhome/conf/AdGuardHome.yaml", \
|
||||
"-h", "0.0.0.0", \
|
||||
"-w", "/opt/adguardhome/work" \
|
||||
]
|
||||
|
|
|
@ -382,6 +382,19 @@ func setupBindOpts(opts options) (err error) {
|
|||
config.BindHost = opts.bindHost
|
||||
}
|
||||
|
||||
// Rewrite deprecated options.
|
||||
bindAddr := opts.bindAddr
|
||||
if bindAddr.IsValid() {
|
||||
config.BindHost = bindAddr.Addr()
|
||||
config.BindPort = int(bindAddr.Port())
|
||||
|
||||
err = checkPorts()
|
||||
if err != nil {
|
||||
// Don't wrap the error, because it's informative enough as is.
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,18 @@ type options struct {
|
|||
serviceControlAction string
|
||||
|
||||
// bindHost is the address on which to serve the HTTP UI.
|
||||
//
|
||||
// Deprecated: Use bindAddr.
|
||||
bindHost netip.Addr
|
||||
|
||||
// bindPort is the port on which to serve the HTTP UI.
|
||||
//
|
||||
// Deprecated: Use bindAddr.
|
||||
bindPort int
|
||||
|
||||
// bindAddr is the address to serve the web UI on.
|
||||
bindAddr netip.AddrPort
|
||||
|
||||
// checkConfig is true if the current invocation is only required to check
|
||||
// the configuration file and exit.
|
||||
checkConfig bool
|
||||
|
@ -147,7 +154,8 @@ var cmdLineOpts = []cmdLineOpt{{
|
|||
|
||||
return o.bindHost.String(), true
|
||||
},
|
||||
description: "Host address to bind HTTP server on.",
|
||||
description: "Deprecated. Host address to bind HTTP server on. Use --web-addr. " +
|
||||
"The short -h will work as --help in the future.",
|
||||
longName: "host",
|
||||
shortName: "h",
|
||||
}, {
|
||||
|
@ -174,9 +182,23 @@ var cmdLineOpts = []cmdLineOpt{{
|
|||
|
||||
return strconv.Itoa(o.bindPort), true
|
||||
},
|
||||
description: "Port to serve HTTP pages on.",
|
||||
description: "Deprecated. Port to serve HTTP pages on. Use --web-addr.",
|
||||
longName: "port",
|
||||
shortName: "p",
|
||||
}, {
|
||||
updateWithValue: func(o options, v string) (oo options, err error) {
|
||||
o.bindAddr, err = netip.ParseAddrPort(v)
|
||||
|
||||
return o, err
|
||||
},
|
||||
updateNoValue: nil,
|
||||
effect: nil,
|
||||
serialize: func(o options) (val string, ok bool) {
|
||||
return o.bindAddr.String(), o.bindAddr.IsValid()
|
||||
},
|
||||
description: "Address to serve the web UI on, in the host:port format.",
|
||||
longName: "web-addr",
|
||||
shortName: "",
|
||||
}, {
|
||||
updateWithValue: func(o options, v string) (options, error) {
|
||||
o.serviceControlAction = v
|
||||
|
|
|
@ -82,6 +82,23 @@ func TestParseBindPort(t *testing.T) {
|
|||
testParseErr(t, "port too high", "-p", "18446744073709551617") // 2^64 + 1
|
||||
}
|
||||
|
||||
func TestParseBindAddr(t *testing.T) {
|
||||
wantAddrPort := netip.MustParseAddrPort("1.2.3.4:8089")
|
||||
|
||||
assert.Zero(t, testParseOK(t).bindAddr, "empty is not web-addr")
|
||||
|
||||
assert.Equal(t, wantAddrPort, testParseOK(t, "--web-addr", "1.2.3.4:8089").bindAddr)
|
||||
assert.Equal(t, netip.MustParseAddrPort("1.2.3.4:0"), testParseOK(t, "--web-addr", "1.2.3.4:0").bindAddr)
|
||||
testParseParamMissing(t, "-web-addr")
|
||||
|
||||
testParseErr(t, "not an int", "--web-addr", "1.2.3.4:x")
|
||||
testParseErr(t, "hex not supported", "--web-addr", "1.2.3.4:0x100")
|
||||
testParseErr(t, "port negative", "--web-addr", "1.2.3.4:-1")
|
||||
testParseErr(t, "port too high", "--web-addr", "1.2.3.4:65536")
|
||||
testParseErr(t, "port too high", "--web-addr", "1.2.3.4:4294967297") // 2^32 + 1
|
||||
testParseErr(t, "port too high", "--web-addr", "1.2.3.4:18446744073709551617") // 2^64 + 1
|
||||
}
|
||||
|
||||
func TestParseLogfile(t *testing.T) {
|
||||
assert.Equal(t, "", testParseOK(t).logFile, "empty is no log file")
|
||||
assert.Equal(t, "path", testParseOK(t, "-l", "path").logFile, "-l is log file")
|
||||
|
@ -162,6 +179,10 @@ func TestOptsToArgs(t *testing.T) {
|
|||
name: "bind_port",
|
||||
args: []string{"-p", "666"},
|
||||
opts: options{bindPort: 666},
|
||||
}, {
|
||||
name: "web-addr",
|
||||
args: []string{"--web-addr", "1.2.3.4:8080"},
|
||||
opts: options{bindAddr: netip.MustParseAddrPort("1.2.3.4:8080")},
|
||||
}, {
|
||||
name: "log_file",
|
||||
args: []string{"-l", "path"},
|
||||
|
|
Loading…
Reference in a new issue