docstring_tokens
stringlengths 18
16.9k
| code_tokens
stringlengths 75
1.81M
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|
keep add keep keep keep keep keep keep
|
<mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "minimist": "0.0.8"
<mask> }
<mask> },
<mask> "ms": {
<mask> "version": "2.0.0",
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> add "optional": true, </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> add "optional": true, </s> add "optional": true, </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true
|
https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed
|
client/package-lock.json
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> },
<mask> "number-is-nan": {
<mask> "version": "1.0.1",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "object-assign": {
<mask> "version": "4.1.1",
<mask> "bundled": true,
<mask> "dev": true,
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> add "optional": true, </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true
|
https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed
|
client/package-lock.json
|
keep add keep keep keep keep keep
|
<mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "wrappy": "1"
<mask> }
<mask> },
<mask> "os-homedir": {
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> add "optional": true, </s> add "optional": true, </s> add "optional": true, </s> add "optional": true, </s> add "optional": true,
|
https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed
|
client/package-lock.json
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> },
<mask> "safe-buffer": {
<mask> "version": "5.1.1",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "safer-buffer": {
<mask> "version": "2.1.2",
<mask> "bundled": true,
<mask> "dev": true,
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true
|
https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed
|
client/package-lock.json
|
keep keep keep add keep keep keep keep
|
<mask> "string-width": {
<mask> "version": "1.0.2",
<mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "code-point-at": "^1.0.0",
<mask> "is-fullwidth-code-point": "^1.0.0",
<mask> "strip-ansi": "^3.0.0"
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> add "optional": true, </s> add "optional": true, </s> add "optional": true, </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true
|
https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed
|
client/package-lock.json
|
keep keep keep add keep keep keep keep keep keep
|
<mask> "strip-ansi": {
<mask> "version": "3.0.1",
<mask> "bundled": true,
<mask> "dev": true,
<mask> "requires": {
<mask> "ansi-regex": "^2.0.0"
<mask> }
<mask> },
<mask> "strip-json-comments": {
<mask> "version": "2.0.1",
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> add "optional": true, </s> add "optional": true, </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true
|
https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed
|
client/package-lock.json
|
keep keep keep keep replace keep keep keep keep replace
|
<mask> },
<mask> "wrappy": {
<mask> "version": "1.0.2",
<mask> "bundled": true,
<mask> "dev": true
<mask> },
<mask> "yallist": {
<mask> "version": "3.0.2",
<mask> "bundled": true,
<mask> "dev": true
</s> npm 6.7.0 unconditionally modifies package-lock.json. Commit those changes. </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true </s> remove "dev": true
</s> add "dev": true,
"optional": true
|
https://github.com/AdguardTeam/AdGuardHome/commit/548f5395661a735ef38911bf9958e6e095c9d1ed
|
client/package-lock.json
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> ReqECS: pctx.ReqECS,
<mask> Answer: pctx.Res,
<mask> OrigAnswer: dctx.origResp,
<mask> Result: dctx.result,
<mask> Elapsed: elapsed,
<mask> ClientID: dctx.clientID,
<mask> ClientIP: ip,
<mask> AuthenticatedData: dctx.responseAD,
<mask> }
<mask>
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> add Elapsed: elapsed, </s> remove ClientIP: client,
</s> add </s> add ClientIP: client, </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove Anonymizer: anonymizer,
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/dnsforward/stats.go
|
keep keep add keep keep keep keep keep
|
<mask> Result: dctx.result,
<mask> ClientID: dctx.clientID,
<mask> ClientIP: ip,
<mask> AuthenticatedData: dctx.responseAD,
<mask> }
<mask>
<mask> switch pctx.Proto {
<mask> case proxy.ProtoHTTPS:
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove Elapsed: elapsed,
</s> add </s> add ClientIP: client, </s> remove ClientIP: client,
</s> add </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> add oldestNano = 0
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/dnsforward/stats.go
|
keep keep keep add keep keep keep keep keep
|
<mask> return fmt.Errorf("init stats: %w", err)
<mask> }
<mask>
<mask> conf := querylog.Config{
<mask> ConfigModified: onConfigModified,
<mask> HTTPRegister: httpRegister,
<mask> FindClient: Context.clients.findMultiple,
<mask> BaseDir: baseDir,
<mask> RotationIvl: config.DNS.QueryLogInterval.Duration,
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> add oldestNano = 0
</s> remove Anonymizer: anonymizer,
</s> add </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
)
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/home/dns.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> MemSize: config.DNS.QueryLogMemSize,
<mask> Enabled: config.DNS.QueryLogEnabled,
<mask> FileEnabled: config.DNS.QueryLogFileEnabled,
<mask> AnonymizeClientIP: config.DNS.AnonymizeClientIP,
<mask> Anonymizer: anonymizer,
<mask> }
<mask> Context.queryLog = querylog.New(conf)
<mask>
<mask> filterConf := config.DNS.DnsfilterConf
<mask> filterConf.EtcHosts = Context.etcHosts
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> add Anonymizer: anonymizer, </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> add oldestNano = 0
</s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) {
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/home/dns.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> "golang.org/x/net/idna"
<mask> )
<mask>
<mask> type qlogConfig struct {
<mask> Enabled bool `json:"enabled"`
<mask> // Use float64 here to support fractional numbers and not mess the API
<mask> // users by changing the units.
<mask> Interval float64 `json:"interval"`
<mask> AnonymizeClientIP bool `json:"anonymize_client_ip"`
<mask> }
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> add Enabled bool `json:"enabled"` </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> add // Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. </s> add ClientIP net.IP
// Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
)
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/http.go
|
keep keep add keep keep keep keep keep
|
<mask> // Use float64 here to support fractional numbers and not mess the API
<mask> // users by changing the units.
<mask> Interval float64 `json:"interval"`
<mask> AnonymizeClientIP bool `json:"anonymize_client_ip"`
<mask> }
<mask>
<mask> // Register web handlers
<mask> func (l *queryLog) initWeb() {
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove Enabled bool `json:"enabled"`
</s> add </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> add // Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure.
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/http.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> if err != nil && !errors.Is(err, os.ErrNotExist) {
<mask> log.Error("removing log file %q: %s", l.logFile, err)
<mask> }
<mask>
<mask> log.Debug("Query log: cleared")
<mask> }
<mask>
<mask> func (l *queryLog) Add(params *AddParams) {
<mask> if !l.conf.Enabled {
<mask> return
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> add oldestNano = 0
</s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> add Enabled bool `json:"enabled"` </s> add Anonymizer: anonymizer, </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
)
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/qlog.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> Question: &q,
<mask> Answer: &a,
<mask> OrigAnswer: &a,
<mask> Result: &res,
<mask> ClientIP: client,
<mask> Upstream: "upstream",
<mask> }
<mask>
<mask> l.Add(params)
<mask> }
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> add ClientIP: client, </s> remove Elapsed: elapsed,
</s> add </s> add Elapsed: elapsed, </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove Anonymizer: anonymizer,
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/qlog_test.go
|
keep add keep keep keep keep
|
<mask> Result: &res,
<mask> Upstream: "upstream",
<mask> }
<mask>
<mask> l.Add(params)
<mask> }
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove ClientIP: client,
</s> add </s> add Elapsed: elapsed, </s> remove Elapsed: elapsed,
</s> add </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove Anonymizer: anonymizer,
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/qlog_test.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> // WriteDiskConfig - write configuration
<mask> WriteDiskConfig(c *Config)
<mask> }
<mask>
<mask> // Config - configuration object
<mask> type Config struct {
<mask> // ConfigModified is called when the configuration is changed, for
<mask> // example by HTTP requests.
<mask> ConfigModified func()
<mask>
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> add // Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> remove Enabled bool `json:"enabled"`
</s> add </s> remove // Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> add </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> add ClientIP net.IP
// Elapsed is the time spent for processing the request.
Elapsed time.Duration
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/querylog.go
|
keep keep keep add keep keep keep keep keep keep
|
<mask> }
<mask>
<mask> // Config is the query log configuration structure.
<mask> type Config struct {
<mask> // ConfigModified is called when the configuration is changed, for
<mask> // example by HTTP requests.
<mask> ConfigModified func()
<mask>
<mask> // HTTPRegister registers an HTTP handler.
<mask> HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request))
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> remove // Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> add </s> add ClientIP net.IP
// Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> remove Enabled bool `json:"enabled"`
</s> add </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) {
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/querylog.go
|
keep keep keep keep replace replace replace keep keep keep keep keep
|
<mask>
<mask> // AnonymizeClientIP tells if the query log should anonymize clients' IP
<mask> // addresses.
<mask> AnonymizeClientIP bool
<mask>
<mask> // Anonymizer processes the IP addresses to anonymize those if needed.
<mask> Anonymizer *aghnet.IPMut
<mask> }
<mask>
<mask> // AddParams is the parameters for adding an entry.
<mask> type AddParams struct {
<mask> Question *dns.Msg
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> add // Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> remove Enabled bool `json:"enabled"`
</s> add </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. </s> add Enabled bool `json:"enabled"` </s> add ClientIP net.IP
// Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) {
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/querylog.go
|
keep keep keep keep replace replace replace keep keep replace replace keep
|
<mask>
<mask> // Result is the filtering result (optional).
<mask> Result *filtering.Result
<mask>
<mask> // Elapsed is the time spent for processing the request.
<mask> Elapsed time.Duration
<mask>
<mask> ClientID string
<mask>
<mask> ClientIP net.IP
<mask>
<mask> // Upstream is the URL of the upstream DNS server.
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> add ClientIP net.IP
// Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. </s> add // Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) {
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/querylog.go
|
keep keep keep add keep keep keep keep
|
<mask> Upstream string
<mask>
<mask> ClientProto ClientProto
<mask>
<mask> // Cached indicates if the response is served from cache.
<mask> Cached bool
<mask>
<mask> // AuthenticatedData shows if the response had the AD bit set.
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove ClientIP net.IP
</s> add </s> remove // Elapsed is the time spent for processing the request.
Elapsed time.Duration
</s> add </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add </s> add // Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add Enabled bool `json:"enabled"` </s> remove Enabled bool `json:"enabled"`
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/querylog.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask>
<mask> // search - searches log entries in the query log using specified parameters
<mask> // returns the list of entries found + time of the oldest entry
<mask> func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
<mask> now := time.Now()
<mask>
<mask> if params.limit == 0 {
<mask> return []*logEntry{}, time.Time{}
<mask> }
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) </s> remove // Config - configuration object
</s> add // Config is the query log configuration structure. </s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/search.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask>
<mask> totalLimit := params.offset + params.limit
<mask>
<mask> // now let's get a unified collection
<mask> entries := append(memoryEntries, fileEntries...)
<mask> if len(entries) > totalLimit {
<mask> // remove extra records
<mask> entries = entries[:totalLimit]
<mask> }
<mask>
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove Anonymizer: anonymizer,
</s> add </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) </s> add Anonymizer: anonymizer, </s> add oldestNano = 0
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/search.go
|
keep keep replace keep keep keep keep replace replace keep keep keep
|
<mask> }
<mask>
<mask> if len(entries) > 0 && len(entries) <= totalLimit {
<mask> // Update oldest after merging in the memory buffer.
<mask> oldest = entries[len(entries)-1].Time
<mask> }
<mask>
<mask> log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
<mask> len(entries), total, params.olderThan, time.Since(now))
<mask>
<mask> return entries, oldest
<mask> }
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> add oldestNano = 0
</s> remove
// Anonymizer processes the IP addresses to anonymize those if needed.
Anonymizer *aghnet.IPMut
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/search.go
|
keep keep keep add keep keep keep keep
|
<mask>
<mask> e, ts, err = l.readNextEntry(r, params, cache)
<mask> if err != nil {
<mask> if err == io.EOF {
<mask> break
<mask> }
<mask>
<mask> log.Error("querylog: reading next entry: %s", err)
</s> Pull request: querylog: fix oldest calc
Updates #4591.
Squashed commit of the following:
commit 70b70c78c85311363535536c7ea12336b21accf8
Author: Ainar Garipov <[email protected]>
Date: Wed May 25 17:35:54 2022 +0300
querylog: fix oldest calc </s> remove log.Debug("Query log: cleared")
</s> add log.Debug("querylog: cleared") </s> remove if len(entries) > 0 && len(entries) <= totalLimit {
</s> add if len(entries) > 0 { </s> remove func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) {
</s> add func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { </s> remove entries := append(memoryEntries, fileEntries...)
</s> add entries = append(memoryEntries, fileEntries...) </s> remove log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
len(entries), total, params.olderThan, time.Since(now))
</s> add log.Debug(
"querylog: prepared data (%d/%d) older than %s in %s",
len(entries),
total,
params.olderThan,
time.Since(now),
) </s> add Anonymizer: anonymizer,
|
https://github.com/AdguardTeam/AdGuardHome/commit/549b20bdea3c3215bb355ffc39546f7bb3260d80
|
internal/querylog/search.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> *.snap
<mask> /agh-backup/
<mask> /bin/
<mask> /build/*
<mask> /build2/*
<mask> /data/
<mask> /dist/
<mask> /filtering/tests/filtering.TestLotsOfRules*.pprof
<mask> /filtering/tests/top-1m.csv
<mask> /launchpad_credentials
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove clientFS: clientFS,
clientBetaFS: clientBetaFS,
</s> add clientFS: clientFS, </s> remove firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort,
BetaBindPort: config.BetaBindPort,
</s> add firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort,
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
.gitignore
|
keep keep keep keep replace
|
<mask> leases.db
<mask> node_modules/
<mask>
<mask> !/build/gitkeep
<mask> !/build2/gitkeep
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove if [ "$( git diff --cached --name-only -- 'client2/*.js' 'client2/*.ts' 'client2/*.tsx' )" ]
then
make VERBOSE="$verbose" js-beta-lint js-beta-test
fi
</s> add </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove clientFS: clientFS,
clientBetaFS: clientBetaFS,
</s> add clientFS: clientFS,
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
.gitignore
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
<mask> .POSIX:
<mask>
<mask> CHANNEL = development
<mask> CLIENT_BETA_DIR = client2
<mask> CLIENT_DIR = client
<mask> COMMIT = $$( git rev-parse --short HEAD )
<mask> DIST_DIR = dist
<mask> # Don't name this macro "GO", because GNU Make apparenly makes it an
<mask> # exported environment variable with the literal value of "${GO:-go}",
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
YARN_INSTALL_FLAGS = $(YARN_FLAGS) --network-timeout 120000 --silent\
--ignore-engines --ignore-optional --ignore-platform\
--ignore-scripts
</s> add </s> remove $(YARN) $(YARN_FLAGS) build
</s> add </s> remove js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
</s> add </s> remove $(YARN) $(YARN_INSTALL_FLAGS) install
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example:
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
Makefile
|
keep keep keep keep replace replace replace replace keep keep keep keep keep
|
<mask> SIGN = 1
<mask> VERBOSE = 0
<mask> VERSION = v0.0.0
<mask> YARN = yarn
<mask> YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
<mask> YARN_INSTALL_FLAGS = $(YARN_FLAGS) --network-timeout 120000 --silent\
<mask> --ignore-engines --ignore-optional --ignore-platform\
<mask> --ignore-scripts
<mask>
<mask> NEXTAPI = 0
<mask>
<mask> # Macros for the build-release target. If FRONTEND_PREBUILT is 0, the
<mask> # default, the macro $(BUILD_RELEASE_DEPS_$(FRONTEND_PREBUILT)) expands
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove CLIENT_BETA_DIR = client2
</s> add </s> remove js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove $(YARN) $(YARN_INSTALL_FLAGS) install
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove dst.BetaBindPort = src.BetaBindPort
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
Makefile
|
keep keep replace keep keep replace keep keep
|
<mask> js-build:
<mask> $(NPM) $(NPM_FLAGS) run build-prod
<mask> $(YARN) $(YARN_FLAGS) build
<mask> js-deps:
<mask> $(NPM) $(NPM_INSTALL_FLAGS) ci
<mask> $(YARN) $(YARN_INSTALL_FLAGS) install
<mask>
<mask> # TODO(a.garipov): Remove the legacy client tasks support once the new
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
</s> add </s> remove YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
YARN_INSTALL_FLAGS = $(YARN_FLAGS) --network-timeout 120000 --silent\
--ignore-engines --ignore-optional --ignore-platform\
--ignore-scripts
</s> add </s> remove CLIENT_BETA_DIR = client2
</s> add </s> remove //go:embed build build2
</s> add //go:embed build </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
Makefile
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> # TODO(a.garipov): Remove the legacy client tasks support once the new
<mask> # client is done and the old one is removed.
<mask> js-lint: ; $(NPM) $(NPM_FLAGS) run lint
<mask> js-test: ; $(NPM) $(NPM_FLAGS) run test
<mask> js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
<mask> js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
<mask>
<mask> go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
<mask> go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
<mask> go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
<mask> go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove $(YARN) $(YARN_INSTALL_FLAGS) install
</s> add </s> remove $(YARN) $(YARN_FLAGS) build
</s> add </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add </s> remove YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
YARN_INSTALL_FLAGS = $(YARN_FLAGS) --network-timeout 120000 --silent\
--ignore-engines --ignore-optional --ignore-platform\
--ignore-scripts
</s> add </s> remove CLIENT_BETA_DIR = client2
</s> add </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
Makefile
|
keep keep keep keep replace replace replace keep keep keep keep keep
|
<mask> // BindHost is the address for the web interface server to listen on.
<mask> BindHost netip.Addr `yaml:"bind_host"`
<mask> // BindPort is the port for the web interface server to listen on.
<mask> BindPort int `yaml:"bind_port"`
<mask> // BetaBindPort is the port for the new client's web interface server to
<mask> // listen on.
<mask> BetaBindPort int `yaml:"beta_bind_port"`
<mask>
<mask> // Users are the clients capable for accessing the web interface.
<mask> Users []webUser `yaml:"users"`
<mask> // AuthAttempts is the maximum number of failed login attempts a user
<mask> // can do before being blocked.
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int </s> remove clientFS fs.FS
clientBetaFS fs.FS
</s> add clientFS fs.FS </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove dst.BetaBindPort = src.BetaBindPort
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/config.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> //
<mask> // TODO(a.garipov, e.burkov): This global is awful and must be removed.
<mask> var config = &configuration{
<mask> BindPort: 3000,
<mask> BetaBindPort: 0,
<mask> BindHost: netip.IPv4Unspecified(),
<mask> AuthAttempts: 5,
<mask> AuthBlockMin: 15,
<mask> WebSessionTTLHours: 30 * 24,
<mask> DNS: dnsConfig{
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort,
BetaBindPort: config.BetaBindPort,
</s> add firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort, </s> remove // This must be removed in API v1.
w.registerBetaInstallHandlers()
</s> add </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add </s> remove //go:embed build2
</s> add //go:embed build
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/config.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> return err
<mask> }
<mask>
<mask> tcpPorts := aghalg.UniqChecker[tcpPort]{}
<mask> addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
<mask>
<mask> udpPorts := aghalg.UniqChecker[udpPort]{}
<mask> addPorts(udpPorts, udpPort(config.DNS.Port))
<mask>
<mask> if config.TLS.Enabled {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove addPorts(tcpPorts, tcpPort(opts.bindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(opts.bindPort)) </s> remove tcpPort(betaBindPort),
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove tcpPort(config.BetaBindPort),
</s> add </s> remove tcpPort(config.BetaBindPort),
</s> add </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port)
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/config.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> "os"
<mask> "os/exec"
<mask> "path/filepath"
<mask> "runtime"
<mask> "strings"
<mask> "time"
<mask> "unicode/utf8"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghalg"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove if [ "$( git diff --cached --name-only -- 'client2/*.js' 'client2/*.ts' 'client2/*.tsx' )" ]
then
make VERBOSE="$verbose" js-beta-lint js-beta-test
fi
</s> add </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove clientFS: clientFS,
clientBetaFS: clientBetaFS,
</s> add clientFS: clientFS,
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/controlinstall.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> defer func() { err = errors.Annotate(err, "validating ports: %w") }()
<mask>
<mask> portInt := req.Web.Port
<mask> port := tcpPort(portInt)
<mask> addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
<mask> if err = tcpPorts.Validate(); err != nil {
<mask> // Reset the value for the port to 1 to make sure that validateDNS
<mask> // doesn't throw the same error, unless the same TCP port is set there
<mask> // as well.
<mask> tcpPorts[port] = 1
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort))
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/controlinstall.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> // configuration structures.
<mask> func copyInstallSettings(dst, src *configuration) {
<mask> dst.BindHost = src.BindHost
<mask> dst.BindPort = src.BindPort
<mask> dst.BetaBindPort = src.BetaBindPort
<mask> dst.DNS.BindHosts = src.DNS.BindHosts
<mask> dst.DNS.Port = src.DNS.Port
<mask> }
<mask>
<mask> // shutdownTimeout is the timeout for shutting HTTP server down operation.
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove switch version.Channel() {
case version.ChannelEdge, version.ChannelDevelopment:
config.BetaBindPort = 3001
default:
// Go on.
}
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/controlinstall.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> ctx, cancel := context.WithTimeout(context.Background(), timeout)
<mask> defer cancel()
<mask>
<mask> shutdownSrv(ctx, web.httpServer)
<mask> shutdownSrv(ctx, web.httpServerBeta)
<mask> }(shutdownTimeout)
<mask> }
<mask>
<mask> // decodeApplyConfigReq decodes the configuration, validates some parameters,
<mask> // and returns it along with the boolean indicating whether or not the HTTP
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove bindPort, betaBindPort, dohPort, dotPort, dnscryptTCPPort tcpPort,
</s> add bindPort, dohPort, dotPort, dnscryptTCPPort tcpPort, </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS)
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/controlinstall.go
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace
|
<mask> Context.mux.HandleFunc("/control/install/get_addresses", preInstall(ensureGET(web.handleInstallGetAddresses)))
<mask> Context.mux.HandleFunc("/control/install/check_config", preInstall(ensurePOST(web.handleInstallCheckConfig)))
<mask> Context.mux.HandleFunc("/control/install/configure", preInstall(ensurePOST(web.handleInstallConfigure)))
<mask> }
<mask>
<mask> // checkConfigReqEntBeta is a struct representing new client's config check
<mask> // request entry. It supports multiple IP values unlike the checkConfigReqEnt.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default checkConfigReqEnt.
<mask> type checkConfigReqEntBeta struct {
<mask> IP []netip.Addr `json:"ip"`
<mask> Port int `json:"port"`
<mask> Autofix bool `json:"autofix"`
<mask> }
<mask>
<mask> // checkConfigReqBeta is a struct representing new client's config check request
<mask> // body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default checkConfigReq.
<mask> type checkConfigReqBeta struct {
<mask> Web checkConfigReqEntBeta `json:"web"`
<mask> DNS checkConfigReqEntBeta `json:"dns"`
<mask> SetStaticIP bool `json:"set_static_ip"`
<mask> }
<mask>
<mask> // handleInstallCheckConfigBeta is a substitution of /install/check_config
<mask> // handler for new client.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default handleInstallCheckConfig.
<mask> func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
<mask> reqData := checkConfigReqBeta{}
<mask> err := json.NewDecoder(r.Body).Decode(&reqData)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
<mask>
<mask> return
<mask> }
<mask>
<mask> nonBetaReqData := checkConfReq{
<mask> Web: checkConfReqEnt{
<mask> IP: reqData.Web.IP[0],
<mask> Port: reqData.Web.Port,
<mask> Autofix: reqData.Web.Autofix,
<mask> },
<mask> DNS: checkConfReqEnt{
<mask> IP: reqData.DNS.IP[0],
<mask> Port: reqData.DNS.Port,
<mask> Autofix: reqData.DNS.Autofix,
<mask> },
<mask> SetStaticIP: reqData.SetStaticIP,
<mask> }
<mask>
<mask> nonBetaReqBody := &strings.Builder{}
<mask>
<mask> err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> body := nonBetaReqBody.String()
<mask> r.Body = io.NopCloser(strings.NewReader(body))
<mask> r.ContentLength = int64(len(body))
<mask>
<mask> web.handleInstallCheckConfig(w, r)
<mask> }
<mask>
<mask> // applyConfigReqEntBeta is a struct representing new client's config setting
<mask> // request entry. It supports multiple IP values unlike the applyConfigReqEnt.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default applyConfigReqEnt.
<mask> type applyConfigReqEntBeta struct {
<mask> IP []netip.Addr `json:"ip"`
<mask> Port int `json:"port"`
<mask> }
<mask>
<mask> // applyConfigReqBeta is a struct representing new client's config setting
<mask> // request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default applyConfigReq.
<mask> type applyConfigReqBeta struct {
<mask> Username string `json:"username"`
<mask> Password string `json:"password"`
<mask>
<mask> Web applyConfigReqEntBeta `json:"web"`
<mask> DNS applyConfigReqEntBeta `json:"dns"`
<mask> }
<mask>
<mask> // handleInstallConfigureBeta is a substitution of /install/configure handler
<mask> // for new client.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default handleInstallConfigure.
<mask> func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
<mask> reqData := applyConfigReqBeta{}
<mask> err := json.NewDecoder(r.Body).Decode(&reqData)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
<mask>
<mask> return
<mask> }
<mask>
<mask> nonBetaReqData := applyConfigReq{
<mask> Web: applyConfigReqEnt{
<mask> IP: reqData.Web.IP[0],
<mask> Port: reqData.Web.Port,
<mask> },
<mask> DNS: applyConfigReqEnt{
<mask> IP: reqData.DNS.IP[0],
<mask> Port: reqData.DNS.Port,
<mask> },
<mask> Username: reqData.Username,
<mask> Password: reqData.Password,
<mask> }
<mask>
<mask> nonBetaReqBody := &strings.Builder{}
<mask>
<mask> err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
<mask>
<mask> return
<mask> }
<mask> body := nonBetaReqBody.String()
<mask> r.Body = io.NopCloser(strings.NewReader(body))
<mask> r.ContentLength = int64(len(body))
<mask>
<mask> web.handleInstallConfigure(w, r)
<mask> }
<mask>
<mask> // getAddrsResponseBeta is a struct representing new client's getting addresses
<mask> // request body. It uses array of structs instead of map.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default firstRunData.
<mask> type getAddrsResponseBeta struct {
<mask> Interfaces []*aghnet.NetInterface `json:"interfaces"`
<mask> WebPort int `json:"web_port"`
<mask> DNSPort int `json:"dns_port"`
<mask> }
<mask>
<mask> // handleInstallConfigureBeta is a substitution of /install/get_addresses
<mask> // handler for new client.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default handleInstallGetAddresses.
<mask> func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
<mask> data := getAddrsResponseBeta{
<mask> WebPort: defaultPortHTTP,
<mask> DNSPort: defaultPortDNS,
<mask> }
<mask>
<mask> ifaces, err := aghnet.GetValidNetInterfacesForWeb()
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> data.Interfaces = ifaces
<mask>
<mask> _ = aghhttp.WriteJSONResponse(w, r, data)
<mask> }
<mask>
<mask> // registerBetaInstallHandlers registers the install handlers for new client
<mask> // with the structures it supports.
<mask> //
<mask> // TODO(e.burkov): This should removed with the API v1 when the appropriate
<mask> // functionality will appear in default handlers.
<mask> func (web *Web) registerBetaInstallHandlers() {
<mask> Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
<mask> Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
<mask> Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove // This must be removed in API v1.
w.registerBetaInstallHandlers()
</s> add </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/controlinstall.go
|
keep keep keep keep replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask>
<mask> func setupContext(opts options) {
<mask> setupContextFlags(opts)
<mask>
<mask> switch version.Channel() {
<mask> case version.ChannelEdge, version.ChannelDevelopment:
<mask> config.BetaBindPort = 3001
<mask> default:
<mask> // Go on.
<mask> }
<mask>
<mask> Context.tlsRoots = aghtls.SystemRootCAs()
<mask> Context.transport = &http.Transport{
<mask> DialContext: customDialContext,
<mask> Proxy: getHTTPProxy,
<mask> TLSClientConfig: &tls.Config{
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove dst.BetaBindPort = src.BetaBindPort
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> Context.clients.Init(config.Clients.Persistent, Context.dhcpServer, Context.etcHosts, arpdb)
<mask>
<mask> if opts.bindPort != 0 {
<mask> tcpPorts := aghalg.UniqChecker[tcpPort]{}
<mask> addPorts(tcpPorts, tcpPort(opts.bindPort), tcpPort(config.BetaBindPort))
<mask>
<mask> udpPorts := aghalg.UniqChecker[udpPort]{}
<mask> addPorts(udpPorts, udpPort(config.DNS.Port))
<mask>
<mask> if config.TLS.Enabled {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove tcpPort(betaBindPort),
</s> add </s> remove bindPort, betaBindPort, dohPort, dotPort, dnscryptTCPPort tcpPort,
</s> add bindPort, dohPort, dotPort, dnscryptTCPPort tcpPort, </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep keep replace keep keep keep keep replace keep keep keep keep
|
<mask>
<mask> func initWeb(opts options, clientBuildFS fs.FS) (web *Web, err error) {
<mask> var clientFS, clientBetaFS fs.FS
<mask> if opts.localFrontend {
<mask> log.Info("warning: using local frontend files")
<mask>
<mask> clientFS = os.DirFS("build/static")
<mask> clientBetaFS = os.DirFS("build2/static")
<mask> } else {
<mask> clientFS, err = fs.Sub(clientBuildFS, "build/static")
<mask> if err != nil {
<mask> return nil, fmt.Errorf("getting embedded client subdir: %w", err)
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove clientFS fs.FS
clientBetaFS fs.FS
</s> add clientFS fs.FS </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep replace replace replace replace replace keep keep keep replace replace replace replace keep keep keep
|
<mask> }
<mask>
<mask> clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
<mask> if err != nil {
<mask> return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
<mask> }
<mask> }
<mask>
<mask> webConf := webConfig{
<mask> firstRun: Context.firstRun,
<mask> BindHost: config.BindHost,
<mask> BindPort: config.BindPort,
<mask> BetaBindPort: config.BetaBindPort,
<mask>
<mask> ReadTimeout: readTimeout,
<mask> ReadHeaderTimeout: readHdrTimeout,
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove clientFS: clientFS,
clientBetaFS: clientBetaFS,
</s> add clientFS: clientFS, </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port)
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> ReadTimeout: readTimeout,
<mask> ReadHeaderTimeout: readHdrTimeout,
<mask> WriteTimeout: writeTimeout,
<mask>
<mask> clientFS: clientFS,
<mask> clientBetaFS: clientBetaFS,
<mask>
<mask> serveHTTP3: config.DNS.ServeHTTP3,
<mask> }
<mask>
<mask> web = newWeb(&webConf)
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort,
BetaBindPort: config.BetaBindPort,
</s> add firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort, </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep keep keep replace replace keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep
|
<mask> }
<mask>
<mask> // printWebAddrs prints addresses built from proto, addr, and an appropriate
<mask> // port. At least one address is printed with the value of port. If the value
<mask> // of betaPort is 0, the second address is not printed. Output example:
<mask> //
<mask> // Go to http://127.0.0.1:80
<mask> // Go to http://127.0.0.1:3000 (BETA)
<mask> func printWebAddrs(proto, addr string, port, betaPort int) {
<mask> const (
<mask> hostMsg = "Go to %s://%s"
<mask> hostBetaMsg = hostMsg + " (BETA)"
<mask> )
<mask>
<mask> log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
<mask> if betaPort == 0 {
<mask> return
<mask> }
<mask>
<mask> log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
<mask> }
<mask>
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask>
<mask> // TODO(e.burkov): Inspect and perhaps merge with the previous condition.
<mask> if proto == aghhttp.SchemeHTTPS && tlsConf.ServerName != "" {
<mask> printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
<mask>
<mask> return
<mask> }
<mask>
<mask> bindhost := config.BindHost
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask>
<mask> bindhost := config.BindHost
<mask> if !bindhost.IsUnspecified() {
<mask> printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
<mask>
<mask> return
<mask> }
<mask>
<mask> ifaces, err := aghnet.GetValidNetInterfacesForWeb()
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove printWebAddrs(proto, addr.String(), config.BindPort, config.BetaBindPort)
</s> add printWebAddrs(proto, addr.String(), config.BindPort) </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> log.Error("web: getting iface ips: %s", err)
<mask> // That's weird, but we'll ignore it.
<mask> //
<mask> // TODO(e.burkov): Find out when it happens.
<mask> printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
<mask>
<mask> return
<mask> }
<mask>
<mask> for _, iface := range ifaces {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove printWebAddrs(proto, addr.String(), config.BindPort, config.BetaBindPort)
</s> add printWebAddrs(proto, addr.String(), config.BindPort) </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example:
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask>
<mask> for _, iface := range ifaces {
<mask> for _, addr := range iface.Addresses {
<mask> printWebAddrs(proto, addr.String(), config.BindPort, config.BetaBindPort)
<mask> }
<mask> }
<mask> }
<mask>
<mask> // -------------------
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
</s> add printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS) </s> remove firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort,
BetaBindPort: config.BetaBindPort,
</s> add firstRun: Context.firstRun,
BindHost: config.BindHost,
BindPort: config.BindPort, </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/home.go
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace
|
<mask>
<mask> h.ServeHTTP(w, rr)
<mask> })
<mask> }
<mask>
<mask> // wrapIndexBeta returns handler that deals with new client.
<mask> func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
<mask> return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
<mask> h, pattern := Context.mux.Handler(r)
<mask> switch pattern {
<mask> case "/":
<mask> web.handlerBeta.ServeHTTP(w, r)
<mask> case "/install.html":
<mask> web.installerBeta.ServeHTTP(w, r)
<mask> default:
<mask> h.ServeHTTP(w, r)
<mask> }
<mask> })
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove switch version.Channel() {
case version.ChannelEdge, version.ChannelDevelopment:
config.BetaBindPort = 3001
default:
// Go on.
}
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/middlewares.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask>
<mask> if setts.Enabled {
<mask> err = validatePorts(
<mask> tcpPort(config.BindPort),
<mask> tcpPort(config.BetaBindPort),
<mask> tcpPort(setts.PortHTTPS),
<mask> tcpPort(setts.PortDNSOverTLS),
<mask> tcpPort(setts.PortDNSCrypt),
<mask> udpPort(config.DNS.Port),
<mask> udpPort(setts.PortDNSOverQUIC),
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove tcpPort(config.BetaBindPort),
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/tls.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask>
<mask> if req.Enabled {
<mask> err = validatePorts(
<mask> tcpPort(config.BindPort),
<mask> tcpPort(config.BetaBindPort),
<mask> tcpPort(req.PortHTTPS),
<mask> tcpPort(req.PortDNSOverTLS),
<mask> tcpPort(req.PortDNSCrypt),
<mask> udpPort(config.DNS.Port),
<mask> udpPort(req.PortDNSOverQUIC),
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove tcpPort(config.BetaBindPort),
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/tls.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask>
<mask> // validatePorts validates the uniqueness of TCP and UDP ports for AdGuard Home
<mask> // DNS protocols.
<mask> func validatePorts(
<mask> bindPort, betaBindPort, dohPort, dotPort, dnscryptTCPPort tcpPort,
<mask> dnsPort, doqPort udpPort,
<mask> ) (err error) {
<mask> tcpPorts := aghalg.UniqChecker[tcpPort]{}
<mask> addPorts(
<mask> tcpPorts,
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove tcpPort(betaBindPort),
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(opts.bindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(opts.bindPort)) </s> remove 'InitialConfigurationBeta':
'type': 'object'
'description': >
AdGuard Home initial configuration for the first-install wizard.
'required':
- 'dns'
- 'web'
- 'username'
- 'password'
'properties':
'dns':
'$ref': '#/components/schemas/AddressInfoBeta'
'web':
'$ref': '#/components/schemas/AddressInfoBeta'
'username':
'type': 'string'
'description': 'Basic auth username'
'example': 'admin'
'password':
'type': 'string'
'description': 'Basic auth password'
'example': 'password'
</s> add </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port))
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/tls.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> tcpPorts := aghalg.UniqChecker[tcpPort]{}
<mask> addPorts(
<mask> tcpPorts,
<mask> tcpPort(bindPort),
<mask> tcpPort(betaBindPort),
<mask> tcpPort(dohPort),
<mask> tcpPort(dotPort),
<mask> tcpPort(dnscryptTCPPort),
<mask> )
<mask>
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove bindPort, betaBindPort, dohPort, dotPort, dnscryptTCPPort tcpPort,
</s> add bindPort, dohPort, dotPort, dnscryptTCPPort tcpPort, </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove addPorts(tcpPorts, tcpPort(opts.bindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(opts.bindPort)) </s> remove clientFS fs.FS
clientBetaFS fs.FS
</s> add clientFS fs.FS </s> remove CLIENT_BETA_DIR = client2
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/tls.go
|
keep keep keep keep replace replace keep replace replace replace replace keep keep
|
<mask> writeTimeout = 60 * time.Second
<mask> )
<mask>
<mask> type webConfig struct {
<mask> clientFS fs.FS
<mask> clientBetaFS fs.FS
<mask>
<mask> BindHost netip.Addr
<mask> BindPort int
<mask> BetaBindPort int
<mask> PortHTTPS int
<mask>
<mask> // ReadTimeout is an option to pass to http.Server for setting an
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/web.go
|
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask>
<mask> // TODO(a.garipov): Refactor all these servers.
<mask> httpServer *http.Server
<mask>
<mask> // httpServerBeta is a server for new client.
<mask> httpServerBeta *http.Server
<mask>
<mask> // handlerBeta is the handler for new client.
<mask> handlerBeta http.Handler
<mask>
<mask> // installerBeta is the pre-install handler for new client.
<mask> installerBeta http.Handler
<mask>
<mask> // httpsServer is the server that handles HTTPS traffic. If it is not nil,
<mask> // [Web.http3Server] must also not be nil.
<mask> httpsServer httpsServer
<mask>
<mask> forceHTTPS bool
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove // BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
</s> add </s> remove js-beta-lint: ; $(YARN) $(YARN_FLAGS) lint
js-beta-test: ; # TODO(v.abdulmyanov): Add tests for the new client.
</s> add </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add </s> remove dst.BetaBindPort = src.BetaBindPort
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/web.go
|
keep keep replace keep keep keep replace keep
|
<mask>
<mask> clientFS := http.FileServer(http.FS(conf.clientFS))
<mask> betaClientFS := http.FileServer(http.FS(conf.clientBetaFS))
<mask>
<mask> // if not configured, redirect / to /install.html, otherwise redirect /install.html to /
<mask> Context.mux.Handle("/", withMiddlewares(clientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler))
<mask> w.handlerBeta = withMiddlewares(betaClientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler)
<mask>
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add </s> remove // This must be removed in API v1.
w.registerBetaInstallHandlers()
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove BindHost netip.Addr
BindPort int
BetaBindPort int
PortHTTPS int
</s> add BindHost netip.Addr
BindPort int
PortHTTPS int </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port))
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/web.go
|
keep keep replace keep replace replace keep
|
<mask> log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ")
<mask> Context.mux.Handle("/install.html", preInstallHandler(clientFS))
<mask> w.installerBeta = preInstallHandler(betaClientFS)
<mask> w.registerInstallHandlers()
<mask> // This must be removed in API v1.
<mask> w.registerBetaInstallHandlers()
<mask> } else {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove w.handlerBeta = withMiddlewares(betaClientFS, gziphandler.GzipHandler, optionalAuthHandler, postInstallHandler)
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove BetaBindPort: 0,
</s> add </s> remove // httpServerBeta is a server for new client.
httpServerBeta *http.Server
// handlerBeta is the handler for new client.
handlerBeta http.Handler
// installerBeta is the pre-install handler for new client.
installerBeta http.Handler
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port))
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/web.go
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask>
<mask> errs <- web.httpServer.ListenAndServe()
<mask> }()
<mask>
<mask> web.startBetaServer(hostStr)
<mask>
<mask> err := <-errs
<mask> if !errors.Is(err, http.ErrServerClosed) {
<mask> cleanupAlways()
<mask> log.Fatal(err)
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(config.BindPort)) </s> remove printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
</s> add printWebAddrs(proto, bindhost.String(), port) </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/web.go
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> // address, so go back to the start of the loop.
<mask> }
<mask> }
<mask>
<mask> // startBetaServer starts the beta HTTP server if necessary.
<mask> func (web *Web) startBetaServer(hostStr string) {
<mask> if web.conf.BetaBindPort == 0 {
<mask> return
<mask> }
<mask>
<mask> // Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
<mask> hdlr := h2c.NewHandler(
<mask> withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
<mask> &http2.Server{},
<mask> )
<mask>
<mask> web.httpServerBeta = &http.Server{
<mask> ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
<mask> Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
<mask> Handler: hdlr,
<mask> ReadTimeout: web.conf.ReadTimeout,
<mask> ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
<mask> WriteTimeout: web.conf.WriteTimeout,
<mask> }
<mask> go func() {
<mask> defer log.OnPanic("web: plain: beta")
<mask>
<mask> betaErr := web.httpServerBeta.ListenAndServe()
<mask> if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
<mask> log.Error("starting beta http server: %s", betaErr)
<mask> }
<mask> }()
<mask> }
<mask>
<mask> // Close gracefully shuts down the HTTP servers.
<mask> func (web *Web) Close(ctx context.Context) {
<mask> log.Info("stopping http server...")
<mask>
<mask> web.httpsServer.cond.L.Lock()
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove
clientBetaFS, err = fs.Sub(clientBuildFS, "build2/static")
if err != nil {
return nil, fmt.Errorf("getting embedded beta client subdir: %w", err)
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/web.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask>
<mask> shutdownSrv(ctx, web.httpsServer.server)
<mask> shutdownSrv3(web.httpsServer.server3)
<mask> shutdownSrv(ctx, web.httpServer)
<mask> shutdownSrv(ctx, web.httpServerBeta)
<mask>
<mask> log.Info("stopped http server")
<mask> }
<mask>
<mask> func (web *Web) tlsServerLoop() {
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove shutdownSrv(ctx, web.httpServerBeta)
</s> add </s> remove // startBetaServer starts the beta HTTP server if necessary.
func (web *Web) startBetaServer(hostStr string) {
if web.conf.BetaBindPort == 0 {
return
}
// Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies.
hdlr := h2c.NewHandler(
withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
&http2.Server{},
)
web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
Handler: hdlr,
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
go func() {
defer log.OnPanic("web: plain: beta")
betaErr := web.httpServerBeta.ListenAndServe()
if betaErr != nil && !errors.Is(betaErr, http.ErrServerClosed) {
log.Error("starting beta http server: %s", betaErr)
}
}()
}
</s> add </s> remove
// wrapIndexBeta returns handler that deals with new client.
func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h, pattern := Context.mux.Handler(r)
switch pattern {
case "/":
web.handlerBeta.ServeHTTP(w, r)
case "/install.html":
web.installerBeta.ServeHTTP(w, r)
default:
h.ServeHTTP(w, r)
}
})
}
</s> add </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove
// checkConfigReqEntBeta is a struct representing new client's config check
// request entry. It supports multiple IP values unlike the checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReqEnt.
type checkConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
}
// checkConfigReqBeta is a struct representing new client's config check request
// body. It uses checkConfigReqEntBeta instead of checkConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default checkConfigReq.
type checkConfigReqBeta struct {
Web checkConfigReqEntBeta `json:"web"`
DNS checkConfigReqEntBeta `json:"dns"`
SetStaticIP bool `json:"set_static_ip"`
}
// handleInstallCheckConfigBeta is a substitution of /install/check_config
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallCheckConfig.
func (web *Web) handleInstallCheckConfigBeta(w http.ResponseWriter, r *http.Request) {
reqData := checkConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := checkConfReq{
Web: checkConfReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
Autofix: reqData.Web.Autofix,
},
DNS: checkConfReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
Autofix: reqData.DNS.Autofix,
},
SetStaticIP: reqData.SetStaticIP,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding check_config: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallCheckConfig(w, r)
}
// applyConfigReqEntBeta is a struct representing new client's config setting
// request entry. It supports multiple IP values unlike the applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReqEnt.
type applyConfigReqEntBeta struct {
IP []netip.Addr `json:"ip"`
Port int `json:"port"`
}
// applyConfigReqBeta is a struct representing new client's config setting
// request body. It uses applyConfigReqEntBeta instead of applyConfigReqEnt.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default applyConfigReq.
type applyConfigReqBeta struct {
Username string `json:"username"`
Password string `json:"password"`
Web applyConfigReqEntBeta `json:"web"`
DNS applyConfigReqEntBeta `json:"dns"`
}
// handleInstallConfigureBeta is a substitution of /install/configure handler
// for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallConfigure.
func (web *Web) handleInstallConfigureBeta(w http.ResponseWriter, r *http.Request) {
reqData := applyConfigReqBeta{}
err := json.NewDecoder(r.Body).Decode(&reqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "Failed to parse 'check_config' JSON data: %s", err)
return
}
if len(reqData.DNS.IP) == 0 || len(reqData.Web.IP) == 0 {
aghhttp.Error(r, w, http.StatusBadRequest, http.StatusText(http.StatusBadRequest))
return
}
nonBetaReqData := applyConfigReq{
Web: applyConfigReqEnt{
IP: reqData.Web.IP[0],
Port: reqData.Web.Port,
},
DNS: applyConfigReqEnt{
IP: reqData.DNS.IP[0],
Port: reqData.DNS.Port,
},
Username: reqData.Username,
Password: reqData.Password,
}
nonBetaReqBody := &strings.Builder{}
err = json.NewEncoder(nonBetaReqBody).Encode(nonBetaReqData)
if err != nil {
aghhttp.Error(r, w, http.StatusBadRequest, "encoding configure: %s", err)
return
}
body := nonBetaReqBody.String()
r.Body = io.NopCloser(strings.NewReader(body))
r.ContentLength = int64(len(body))
web.handleInstallConfigure(w, r)
}
// getAddrsResponseBeta is a struct representing new client's getting addresses
// request body. It uses array of structs instead of map.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default firstRunData.
type getAddrsResponseBeta struct {
Interfaces []*aghnet.NetInterface `json:"interfaces"`
WebPort int `json:"web_port"`
DNSPort int `json:"dns_port"`
}
// handleInstallConfigureBeta is a substitution of /install/get_addresses
// handler for new client.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handleInstallGetAddresses.
func (web *Web) handleInstallGetAddressesBeta(w http.ResponseWriter, r *http.Request) {
data := getAddrsResponseBeta{
WebPort: defaultPortHTTP,
DNSPort: defaultPortDNS,
}
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
if err != nil {
aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err)
return
}
data.Interfaces = ifaces
_ = aghhttp.WriteJSONResponse(w, r, data)
}
// registerBetaInstallHandlers registers the install handlers for new client
// with the structures it supports.
//
// TODO(e.burkov): This should removed with the API v1 when the appropriate
// functionality will appear in default handlers.
func (web *Web) registerBetaInstallHandlers() {
Context.mux.HandleFunc("/control/install/get_addresses_beta", preInstall(ensureGET(web.handleInstallGetAddressesBeta)))
Context.mux.HandleFunc("/control/install/check_config_beta", preInstall(ensurePOST(web.handleInstallCheckConfigBeta)))
Context.mux.HandleFunc("/control/install/configure_beta", preInstall(ensurePOST(web.handleInstallConfigureBeta)))
}
</s> add </s> remove switch version.Channel() {
case version.ChannelEdge, version.ChannelDevelopment:
config.BetaBindPort = 3001
default:
// Go on.
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
internal/home/web.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> // Embed the prebuilt client here since we strive to keep .go files inside the
<mask> // internal directory and the embed package is unable to embed files located
<mask> // outside of the same or underlying directory.
<mask>
<mask> //go:embed build build2
<mask> var clientBuildFS embed.FS
<mask>
<mask> func main() {
<mask> home.Main(clientBuildFS)
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove //go:embed build2
</s> add //go:embed build </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
main.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> // Embed the prebuilt client here since we strive to keep .go files inside the
<mask> // internal directory and the embed package is unable to embed files located
<mask> // outside of the same or underlying directory.
<mask>
<mask> //go:embed build2
<mask> var clientBuildFS embed.FS
<mask>
<mask> func main() {
<mask> cmd.Main(clientBuildFS)
<mask> }
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove //go:embed build build2
</s> add //go:embed build </s> remove // Go to http://127.0.0.1:80
// Go to http://127.0.0.1:3000 (BETA)
func printWebAddrs(proto, addr string, port, betaPort int) {
const (
hostMsg = "Go to %s://%s"
hostBetaMsg = hostMsg + " (BETA)"
)
log.Printf(hostMsg, proto, netutil.JoinHostPort(addr, port))
if betaPort == 0 {
return
}
log.Printf(hostBetaMsg, proto, netutil.JoinHostPort(addr, config.BetaBindPort))
</s> add // go to http://127.0.0.1:80
func printWebAddrs(proto, addr string, port int) {
log.Printf("go to %s://%s", proto, netutil.JoinHostPort(addr, port)) </s> remove // port. At least one address is printed with the value of port. If the value
// of betaPort is 0, the second address is not printed. Output example:
</s> add // port. At least one address is printed with the value of port. Output
// example: </s> remove var clientFS, clientBetaFS fs.FS
</s> add var clientFS fs.FS </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove w.installerBeta = preInstallHandler(betaClientFS)
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
main_next.go
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> 'content':
<mask> 'application/json':
<mask> 'schema':
<mask> '$ref': '#/components/schemas/LanguageSettings'
<mask> '/install/get_addresses_beta':
<mask> 'get':
<mask> 'tags':
<mask> - 'install'
<mask> 'operationId': 'installGetAddressesBeta'
<mask> 'summary': >
<mask> 'UNSTABLE!: Gets the network interfaces information.'
<mask> 'responses':
<mask> '200':
<mask> 'description': 'OK.'
<mask> 'content':
<mask> 'application/json':
<mask> 'schema':
<mask> '$ref': '#/components/schemas/AddressesInfoBeta'
<mask> '/install/get_addresses':
<mask> 'get':
<mask> 'tags':
<mask> - 'install'
<mask> 'operationId': 'installGetAddresses'
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove '/install/check_config_beta':
'post':
'tags':
- 'install'
'operationId': 'installCheckConfigBeta'
'summary': >
'UNSTABLE!: Checks configuration'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigRequestBeta'
'description': 'Configuration to be checked'
'required': true
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigResponse'
'400':
'description': >
Failed to parse JSON or cannot listen on the specified address.
</s> add </s> remove '/install/configure_beta':
'post':
'tags':
- 'install'
'operationId': 'installConfigureBeta'
'summary': >
'UNSTABLE!: Applies the initial configuration.'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/InitialConfigurationBeta'
'description': 'Initial configuration JSON'
'required': true
'responses':
'200':
'description': 'OK.'
'400':
'description': >
Failed to parse initial configuration or cannot listen to the
specified addresses.
'500':
'description': 'Cannot start the DNS server'
</s> add </s> remove 'InitialConfigurationBeta':
'type': 'object'
'description': >
AdGuard Home initial configuration for the first-install wizard.
'required':
- 'dns'
- 'web'
- 'username'
- 'password'
'properties':
'dns':
'$ref': '#/components/schemas/AddressInfoBeta'
'web':
'$ref': '#/components/schemas/AddressInfoBeta'
'username':
'type': 'string'
'description': 'Basic auth username'
'example': 'admin'
'password':
'type': 'string'
'description': 'Basic auth password'
'example': 'password'
</s> add </s> remove 'AddressesInfoBeta':
'type': 'object'
'description': 'AdGuard Home addresses configuration'
'required':
- 'dns_port'
- 'web_port'
- 'interfaces'
'properties':
'dns_port':
'type': 'integer'
'format': 'uint16'
'example': 53
'web_port':
'type': 'integer'
'format': 'uint16'
'example': 80
'interfaces':
'type': 'array'
'description': >
Network interfaces dictionary, keys are interface names.
'items':
'$ref': '#/components/schemas/NetInterface'
</s> add </s> remove 'CheckConfigRequestBeta':
'type': 'object'
'description': 'Configuration to be checked'
'properties':
'dns':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'web':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'set_static_ip':
'type': 'boolean'
'example': false
</s> add </s> remove 'AddressInfoBeta':
'type': 'object'
'description': 'Port information'
'required':
- 'ip'
- 'port'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
openapi/openapi.yaml
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> 'content':
<mask> 'application/json':
<mask> 'schema':
<mask> '$ref': '#/components/schemas/AddressesInfo'
<mask> '/install/check_config_beta':
<mask> 'post':
<mask> 'tags':
<mask> - 'install'
<mask> 'operationId': 'installCheckConfigBeta'
<mask> 'summary': >
<mask> 'UNSTABLE!: Checks configuration'
<mask> 'requestBody':
<mask> 'content':
<mask> 'application/json':
<mask> 'schema':
<mask> '$ref': '#/components/schemas/CheckConfigRequestBeta'
<mask> 'description': 'Configuration to be checked'
<mask> 'required': true
<mask> 'responses':
<mask> '200':
<mask> 'description': 'OK.'
<mask> 'content':
<mask> 'application/json':
<mask> 'schema':
<mask> '$ref': '#/components/schemas/CheckConfigResponse'
<mask> '400':
<mask> 'description': >
<mask> Failed to parse JSON or cannot listen on the specified address.
<mask> '/install/check_config':
<mask> 'post':
<mask> 'tags':
<mask> - 'install'
<mask> 'operationId': 'installCheckConfig'
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove '/install/configure_beta':
'post':
'tags':
- 'install'
'operationId': 'installConfigureBeta'
'summary': >
'UNSTABLE!: Applies the initial configuration.'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/InitialConfigurationBeta'
'description': 'Initial configuration JSON'
'required': true
'responses':
'200':
'description': 'OK.'
'400':
'description': >
Failed to parse initial configuration or cannot listen to the
specified addresses.
'500':
'description': 'Cannot start the DNS server'
</s> add </s> remove '/install/get_addresses_beta':
'get':
'tags':
- 'install'
'operationId': 'installGetAddressesBeta'
'summary': >
'UNSTABLE!: Gets the network interfaces information.'
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/AddressesInfoBeta'
</s> add </s> remove 'CheckConfigRequestBeta':
'type': 'object'
'description': 'Configuration to be checked'
'properties':
'dns':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'web':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'set_static_ip':
'type': 'boolean'
'example': false
</s> add </s> remove 'InitialConfigurationBeta':
'type': 'object'
'description': >
AdGuard Home initial configuration for the first-install wizard.
'required':
- 'dns'
- 'web'
- 'username'
- 'password'
'properties':
'dns':
'$ref': '#/components/schemas/AddressInfoBeta'
'web':
'$ref': '#/components/schemas/AddressInfoBeta'
'username':
'type': 'string'
'description': 'Basic auth username'
'example': 'admin'
'password':
'type': 'string'
'description': 'Basic auth password'
'example': 'password'
</s> add </s> remove 'AddressesInfoBeta':
'type': 'object'
'description': 'AdGuard Home addresses configuration'
'required':
- 'dns_port'
- 'web_port'
- 'interfaces'
'properties':
'dns_port':
'type': 'integer'
'format': 'uint16'
'example': 53
'web_port':
'type': 'integer'
'format': 'uint16'
'example': 80
'interfaces':
'type': 'array'
'description': >
Network interfaces dictionary, keys are interface names.
'items':
'$ref': '#/components/schemas/NetInterface'
</s> add </s> remove 'AddressInfoBeta':
'type': 'object'
'description': 'Port information'
'required':
- 'ip'
- 'port'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
openapi/openapi.yaml
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> '$ref': '#/components/schemas/CheckConfigResponse'
<mask> '400':
<mask> 'description': >
<mask> Failed to parse JSON or cannot listen on the specified address.
<mask> '/install/configure_beta':
<mask> 'post':
<mask> 'tags':
<mask> - 'install'
<mask> 'operationId': 'installConfigureBeta'
<mask> 'summary': >
<mask> 'UNSTABLE!: Applies the initial configuration.'
<mask> 'requestBody':
<mask> 'content':
<mask> 'application/json':
<mask> 'schema':
<mask> '$ref': '#/components/schemas/InitialConfigurationBeta'
<mask> 'description': 'Initial configuration JSON'
<mask> 'required': true
<mask> 'responses':
<mask> '200':
<mask> 'description': 'OK.'
<mask> '400':
<mask> 'description': >
<mask> Failed to parse initial configuration or cannot listen to the
<mask> specified addresses.
<mask> '500':
<mask> 'description': 'Cannot start the DNS server'
<mask> '/install/configure':
<mask> 'post':
<mask> 'tags':
<mask> - 'install'
<mask> 'operationId': 'installConfigure'
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove '/install/check_config_beta':
'post':
'tags':
- 'install'
'operationId': 'installCheckConfigBeta'
'summary': >
'UNSTABLE!: Checks configuration'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigRequestBeta'
'description': 'Configuration to be checked'
'required': true
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigResponse'
'400':
'description': >
Failed to parse JSON or cannot listen on the specified address.
</s> add </s> remove '/install/get_addresses_beta':
'get':
'tags':
- 'install'
'operationId': 'installGetAddressesBeta'
'summary': >
'UNSTABLE!: Gets the network interfaces information.'
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/AddressesInfoBeta'
</s> add </s> remove 'InitialConfigurationBeta':
'type': 'object'
'description': >
AdGuard Home initial configuration for the first-install wizard.
'required':
- 'dns'
- 'web'
- 'username'
- 'password'
'properties':
'dns':
'$ref': '#/components/schemas/AddressInfoBeta'
'web':
'$ref': '#/components/schemas/AddressInfoBeta'
'username':
'type': 'string'
'description': 'Basic auth username'
'example': 'admin'
'password':
'type': 'string'
'description': 'Basic auth password'
'example': 'password'
</s> add </s> remove 'AddressesInfoBeta':
'type': 'object'
'description': 'AdGuard Home addresses configuration'
'required':
- 'dns_port'
- 'web_port'
- 'interfaces'
'properties':
'dns_port':
'type': 'integer'
'format': 'uint16'
'example': 53
'web_port':
'type': 'integer'
'format': 'uint16'
'example': 80
'interfaces':
'type': 'array'
'description': >
Network interfaces dictionary, keys are interface names.
'items':
'$ref': '#/components/schemas/NetInterface'
</s> add </s> remove 'CheckConfigRequestBeta':
'type': 'object'
'description': 'Configuration to be checked'
'properties':
'dns':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'web':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'set_static_ip':
'type': 'boolean'
'example': false
</s> add </s> remove 'AddressInfoBeta':
'type': 'object'
'description': 'Port information'
'required':
- 'ip'
- 'port'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
openapi/openapi.yaml
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> 'items':
<mask> 'type': 'string'
<mask> 'mtu':
<mask> 'type': 'integer'
<mask> 'AddressInfoBeta':
<mask> 'type': 'object'
<mask> 'description': 'Port information'
<mask> 'required':
<mask> - 'ip'
<mask> - 'port'
<mask> 'properties':
<mask> 'ip':
<mask> 'type': 'array'
<mask> 'items':
<mask> 'type': 'string'
<mask> 'minItems': 1
<mask> 'example':
<mask> - '127.0.0.1'
<mask> 'port':
<mask> 'type': 'integer'
<mask> 'format': 'uint16'
<mask> 'example': 53
<mask> 'AddressInfo':
<mask> 'type': 'object'
<mask> 'description': 'Port information'
<mask> 'required':
<mask> - 'ip'
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove 'CheckConfigRequestInfoBeta':
'type': 'object'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
'autofix':
'type': 'boolean'
'example': false
</s> add </s> remove 'AddressesInfoBeta':
'type': 'object'
'description': 'AdGuard Home addresses configuration'
'required':
- 'dns_port'
- 'web_port'
- 'interfaces'
'properties':
'dns_port':
'type': 'integer'
'format': 'uint16'
'example': 53
'web_port':
'type': 'integer'
'format': 'uint16'
'example': 80
'interfaces':
'type': 'array'
'description': >
Network interfaces dictionary, keys are interface names.
'items':
'$ref': '#/components/schemas/NetInterface'
</s> add </s> remove 'InitialConfigurationBeta':
'type': 'object'
'description': >
AdGuard Home initial configuration for the first-install wizard.
'required':
- 'dns'
- 'web'
- 'username'
- 'password'
'properties':
'dns':
'$ref': '#/components/schemas/AddressInfoBeta'
'web':
'$ref': '#/components/schemas/AddressInfoBeta'
'username':
'type': 'string'
'description': 'Basic auth username'
'example': 'admin'
'password':
'type': 'string'
'description': 'Basic auth password'
'example': 'password'
</s> add </s> remove 'CheckConfigRequestBeta':
'type': 'object'
'description': 'Configuration to be checked'
'properties':
'dns':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'web':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'set_static_ip':
'type': 'boolean'
'example': false
</s> add </s> remove '/install/check_config_beta':
'post':
'tags':
- 'install'
'operationId': 'installCheckConfigBeta'
'summary': >
'UNSTABLE!: Checks configuration'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigRequestBeta'
'description': 'Configuration to be checked'
'required': true
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigResponse'
'400':
'description': >
Failed to parse JSON or cannot listen on the specified address.
</s> add </s> remove '/install/configure_beta':
'post':
'tags':
- 'install'
'operationId': 'installConfigureBeta'
'summary': >
'UNSTABLE!: Applies the initial configuration.'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/InitialConfigurationBeta'
'description': 'Initial configuration JSON'
'required': true
'responses':
'200':
'description': 'OK.'
'400':
'description': >
Failed to parse initial configuration or cannot listen to the
specified addresses.
'500':
'description': 'Cannot start the DNS server'
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
openapi/openapi.yaml
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> 'web_port':
<mask> 'type': 'integer'
<mask> 'format': 'uint16'
<mask> 'example': 80
<mask> 'AddressesInfoBeta':
<mask> 'type': 'object'
<mask> 'description': 'AdGuard Home addresses configuration'
<mask> 'required':
<mask> - 'dns_port'
<mask> - 'web_port'
<mask> - 'interfaces'
<mask> 'properties':
<mask> 'dns_port':
<mask> 'type': 'integer'
<mask> 'format': 'uint16'
<mask> 'example': 53
<mask> 'web_port':
<mask> 'type': 'integer'
<mask> 'format': 'uint16'
<mask> 'example': 80
<mask> 'interfaces':
<mask> 'type': 'array'
<mask> 'description': >
<mask> Network interfaces dictionary, keys are interface names.
<mask> 'items':
<mask> '$ref': '#/components/schemas/NetInterface'
<mask> 'ProfileInfo':
<mask> 'type': 'object'
<mask> 'description': 'Information about the current user'
<mask> 'properties':
<mask> 'name':
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove 'AddressInfoBeta':
'type': 'object'
'description': 'Port information'
'required':
- 'ip'
- 'port'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
</s> add </s> remove 'CheckConfigRequestInfoBeta':
'type': 'object'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
'autofix':
'type': 'boolean'
'example': false
</s> add </s> remove 'InitialConfigurationBeta':
'type': 'object'
'description': >
AdGuard Home initial configuration for the first-install wizard.
'required':
- 'dns'
- 'web'
- 'username'
- 'password'
'properties':
'dns':
'$ref': '#/components/schemas/AddressInfoBeta'
'web':
'$ref': '#/components/schemas/AddressInfoBeta'
'username':
'type': 'string'
'description': 'Basic auth username'
'example': 'admin'
'password':
'type': 'string'
'description': 'Basic auth password'
'example': 'password'
</s> add </s> remove 'CheckConfigRequestBeta':
'type': 'object'
'description': 'Configuration to be checked'
'properties':
'dns':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'web':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'set_static_ip':
'type': 'boolean'
'example': false
</s> add </s> remove '/install/check_config_beta':
'post':
'tags':
- 'install'
'operationId': 'installCheckConfigBeta'
'summary': >
'UNSTABLE!: Checks configuration'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigRequestBeta'
'description': 'Configuration to be checked'
'required': true
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigResponse'
'400':
'description': >
Failed to parse JSON or cannot listen on the specified address.
</s> add </s> remove '/install/configure_beta':
'post':
'tags':
- 'install'
'operationId': 'installConfigureBeta'
'summary': >
'UNSTABLE!: Applies the initial configuration.'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/InitialConfigurationBeta'
'description': 'Initial configuration JSON'
'required': true
'responses':
'200':
'description': 'OK.'
'400':
'description': >
Failed to parse initial configuration or cannot listen to the
specified addresses.
'500':
'description': 'Cannot start the DNS server'
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
openapi/openapi.yaml
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> - 'id'
<mask> - 'name'
<mask> - 'rules'
<mask> 'type': 'object'
<mask> 'CheckConfigRequestBeta':
<mask> 'type': 'object'
<mask> 'description': 'Configuration to be checked'
<mask> 'properties':
<mask> 'dns':
<mask> '$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
<mask> 'web':
<mask> '$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
<mask> 'set_static_ip':
<mask> 'type': 'boolean'
<mask> 'example': false
<mask> 'CheckConfigRequest':
<mask> 'type': 'object'
<mask> 'description': 'Configuration to be checked'
<mask> 'properties':
<mask> 'dns':
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove 'CheckConfigRequestInfoBeta':
'type': 'object'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
'autofix':
'type': 'boolean'
'example': false
</s> add </s> remove 'InitialConfigurationBeta':
'type': 'object'
'description': >
AdGuard Home initial configuration for the first-install wizard.
'required':
- 'dns'
- 'web'
- 'username'
- 'password'
'properties':
'dns':
'$ref': '#/components/schemas/AddressInfoBeta'
'web':
'$ref': '#/components/schemas/AddressInfoBeta'
'username':
'type': 'string'
'description': 'Basic auth username'
'example': 'admin'
'password':
'type': 'string'
'description': 'Basic auth password'
'example': 'password'
</s> add </s> remove 'AddressesInfoBeta':
'type': 'object'
'description': 'AdGuard Home addresses configuration'
'required':
- 'dns_port'
- 'web_port'
- 'interfaces'
'properties':
'dns_port':
'type': 'integer'
'format': 'uint16'
'example': 53
'web_port':
'type': 'integer'
'format': 'uint16'
'example': 80
'interfaces':
'type': 'array'
'description': >
Network interfaces dictionary, keys are interface names.
'items':
'$ref': '#/components/schemas/NetInterface'
</s> add </s> remove 'AddressInfoBeta':
'type': 'object'
'description': 'Port information'
'required':
- 'ip'
- 'port'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
</s> add </s> remove '/install/check_config_beta':
'post':
'tags':
- 'install'
'operationId': 'installCheckConfigBeta'
'summary': >
'UNSTABLE!: Checks configuration'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigRequestBeta'
'description': 'Configuration to be checked'
'required': true
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigResponse'
'400':
'description': >
Failed to parse JSON or cannot listen on the specified address.
</s> add </s> remove '/install/configure_beta':
'post':
'tags':
- 'install'
'operationId': 'installConfigureBeta'
'summary': >
'UNSTABLE!: Applies the initial configuration.'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/InitialConfigurationBeta'
'description': 'Initial configuration JSON'
'required': true
'responses':
'200':
'description': 'OK.'
'400':
'description': >
Failed to parse initial configuration or cannot listen to the
specified addresses.
'500':
'description': 'Cannot start the DNS server'
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
openapi/openapi.yaml
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> '$ref': '#/components/schemas/CheckConfigRequestInfo'
<mask> 'set_static_ip':
<mask> 'type': 'boolean'
<mask> 'example': false
<mask> 'CheckConfigRequestInfoBeta':
<mask> 'type': 'object'
<mask> 'properties':
<mask> 'ip':
<mask> 'type': 'array'
<mask> 'items':
<mask> 'type': 'string'
<mask> 'minItems': 1
<mask> 'example':
<mask> - '127.0.0.1'
<mask> 'port':
<mask> 'type': 'integer'
<mask> 'format': 'uint16'
<mask> 'example': 53
<mask> 'autofix':
<mask> 'type': 'boolean'
<mask> 'example': false
<mask> 'CheckConfigRequestInfo':
<mask> 'type': 'object'
<mask> 'properties':
<mask> 'ip':
<mask> 'type': 'string'
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove 'AddressInfoBeta':
'type': 'object'
'description': 'Port information'
'required':
- 'ip'
- 'port'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
</s> add </s> remove 'AddressesInfoBeta':
'type': 'object'
'description': 'AdGuard Home addresses configuration'
'required':
- 'dns_port'
- 'web_port'
- 'interfaces'
'properties':
'dns_port':
'type': 'integer'
'format': 'uint16'
'example': 53
'web_port':
'type': 'integer'
'format': 'uint16'
'example': 80
'interfaces':
'type': 'array'
'description': >
Network interfaces dictionary, keys are interface names.
'items':
'$ref': '#/components/schemas/NetInterface'
</s> add </s> remove 'CheckConfigRequestBeta':
'type': 'object'
'description': 'Configuration to be checked'
'properties':
'dns':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'web':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'set_static_ip':
'type': 'boolean'
'example': false
</s> add </s> remove 'InitialConfigurationBeta':
'type': 'object'
'description': >
AdGuard Home initial configuration for the first-install wizard.
'required':
- 'dns'
- 'web'
- 'username'
- 'password'
'properties':
'dns':
'$ref': '#/components/schemas/AddressInfoBeta'
'web':
'$ref': '#/components/schemas/AddressInfoBeta'
'username':
'type': 'string'
'description': 'Basic auth username'
'example': 'admin'
'password':
'type': 'string'
'description': 'Basic auth password'
'example': 'password'
</s> add </s> remove '/install/get_addresses_beta':
'get':
'tags':
- 'install'
'operationId': 'installGetAddressesBeta'
'summary': >
'UNSTABLE!: Gets the network interfaces information.'
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/AddressesInfoBeta'
</s> add </s> remove '/install/check_config_beta':
'post':
'tags':
- 'install'
'operationId': 'installCheckConfigBeta'
'summary': >
'UNSTABLE!: Checks configuration'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigRequestBeta'
'description': 'Configuration to be checked'
'required': true
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigResponse'
'400':
'description': >
Failed to parse JSON or cannot listen on the specified address.
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
openapi/openapi.yaml
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> 'error':
<mask> 'type': 'string'
<mask> 'default': ''
<mask> 'description': 'Error text. Set if static=error'
<mask> 'InitialConfigurationBeta':
<mask> 'type': 'object'
<mask> 'description': >
<mask> AdGuard Home initial configuration for the first-install wizard.
<mask> 'required':
<mask> - 'dns'
<mask> - 'web'
<mask> - 'username'
<mask> - 'password'
<mask> 'properties':
<mask> 'dns':
<mask> '$ref': '#/components/schemas/AddressInfoBeta'
<mask> 'web':
<mask> '$ref': '#/components/schemas/AddressInfoBeta'
<mask> 'username':
<mask> 'type': 'string'
<mask> 'description': 'Basic auth username'
<mask> 'example': 'admin'
<mask> 'password':
<mask> 'type': 'string'
<mask> 'description': 'Basic auth password'
<mask> 'example': 'password'
<mask> 'InitialConfiguration':
<mask> 'type': 'object'
<mask> 'description': >
<mask> AdGuard Home initial configuration for the first-install wizard.
<mask> 'required':
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove 'AddressInfoBeta':
'type': 'object'
'description': 'Port information'
'required':
- 'ip'
- 'port'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
</s> add </s> remove 'AddressesInfoBeta':
'type': 'object'
'description': 'AdGuard Home addresses configuration'
'required':
- 'dns_port'
- 'web_port'
- 'interfaces'
'properties':
'dns_port':
'type': 'integer'
'format': 'uint16'
'example': 53
'web_port':
'type': 'integer'
'format': 'uint16'
'example': 80
'interfaces':
'type': 'array'
'description': >
Network interfaces dictionary, keys are interface names.
'items':
'$ref': '#/components/schemas/NetInterface'
</s> add </s> remove 'CheckConfigRequestBeta':
'type': 'object'
'description': 'Configuration to be checked'
'properties':
'dns':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'web':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'set_static_ip':
'type': 'boolean'
'example': false
</s> add </s> remove 'CheckConfigRequestInfoBeta':
'type': 'object'
'properties':
'ip':
'type': 'array'
'items':
'type': 'string'
'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53
'autofix':
'type': 'boolean'
'example': false
</s> add </s> remove '/install/configure_beta':
'post':
'tags':
- 'install'
'operationId': 'installConfigureBeta'
'summary': >
'UNSTABLE!: Applies the initial configuration.'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/InitialConfigurationBeta'
'description': 'Initial configuration JSON'
'required': true
'responses':
'200':
'description': 'OK.'
'400':
'description': >
Failed to parse initial configuration or cannot listen to the
specified addresses.
'500':
'description': 'Cannot start the DNS server'
</s> add </s> remove '/install/check_config_beta':
'post':
'tags':
- 'install'
'operationId': 'installCheckConfigBeta'
'summary': >
'UNSTABLE!: Checks configuration'
'requestBody':
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigRequestBeta'
'description': 'Configuration to be checked'
'required': true
'responses':
'200':
'description': 'OK.'
'content':
'application/json':
'schema':
'$ref': '#/components/schemas/CheckConfigResponse'
'400':
'description': >
Failed to parse JSON or cannot listen on the specified address.
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
openapi/openapi.yaml
|
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
|
<mask> then
<mask> make VERBOSE="$verbose" js-lint js-test
<mask> fi
<mask>
<mask> if [ "$( git diff --cached --name-only -- 'client2/*.js' 'client2/*.ts' 'client2/*.tsx' )" ]
<mask> then
<mask> make VERBOSE="$verbose" js-beta-lint js-beta-test
<mask> fi
<mask>
<mask> if [ "$( git diff --cached --name-only -- '*.go' '*.mod' '*.sh' 'Makefile' )" ]
<mask> then
<mask> make VERBOSE="$verbose" go-os-check go-lint go-test
<mask> fi
<mask>
</s> Pull request 1717: remove-client2
Merge in DNS/adguard-home from remove-client2 to master
Squashed commit of the following:
commit 0a0923494b0d1003e4f02f3a5f93d5248f0f2ded
Author: Ainar Garipov <[email protected]>
Date: Fri Jan 20 17:14:29 2023 +0300
all: rm old experimental beta (dir client2/)
This project was unfortunately abandoned. v0.108.0 will have a
different front-end and new APIs. </s> remove addPorts(tcpPorts, tcpPort(config.BetaBindPort), port)
</s> add addPorts(tcpPorts, port) </s> remove $(YARN) $(YARN_FLAGS) build
</s> add </s> remove CLIENT_BETA_DIR = client2
</s> add </s> remove addPorts(tcpPorts, tcpPort(opts.bindPort), tcpPort(config.BetaBindPort))
</s> add addPorts(tcpPorts, tcpPort(opts.bindPort)) </s> remove clientBetaFS = os.DirFS("build2/static")
</s> add </s> remove tcpPort(config.BetaBindPort),
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54a141abdeca00005a75f4af141645520b3f6b52
|
scripts/hooks/pre-commit
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> for i := range config.Filters {
<mask>
<mask> filter := &config.Filters[i] // otherwise we will be operating on a copy
<mask>
<mask> log.Printf("Seting ID=%d for filter %s", i, filter.URL)
<mask> filter.ID = i + 1 // start with ID=1
<mask>
<mask> // Forcibly update the filter
<mask> _, err := filter.update(true)
<mask> if err != nil {
<mask> log.Fatal(err)
</s> Fix review comments: NextFilterId collisions </s> remove coreDnsPlugin.Reload <- true
</s> add corednsplugin.Reload <- true </s> remove filterId, err := strconv.Atoi(c.Val())
</s> add filterId, err := strconv.ParseInt(c.Val(), 10, 64) </s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix() </s> add // User filter ID is always 0
const UserFilterId = 0
</s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error { </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
app.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> package main
<mask>
<mask> import (
<mask> "bytes"
<mask> "gopkg.in/yaml.v2"
<mask> "io/ioutil"
<mask> "log"
<mask> "os"
<mask> "path/filepath"
<mask> "regexp"
</s> Fix review comments: NextFilterId collisions </s> add "gopkg.in/yaml.v2" </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool { </s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error { </s> add // User filter ID is always 0
const UserFilterId = 0
</s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix() </s> remove ID int `yaml:"-"`
</s> add ID int64 `yaml:"-"`
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
config.go
|
keep keep keep add keep keep keep keep keep
|
<mask> "regexp"
<mask> "sync"
<mask> "text/template"
<mask> "time"
<mask> )
<mask>
<mask> // Current schema version. We compare it with the value from
<mask> // the configuration file and perform necessary upgrade operations if needed
<mask> const SchemaVersion = 1
</s> Fix review comments: NextFilterId collisions </s> add // User filter ID is always 0
const UserFilterId = 0
</s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix() </s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error { </s> remove coreDnsPlugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin"
</s> add corednsplugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin" </s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++ </s> remove ID: uint32(filterId),
</s> add ID: filterId,
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
config.go
|
keep add keep keep keep keep
|
<mask> const FiltersDir = "filters"
<mask>
<mask> // Just a counter that we use for incrementing the filter ID
<mask> var NextFilterId = time.Now().Unix()
<mask>
<mask> // configuration is loaded from YAML
</s> Fix review comments: NextFilterId collisions </s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix() </s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++ </s> add "gopkg.in/yaml.v2" </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to </s> remove ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
</s> add ID int64 `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error {
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
config.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> // Directory where we'll store all downloaded filters contents
<mask> const FiltersDir = "filters"
<mask>
<mask> // Just a counter that we use for incrementing the filter ID
<mask> var NextFilterId int
<mask>
<mask> // configuration is loaded from YAML
<mask> type configuration struct {
<mask> // Config filename (can be overriden via the command line arguments)
<mask> ourConfigFilename string
</s> Fix review comments: NextFilterId collisions </s> add // User filter ID is always 0
const UserFilterId = 0
</s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++ </s> remove ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
</s> add ID int64 `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> add "gopkg.in/yaml.v2" </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to </s> remove ID int `yaml:"-"`
</s> add ID int64 `yaml:"-"`
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
config.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> sync.RWMutex `yaml:"-"`
<mask> }
<mask>
<mask> type coreDnsFilter struct {
<mask> ID int `yaml:"-"`
<mask> Path string `yaml:"-"`
<mask> }
<mask>
<mask> type coreDNSConfig struct {
<mask> binaryFile string
</s> Fix review comments: NextFilterId collisions </s> remove ID uint32
</s> add ID int64 </s> remove ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
</s> add ID int64 `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix() </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt") </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool { </s> remove coreDnsPlugin.Reload <- true
</s> add corednsplugin.Reload <- true
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
config.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> UpstreamDNS []string `yaml:"upstream_dns"`
<mask> }
<mask>
<mask> type filter struct {
<mask> ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
<mask> URL string `json:"url"`
<mask> Name string `json:"name" yaml:"name"`
<mask> Enabled bool `json:"enabled"`
<mask> RulesCount int `json:"rulesCount" yaml:"-"`
<mask> contents []byte
</s> Fix review comments: NextFilterId collisions </s> remove ID int `yaml:"-"`
</s> add ID int64 `yaml:"-"` </s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix() </s> remove ID uint32
</s> add ID int64 </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt") </s> add // User filter ID is always 0
const UserFilterId = 0
</s> remove listID uint32
</s> add listID int64
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
config.go
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> contents = append(contents, '\n')
<mask> }
<mask>
<mask> userFilter := filter{
<mask> // User filter always has ID=0
<mask> ID: 0,
<mask> contents: contents,
<mask> Enabled: true,
<mask> }
<mask>
<mask> return userFilter
</s> Fix review comments: NextFilterId collisions </s> add // User filter ID is always 0
const UserFilterId = 0
</s> remove ID: uint32(filterId),
</s> add ID: filterId, </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt") </s> remove ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
</s> add ID int64 `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++ </s> remove filterId, err := strconv.Atoi(c.Val())
</s> add filterId, err := strconv.ParseInt(c.Val(), 10, 64)
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
config.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> "strconv"
<mask> "strings"
<mask> "time"
<mask>
<mask> coreDnsPlugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin"
<mask> "github.com/miekg/dns"
<mask> "gopkg.in/asaskevich/govalidator.v4"
<mask> )
<mask>
<mask> const updatePeriod = time.Minute * 30
</s> Fix review comments: NextFilterId collisions </s> add "gopkg.in/yaml.v2" </s> remove ID uint32
</s> add ID int64 </s> add // User filter ID is always 0
const UserFilterId = 0
</s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix() </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool { </s> remove "gopkg.in/yaml.v2"
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
control.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> // -------------------
<mask> // coredns run control
<mask> // -------------------
<mask> func tellCoreDNSToReload() {
<mask> coreDnsPlugin.Reload <- true
<mask> }
<mask>
<mask> func writeAllConfigsAndReloadCoreDNS() error {
<mask> err := writeAllConfigs()
<mask> if err != nil {
</s> Fix review comments: NextFilterId collisions </s> remove filterId, err := strconv.Atoi(c.Val())
</s> add filterId, err := strconv.ParseInt(c.Val(), 10, 64) </s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++ </s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error { </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool { </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt") </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
control.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask>
<mask> // Path to the filter contents
<mask> func (filter *filter) getFilterFilePath() string {
<mask> return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
<mask> }
<mask>
<mask> // ------------
<mask> // safebrowsing
<mask> // ------------
</s> Fix review comments: NextFilterId collisions </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to </s> remove // User filter always has ID=0
ID: 0,
</s> add // User filter always has constant ID=0
ID: UserFilterId, </s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix() </s> remove coreDnsPlugin.Reload <- true
</s> add corednsplugin.Reload <- true </s> remove ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
</s> add ID int64 `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool {
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
control.go
|
keep keep keep replace keep keep keep keep replace replace replace replace
|
<mask> http.HandleFunc("/control/status", optionalAuth(ensureGET(handleStatus)))
<mask> http.HandleFunc("/control/enable_protection", optionalAuth(ensurePOST(handleProtectionEnable)))
<mask> http.HandleFunc("/control/disable_protection", optionalAuth(ensurePOST(handleProtectionDisable)))
<mask> http.HandleFunc("/control/querylog", optionalAuth(ensureGET(coreDnsPlugin.HandleQueryLog)))
<mask> http.HandleFunc("/control/querylog_enable", optionalAuth(ensurePOST(handleQueryLogEnable)))
<mask> http.HandleFunc("/control/querylog_disable", optionalAuth(ensurePOST(handleQueryLogDisable)))
<mask> http.HandleFunc("/control/set_upstream_dns", optionalAuth(ensurePOST(handleSetUpstreamDNS)))
<mask> http.HandleFunc("/control/test_upstream_dns", optionalAuth(ensurePOST(handleTestUpstreamDNS)))
<mask> http.HandleFunc("/control/stats_top", optionalAuth(ensureGET(coreDnsPlugin.HandleStatsTop)))
<mask> http.HandleFunc("/control/stats", optionalAuth(ensureGET(coreDnsPlugin.HandleStats)))
<mask> http.HandleFunc("/control/stats_history", optionalAuth(ensureGET(coreDnsPlugin.HandleStatsHistory)))
<mask> http.HandleFunc("/control/stats_reset", optionalAuth(ensurePOST(coreDnsPlugin.HandleStatsReset)))
</s> Fix review comments: NextFilterId collisions </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool { </s> remove coreDnsPlugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin"
</s> add corednsplugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin" </s> remove "gopkg.in/yaml.v2"
</s> add </s> add "gopkg.in/yaml.v2" </s> add // User filter ID is always 0
const UserFilterId = 0
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
control.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> lookupCache = map[string]cacheEntry{}
<mask> )
<mask>
<mask> type plugFilter struct {
<mask> ID uint32
<mask> Path string
<mask> }
<mask>
<mask> type plugSettings struct {
<mask> SafeBrowsingBlockHost string
</s> Fix review comments: NextFilterId collisions </s> remove ID int `yaml:"-"`
</s> add ID int64 `yaml:"-"` </s> remove ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
</s> add ID int64 `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix() </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt") </s> remove listID uint32
</s> add listID int64 </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
coredns_plugin/coredns_plugin.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> if !c.NextArg() {
<mask> return nil, c.ArgErr()
<mask> }
<mask>
<mask> filterId, err := strconv.Atoi(c.Val())
<mask> if err != nil {
<mask> return nil, c.ArgErr()
<mask> }
<mask> if !c.NextArg() {
<mask> return nil, c.ArgErr()
</s> Fix review comments: NextFilterId collisions </s> remove coreDnsPlugin.Reload <- true
</s> add corednsplugin.Reload <- true </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool { </s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++ </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt") </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to </s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error {
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
coredns_plugin/coredns_plugin.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> filterPath := c.Val()
<mask>
<mask> // Initialize filter and add it to the list
<mask> p.settings.Filters = append(p.settings.Filters, plugFilter{
<mask> ID: uint32(filterId),
<mask> Path: filterPath,
<mask> })
<mask> }
<mask> }
<mask> }
</s> Fix review comments: NextFilterId collisions </s> remove // User filter always has ID=0
ID: 0,
</s> add // User filter always has constant ID=0
ID: UserFilterId, </s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error { </s> add "gopkg.in/yaml.v2" </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt") </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to </s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
coredns_plugin/coredns_plugin.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> isWhitelist bool
<mask> isImportant bool
<mask>
<mask> // user-supplied data
<mask> listID uint32
<mask>
<mask> // suffix matching
<mask> isSuffix bool
<mask> suffix string
<mask>
</s> Fix review comments: NextFilterId collisions </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool { </s> remove ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
</s> add ID int64 `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error { </s> remove ID uint32
</s> add ID int64 </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt")
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
dnsfilter/dnsfilter.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> IsFiltered bool `json:",omitempty"` // True if the host name is filtered
<mask> Reason Reason `json:",omitempty"` // Reason for blocking / unblocking
<mask> Rule string `json:",omitempty"` // Original rule text
<mask> Ip net.IP `json:",omitempty"` // Not nil only in the case of a hosts file syntax
<mask> FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
<mask> }
<mask>
<mask> // Matched can be used to see if any match at all was found, no matter filtered or not
<mask> func (r Reason) Matched() bool {
<mask> return r != NotFilteredNotFound
</s> Fix review comments: NextFilterId collisions </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool { </s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error { </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt") </s> remove listID uint32
</s> add listID int64 </s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++ </s> remove var NextFilterId int
</s> add var NextFilterId = time.Now().Unix()
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
dnsfilter/dnsfilter.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> // Adding rule and matching against the rules
<mask> //
<mask>
<mask> // AddRule adds a rule, checking if it is a valid rule first and if it wasn't added already
<mask> func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
<mask> input = strings.TrimSpace(input)
<mask> d.storageMutex.RLock()
<mask> _, exists := d.storage[input]
<mask> d.storageMutex.RUnlock()
<mask> if exists {
</s> Fix review comments: NextFilterId collisions </s> remove func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
</s> add func (d *Dnsfilter) parseEtcHosts(input string, filterListID int64) bool { </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to </s> add "gopkg.in/yaml.v2" </s> remove coreDnsPlugin.Reload <- true
</s> add corednsplugin.Reload <- true </s> remove ID: uint32(filterId),
</s> add ID: filterId, </s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
dnsfilter/dnsfilter.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> return nil
<mask> }
<mask>
<mask> // Parses the hosts-syntax rules. Returns false if the input string is not of hosts-syntax.
<mask> func (d *Dnsfilter) parseEtcHosts(input string, filterListID uint32) bool {
<mask> // Strip the trailing comment
<mask> ruleText := input
<mask> if pos := strings.IndexByte(ruleText, '#'); pos != -1 {
<mask> ruleText = ruleText[0:pos]
<mask> }
</s> Fix review comments: NextFilterId collisions </s> remove func (d *Dnsfilter) AddRule(input string, filterListID uint32) error {
</s> add func (d *Dnsfilter) AddRule(input string, filterListID int64) error { </s> remove FilterID uint32 `json:",omitempty"` // Filter ID the rule belongs to
</s> add FilterID int64 `json:",omitempty"` // Filter ID the rule belongs to </s> remove coreDnsPlugin.Reload <- true
</s> add corednsplugin.Reload <- true </s> remove filterId, err := strconv.Atoi(c.Val())
</s> add filterId, err := strconv.ParseInt(c.Val(), 10, 64) </s> remove log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
</s> add // Set the filter ID
log.Printf("Seting ID=%d for filter %s", NextFilterId, filter.URL)
filter.ID = NextFilterId
NextFilterId++ </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
</s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.FormatInt(filter.ID, 10)+".txt")
|
https://github.com/AdguardTeam/AdGuardHome/commit/54bdacdde282a4b9b7dde55df7ed4aeda3df375d
|
dnsfilter/dnsfilter.go
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> "strings"
<mask> "sync"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghio"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // systemResolvers implementation differs for Windows since Go's resolver
</s> Pull request: 3457 fix service reload
Merge in DNS/adguard-home from 3457-darwin-svc-reload to master
Closes #3457.
Squashed commit of the following:
commit e3d6fbccf8373194360b6480e2d702ccd0ec7107
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 18 00:52:39 2021 +0300
aghos: imp docs
commit 220d37ebc1e0c2e9ba37a34650bff1480bd2fcf6
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 17 15:45:52 2021 +0300
all: fix ps </s> remove "syscall"
</s> add "strconv"
"strings"
"github.com/AdguardTeam/golibs/log" </s> add "path" </s> remove "syscall"
</s> add </s> add "io" </s> remove log.Debug("Sent signal to PID %d", pid)
</s> add log.Debug("sent signal to PID %d", pid) </s> remove // SendProcessSignal sends signal to a process.
func SendProcessSignal(pid int, sig syscall.Signal) error {
return sendProcessSignal(pid, sig)
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/550b1798a169d07139f8f079bc5c83271a181f7f
|
internal/aghnet/systemresolvers_windows.go
|
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
|
<mask> if err != nil {
<mask> return nil, fmt.Errorf("getting the command's stdout pipe: %w", err)
<mask> }
<mask>
<mask> var stdoutLimited io.Reader
<mask> stdoutLimited, err = aghio.LimitReader(stdout, aghos.MaxCmdOutputSize)
<mask> if err != nil {
<mask> return nil, fmt.Errorf("limiting stdout reader: %w", err)
<mask> }
<mask>
<mask> go writeExit(stdin)
<mask>
<mask> err = cmd.Start()
<mask> if err != nil {
<mask> return nil, fmt.Errorf("start command executing: %w", err)
</s> Pull request: 3457 fix service reload
Merge in DNS/adguard-home from 3457-darwin-svc-reload to master
Closes #3457.
Squashed commit of the following:
commit e3d6fbccf8373194360b6480e2d702ccd0ec7107
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 18 00:52:39 2021 +0300
aghos: imp docs
commit 220d37ebc1e0c2e9ba37a34650bff1480bd2fcf6
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 17 15:45:52 2021 +0300
all: fix ps </s> remove s := bufio.NewScanner(stdoutLimited)
</s> add s := bufio.NewScanner(stdout) </s> remove err = aghos.SendProcessSignal(pid, syscall.SIGHUP)
if err != nil {
log.Error("Can't send signal to PID %d: %s", pid, err)
</s> add if err = proc.Signal(syscall.SIGHUP); err != nil {
log.Error("Can't send signal to pid %d: %s", pid, err)
</s> remove pid, err := strconv.Atoi(strings.TrimSpace(parts[0]))
if err != nil {
log.Error("Can't read PID file %s: %s", pidfile, err)
</s> add var proc *os.Process
if proc, err = os.FindProcess(pid); err != nil {
log.Error("can't send signal to pid %d: %s", pid, err)
</s> remove parts := strings.SplitN(string(data), "\n", 2)
if len(parts) == 0 {
log.Error("Can't read PID file %s: bad value", pidfile)
return
</s> add } else {
parts := strings.SplitN(string(data), "\n", 2)
if len(parts) == 0 {
log.Error("can't read pid file %s: bad value", pidfile)
return
}
if pid, err = strconv.Atoi(strings.TrimSpace(parts[0])); err != nil {
log.Error("can't read pid file %s: %s", pidfile, err)
return
} </s> remove
data = []byte(psdata)
</s> add </s> remove var code int
var psdata string
code, psdata, err = aghos.RunCommand("ps", "-C", serviceName, "-o", "pid=")
if err != nil || code != 0 {
log.Error("finding AdGuardHome process: code: %d, error: %s", code, err)
</s> add if pid, err = aghos.PIDByCommand(serviceName, os.Getpid()); err != nil {
log.Error("finding AdGuardHome process: %s", err)
|
https://github.com/AdguardTeam/AdGuardHome/commit/550b1798a169d07139f8f079bc5c83271a181f7f
|
internal/aghnet/systemresolvers_windows.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> if err != nil {
<mask> return nil, fmt.Errorf("start command executing: %w", err)
<mask> }
<mask>
<mask> s := bufio.NewScanner(stdoutLimited)
<mask> addrs = scanAddrs(s)
<mask>
<mask> err = cmd.Wait()
<mask> if err != nil {
<mask> return nil, fmt.Errorf("executing the command: %w", err)
</s> Pull request: 3457 fix service reload
Merge in DNS/adguard-home from 3457-darwin-svc-reload to master
Closes #3457.
Squashed commit of the following:
commit e3d6fbccf8373194360b6480e2d702ccd0ec7107
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 18 00:52:39 2021 +0300
aghos: imp docs
commit 220d37ebc1e0c2e9ba37a34650bff1480bd2fcf6
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 17 15:45:52 2021 +0300
all: fix ps </s> remove var stdoutLimited io.Reader
stdoutLimited, err = aghio.LimitReader(stdout, aghos.MaxCmdOutputSize)
if err != nil {
return nil, fmt.Errorf("limiting stdout reader: %w", err)
}
</s> add </s> remove parts := strings.SplitN(string(data), "\n", 2)
if len(parts) == 0 {
log.Error("Can't read PID file %s: bad value", pidfile)
return
</s> add } else {
parts := strings.SplitN(string(data), "\n", 2)
if len(parts) == 0 {
log.Error("can't read pid file %s: bad value", pidfile)
return
}
if pid, err = strconv.Atoi(strings.TrimSpace(parts[0])); err != nil {
log.Error("can't read pid file %s: %s", pidfile, err)
return
} </s> remove pid, err := strconv.Atoi(strings.TrimSpace(parts[0]))
if err != nil {
log.Error("Can't read PID file %s: %s", pidfile, err)
</s> add var proc *os.Process
if proc, err = os.FindProcess(pid); err != nil {
log.Error("can't send signal to pid %d: %s", pid, err)
</s> remove }
</s> add </s> remove err = aghos.SendProcessSignal(pid, syscall.SIGHUP)
if err != nil {
log.Error("Can't send signal to PID %d: %s", pid, err)
</s> add if err = proc.Signal(syscall.SIGHUP); err != nil {
log.Error("Can't send signal to pid %d: %s", pid, err)
</s> remove var code int
var psdata string
code, psdata, err = aghos.RunCommand("ps", "-C", serviceName, "-o", "pid=")
if err != nil || code != 0 {
log.Error("finding AdGuardHome process: code: %d, error: %s", code, err)
</s> add if pid, err = aghos.PIDByCommand(serviceName, os.Getpid()); err != nil {
log.Error("finding AdGuardHome process: %s", err)
|
https://github.com/AdguardTeam/AdGuardHome/commit/550b1798a169d07139f8f079bc5c83271a181f7f
|
internal/aghnet/systemresolvers_windows.go
|
keep add keep keep keep keep keep
|
<mask>
<mask> import (
<mask> "fmt"
<mask> "io"
<mask> "os/exec"
<mask> "path"
<mask> "runtime"
</s> Pull request: 3457 fix service reload
Merge in DNS/adguard-home from 3457-darwin-svc-reload to master
Closes #3457.
Squashed commit of the following:
commit e3d6fbccf8373194360b6480e2d702ccd0ec7107
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 18 00:52:39 2021 +0300
aghos: imp docs
commit 220d37ebc1e0c2e9ba37a34650bff1480bd2fcf6
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 17 15:45:52 2021 +0300
all: fix ps </s> add "io" </s> add "path" </s> remove "syscall"
</s> add "strconv"
"strings"
"github.com/AdguardTeam/golibs/log" </s> remove "syscall"
</s> add </s> remove command_args="-P ${pidfile} -f -r {{.WorkingDirectory}}/{{.Name}}"
</s> add command_args="-p ${pidfile} -f -r {{.WorkingDirectory}}/{{.Name}}" </s> remove func sendProcessSignal(pid int, sig syscall.Signal) error {
return syscall.Kill(pid, sig)
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/550b1798a169d07139f8f079bc5c83271a181f7f
|
internal/aghos/os.go
|
keep add keep keep keep keep keep keep
|
<mask> "bufio"
<mask> "fmt"
<mask> "os/exec"
<mask> "path"
<mask> "runtime"
<mask> "strconv"
<mask> "strings"
<mask>
</s> Pull request: 3457 fix service reload
Merge in DNS/adguard-home from 3457-darwin-svc-reload to master
Closes #3457.
Squashed commit of the following:
commit e3d6fbccf8373194360b6480e2d702ccd0ec7107
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 18 00:52:39 2021 +0300
aghos: imp docs
commit 220d37ebc1e0c2e9ba37a34650bff1480bd2fcf6
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 17 15:45:52 2021 +0300
all: fix ps </s> add "path" </s> add "bufio" </s> remove "syscall"
</s> add "strconv"
"strings"
"github.com/AdguardTeam/golibs/log" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghio"
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
</s> add </s> remove log.Debug("Sent signal to PID %d", pid)
</s> add log.Debug("sent signal to PID %d", pid) </s> remove var stdoutLimited io.Reader
stdoutLimited, err = aghio.LimitReader(stdout, aghos.MaxCmdOutputSize)
if err != nil {
return nil, fmt.Errorf("limiting stdout reader: %w", err)
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/550b1798a169d07139f8f079bc5c83271a181f7f
|
internal/aghos/os.go
|
keep keep keep add keep keep keep keep keep
|
<mask> "bufio"
<mask> "fmt"
<mask> "io"
<mask> "os/exec"
<mask> "runtime"
<mask> "strconv"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/golibs/log"
</s> Pull request: 3457 fix service reload
Merge in DNS/adguard-home from 3457-darwin-svc-reload to master
Closes #3457.
Squashed commit of the following:
commit e3d6fbccf8373194360b6480e2d702ccd0ec7107
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 18 00:52:39 2021 +0300
aghos: imp docs
commit 220d37ebc1e0c2e9ba37a34650bff1480bd2fcf6
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 17 15:45:52 2021 +0300
all: fix ps </s> add "io" </s> add "bufio" </s> remove "syscall"
</s> add "strconv"
"strings"
"github.com/AdguardTeam/golibs/log" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghio"
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
</s> add </s> remove log.Debug("Sent signal to PID %d", pid)
</s> add log.Debug("sent signal to PID %d", pid) </s> remove var stdoutLimited io.Reader
stdoutLimited, err = aghio.LimitReader(stdout, aghos.MaxCmdOutputSize)
if err != nil {
return nil, fmt.Errorf("limiting stdout reader: %w", err)
}
</s> add
|
https://github.com/AdguardTeam/AdGuardHome/commit/550b1798a169d07139f8f079bc5c83271a181f7f
|
internal/aghos/os.go
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> import (
<mask> "fmt"
<mask> "os/exec"
<mask> "runtime"
<mask> "syscall"
<mask> )
<mask>
<mask> // UnsupportedError is returned by functions and methods when a particular
<mask> // operation Op cannot be performed on the current OS.
<mask> type UnsupportedError struct {
</s> Pull request: 3457 fix service reload
Merge in DNS/adguard-home from 3457-darwin-svc-reload to master
Closes #3457.
Squashed commit of the following:
commit e3d6fbccf8373194360b6480e2d702ccd0ec7107
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 18 00:52:39 2021 +0300
aghos: imp docs
commit 220d37ebc1e0c2e9ba37a34650bff1480bd2fcf6
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 17 15:45:52 2021 +0300
all: fix ps </s> add "bufio" </s> remove "syscall"
</s> add </s> remove // SendProcessSignal sends signal to a process.
func SendProcessSignal(pid int, sig syscall.Signal) error {
return sendProcessSignal(pid, sig)
}
</s> add </s> remove log.Debug("Sent signal to PID %d", pid)
</s> add log.Debug("sent signal to PID %d", pid) </s> add "io" </s> add "path"
|
https://github.com/AdguardTeam/AdGuardHome/commit/550b1798a169d07139f8f079bc5c83271a181f7f
|
internal/aghos/os.go
|
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
|
<mask> func HaveAdminRights() (bool, error) {
<mask> return haveAdminRights()
<mask> }
<mask>
<mask> // SendProcessSignal sends signal to a process.
<mask> func SendProcessSignal(pid int, sig syscall.Signal) error {
<mask> return sendProcessSignal(pid, sig)
<mask> }
<mask>
<mask> // MaxCmdOutputSize is the maximum length of performed shell command output.
<mask> const MaxCmdOutputSize = 2 * 1024
<mask>
<mask> // RunCommand runs shell command.
<mask> func RunCommand(command string, arguments ...string) (int, string, error) {
</s> Pull request: 3457 fix service reload
Merge in DNS/adguard-home from 3457-darwin-svc-reload to master
Closes #3457.
Squashed commit of the following:
commit e3d6fbccf8373194360b6480e2d702ccd0ec7107
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 18 00:52:39 2021 +0300
aghos: imp docs
commit 220d37ebc1e0c2e9ba37a34650bff1480bd2fcf6
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 17 15:45:52 2021 +0300
all: fix ps </s> remove func sendProcessSignal(pid int, sig syscall.Signal) error {
return syscall.Kill(pid, sig)
}
</s> add </s> remove func sendProcessSignal(pid int, sig syscall.Signal) error {
return syscall.Kill(pid, sig)
}
</s> add </s> remove func sendProcessSignal(pid int, sig syscall.Signal) error {
return syscall.Kill(pid, sig)
}
</s> add </s> remove log.Debug("Sent signal to PID %d", pid)
</s> add log.Debug("sent signal to PID %d", pid) </s> remove func sendProcessSignal(pid int, sig syscall.Signal) error {
return Unsupported("kill")
}
</s> add </s> remove "syscall"
</s> add "strconv"
"strings"
"github.com/AdguardTeam/golibs/log"
|
https://github.com/AdguardTeam/AdGuardHome/commit/550b1798a169d07139f8f079bc5c83271a181f7f
|
internal/aghos/os.go
|
keep keep keep keep replace replace replace replace keep keep keep
|
<mask> func haveAdminRights() (bool, error) {
<mask> return os.Getuid() == 0, nil
<mask> }
<mask>
<mask> func sendProcessSignal(pid int, sig syscall.Signal) error {
<mask> return syscall.Kill(pid, sig)
<mask> }
<mask>
<mask> func isOpenWrt() (ok bool) {
<mask> return false
<mask> }
</s> Pull request: 3457 fix service reload
Merge in DNS/adguard-home from 3457-darwin-svc-reload to master
Closes #3457.
Squashed commit of the following:
commit e3d6fbccf8373194360b6480e2d702ccd0ec7107
Author: Eugene Burkov <[email protected]>
Date: Wed Aug 18 00:52:39 2021 +0300
aghos: imp docs
commit 220d37ebc1e0c2e9ba37a34650bff1480bd2fcf6
Author: Eugene Burkov <[email protected]>
Date: Tue Aug 17 15:45:52 2021 +0300
all: fix ps </s> remove func sendProcessSignal(pid int, sig syscall.Signal) error {
return syscall.Kill(pid, sig)
}
</s> add </s> remove func sendProcessSignal(pid int, sig syscall.Signal) error {
return syscall.Kill(pid, sig)
}
</s> add </s> remove func sendProcessSignal(pid int, sig syscall.Signal) error {
return Unsupported("kill")
}
</s> add </s> remove // SendProcessSignal sends signal to a process.
func SendProcessSignal(pid int, sig syscall.Signal) error {
return sendProcessSignal(pid, sig)
}
</s> add </s> remove "syscall"
</s> add </s> remove parts := strings.SplitN(string(data), "\n", 2)
if len(parts) == 0 {
log.Error("Can't read PID file %s: bad value", pidfile)
return
</s> add } else {
parts := strings.SplitN(string(data), "\n", 2)
if len(parts) == 0 {
log.Error("can't read pid file %s: bad value", pidfile)
return
}
if pid, err = strconv.Atoi(strings.TrimSpace(parts[0])); err != nil {
log.Error("can't read pid file %s: %s", pidfile, err)
return
}
|
https://github.com/AdguardTeam/AdGuardHome/commit/550b1798a169d07139f8f079bc5c83271a181f7f
|
internal/aghos/os_bsd.go
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.