code_before
stringlengths
16
1.81M
edits
stringlengths
4
328k
next_edit
stringlengths
0
76.5k
code_after
stringlengths
3
49.9M
label_window
sequencelengths
4
1.81k
instruction
stringlengths
20
51.9k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled) r.Header.Del("Cookie") Context.auth.Close() } func TestRealIP(t *testing.T) {
</s> remove r.Header.Set("Cookie", "bad") </s> add r.Header.Set(httphdr.Cookie, "bad") </s> remove r.Header.Del("Cookie") </s> add r.Header.Del(httphdr.Cookie) </s> remove loginURL := w.hdr.Get("Location") </s> add loginURL := w.hdr.Get(httphdr.Location) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location)) </s> remove assert.NotEmpty(t, w.hdr.Get("Location")) </s> add assert.NotEmpty(t, w.hdr.Get(httphdr.Location))
r.Header.Del(httphdr.Cookie)
r.URL = &url.URL{Path: loginURL} handlerCalled = false handler2(&w, &r) assert.True(t, handlerCalled) r.Header.Del(httphdr.Cookie) Context.auth.Close() } func TestRealIP(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
wantIP: net.IPv4(1, 2, 3, 4), }, { name: "success_proxy", header: http.Header{ textproto.CanonicalMIMEHeaderKey("X-Real-IP"): []string{"1.2.3.5"}, }, remoteAddr: remoteAddr, wantErrMsg: "", wantIP: net.IPv4(1, 2, 3, 5), }, {
</s> remove textproto.CanonicalMIMEHeaderKey("X-Forwarded-For"): []string{ </s> add textproto.CanonicalMIMEHeaderKey(httphdr.XForwardedFor): []string{ </s> remove h.Set("Content-Disposition", d) </s> add h.Set(httphdr.ContentDisposition, d) </s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove w.Header().Set("Location", "/login.html") </s> add w.Header().Set(httphdr.Location, "/login.html") </s> remove w.Header().Set("Content-Disposition", contDisp) </s> add w.Header().Set(httphdr.ContentDisposition, contDisp)
textproto.CanonicalMIMEHeaderKey(httphdr.XRealIP): []string{"1.2.3.5"},
wantIP: net.IPv4(1, 2, 3, 4), }, { name: "success_proxy", header: http.Header{ textproto.CanonicalMIMEHeaderKey(httphdr.XRealIP): []string{"1.2.3.5"}, }, remoteAddr: remoteAddr, wantErrMsg: "", wantIP: net.IPv4(1, 2, 3, 5), }, {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
wantIP: net.IPv4(1, 2, 3, 5), }, { name: "success_proxy_multiple", header: http.Header{ textproto.CanonicalMIMEHeaderKey("X-Forwarded-For"): []string{ "1.2.3.6, 1.2.3.5", }, }, remoteAddr: remoteAddr, wantErrMsg: "",
</s> remove textproto.CanonicalMIMEHeaderKey("X-Real-IP"): []string{"1.2.3.5"}, </s> add textproto.CanonicalMIMEHeaderKey(httphdr.XRealIP): []string{"1.2.3.5"}, </s> remove "CF-Connecting-IP", "True-Client-IP", "X-Real-IP", </s> add httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP, </s> remove h.Set("Content-Disposition", d) </s> add h.Set(httphdr.ContentDisposition, d) </s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove w.Header().Set("Location", "/login.html") </s> add w.Header().Set(httphdr.Location, "/login.html")
textproto.CanonicalMIMEHeaderKey(httphdr.XForwardedFor): []string{
wantIP: net.IPv4(1, 2, 3, 5), }, { name: "success_proxy_multiple", header: http.Header{ textproto.CanonicalMIMEHeaderKey(httphdr.XForwardedFor): []string{ "1.2.3.6, 1.2.3.5", }, }, remoteAddr: remoteAddr, wantErrMsg: "",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/auth_test.go
"github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" "github.com/NYTimes/gziphandler" ) // appendDNSAddrs is a convenient helper for appending a formatted form of DNS
</s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain {
"github.com/AdguardTeam/golibs/httphdr"
"github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" "github.com/NYTimes/gziphandler" ) // appendDNSAddrs is a convenient helper for appending a formatted form of DNS
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/control.go
// to w, and ok is false. func ensureContentType(w http.ResponseWriter, r *http.Request) (ok bool) { const statusUnsup = http.StatusUnsupportedMediaType cType := r.Header.Get(aghhttp.HdrNameContentType) if r.ContentLength == 0 { if cType == "" { return true }
</s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { </s> remove w.Header().Set("Content-Disposition", contDisp) </s> add w.Header().Set(httphdr.ContentDisposition, contDisp) </s> remove w.Header().Set("Location", "/") </s> add w.Header().Set(httphdr.Location, "/") </s> remove respHdr.Set(aghhttp.HdrNameAccessControlAllowOrigin, originURL.String()) respHdr.Set(aghhttp.HdrNameVary, aghhttp.HdrNameOrigin) </s> add respHdr.Set(httphdr.AccessControlAllowOrigin, originURL.String()) respHdr.Set(httphdr.Vary, httphdr.Origin) </s> remove cType := w.Header().Get(aghhttp.HdrNameContentType) </s> add cType := w.Header().Get(httphdr.ContentType)
cType := r.Header.Get(httphdr.ContentType)
// to w, and ok is false. func ensureContentType(w http.ResponseWriter, r *http.Request) (ok bool) { const statusUnsup = http.StatusUnsupportedMediaType cType := r.Header.Get(httphdr.ContentType) if r.ContentLength == 0 { if cType == "" { return true }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/control.go
// TODO(a.garipov): Consider adding a configurable max-age. Currently, the // default is 24 hours. if serveHTTP3 { altSvc := fmt.Sprintf(`h3=":%d"`, portHTTPS) respHdr.Set(aghhttp.HdrNameAltSvc, altSvc) } if r.TLS == nil && web.forceHTTPS { hostPort := host if port := web.conf.PortHTTPS; port != defaultPortHTTPS {
</s> remove w.Header().Set("Location", "/") </s> add w.Header().Set(httphdr.Location, "/") </s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { </s> remove h.Set(aghhttp.HdrNameContentType, aghhttp.HdrValApplicationJSON) h.Set(aghhttp.HdrNameServer, aghhttp.UserAgent()) </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent()) </s> remove s := r.Header.Get("X-Forwarded-For") </s> add s := r.Header.Get(httphdr.XForwardedFor) </s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType)
respHdr.Set(httphdr.AltSvc, altSvc)
// TODO(a.garipov): Consider adding a configurable max-age. Currently, the // default is 24 hours. if serveHTTP3 { altSvc := fmt.Sprintf(`h3=":%d"`, portHTTPS) respHdr.Set(httphdr.AltSvc, altSvc) } if r.TLS == nil && web.forceHTTPS { hostPort := host if port := web.conf.PortHTTPS; port != defaultPortHTTPS {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/control.go
Scheme: aghhttp.SchemeHTTP, Host: r.Host, } respHdr.Set(aghhttp.HdrNameAccessControlAllowOrigin, originURL.String()) respHdr.Set(aghhttp.HdrNameVary, aghhttp.HdrNameOrigin) return true } // postInstall lets the handler to run only if firstRun is false. Otherwise, it
</s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove respHdr.Set("Location", "/login.html") </s> add respHdr.Set(httphdr.Location, "/login.html") </s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { </s> remove w.Header().Set("Location", "/") </s> add w.Header().Set(httphdr.Location, "/") </s> remove w.Header().Set(HdrNameContentType, HdrValApplicationJSON) </s> add w.Header().Set(httphdr.ContentType, HdrValApplicationJSON)
respHdr.Set(httphdr.AccessControlAllowOrigin, originURL.String()) respHdr.Set(httphdr.Vary, httphdr.Origin)
Scheme: aghhttp.SchemeHTTP, Host: r.Host, } respHdr.Set(httphdr.AccessControlAllowOrigin, originURL.String()) respHdr.Set(httphdr.Vary, httphdr.Origin) respHdr.Set(httphdr.AccessControlAllowOrigin, originURL.String()) respHdr.Set(httphdr.Vary, httphdr.Origin) return true } // postInstall lets the handler to run only if firstRun is false. Otherwise, it
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/control.go
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/google/uuid" "howett.net/plist" )
</s>
"github.com/AdguardTeam/golibs/httphdr"
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/log" "github.com/google/uuid" "howett.net/plist" )
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/mobileconfig.go
return } w.Header().Set("Content-Type", "application/xml") const ( dohContDisp = `attachment; filename=doh.mobileconfig` dotContDisp = `attachment; filename=dot.mobileconfig` )
</s> remove // HTTP Headers // HTTP header name constants. // // TODO(a.garipov): Remove unused. const ( HdrNameAcceptEncoding = "Accept-Encoding" HdrNameAccessControlAllowOrigin = "Access-Control-Allow-Origin" HdrNameAltSvc = "Alt-Svc" HdrNameContentEncoding = "Content-Encoding" HdrNameContentType = "Content-Type" HdrNameOrigin = "Origin" HdrNameServer = "Server" HdrNameTrailer = "Trailer" HdrNameUserAgent = "User-Agent" HdrNameVary = "Vary" ) </s> add // HTTP headers </s> remove w.Header().Set("Content-Disposition", contDisp) </s> add w.Header().Set(httphdr.ContentDisposition, contDisp) </s> remove w.Header().Set("Content-Type", "application/json") </s> add w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON)
w.Header().Set(httphdr.ContentType, "application/xml")
return } w.Header().Set(httphdr.ContentType, "application/xml") const ( dohContDisp = `attachment; filename=doh.mobileconfig` dotContDisp = `attachment; filename=dot.mobileconfig` )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/mobileconfig.go
if dnsp == dnsProtoTLS { contDisp = dotContDisp } w.Header().Set("Content-Disposition", contDisp) _, _ = w.Write(mobileconfig) } func handleMobileConfigDoH(w http.ResponseWriter, r *http.Request) {
</s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove h.Set("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate") h.Set("Pragma", "no-cache") h.Set("Expires", "0") </s> add h.Set(httphdr.CacheControl, "no-store, no-cache, must-revalidate, proxy-revalidate") h.Set(httphdr.Pragma, "no-cache") h.Set(httphdr.Expires, "0") </s> remove w.Header().Set("Content-Type", "application/json") </s> add w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) </s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { </s> remove "CF-Connecting-IP", "True-Client-IP", "X-Real-IP", </s> add httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP,
w.Header().Set(httphdr.ContentDisposition, contDisp)
if dnsp == dnsProtoTLS { contDisp = dotContDisp } w.Header().Set(httphdr.ContentDisposition, contDisp) _, _ = w.Write(mobileconfig) } func handleMobileConfigDoH(w http.ResponseWriter, r *http.Request) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/home/mobileconfig.go
"strconv" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/log" ) // JSON Utilities
</s>
"github.com/AdguardTeam/golibs/httphdr"
"strconv" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/log" ) // JSON Utilities
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/next/websvc/json.go
// request. func writeJSONResponse(w http.ResponseWriter, r *http.Request, v any, code int) { // TODO(a.garipov): Put some of these to a middleware. h := w.Header() h.Set(aghhttp.HdrNameContentType, aghhttp.HdrValApplicationJSON) h.Set(aghhttp.HdrNameServer, aghhttp.UserAgent()) w.WriteHeader(code) err := json.NewEncoder(w).Encode(v) if err != nil {
</s> remove w.Header().Set(HdrNameContentType, HdrValApplicationJSON) </s> add w.Header().Set(httphdr.ContentType, HdrValApplicationJSON) </s> remove "CF-Connecting-IP", "True-Client-IP", "X-Real-IP", </s> add httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP, </s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { </s> remove w.Header().Set("Content-Type", "application/json") </s> add w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) </s> remove req.Header.Set("Content-Type", cType) </s> add req.Header.Set(httphdr.ContentType, cType)
h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent())
// request. func writeJSONResponse(w http.ResponseWriter, r *http.Request, v any, code int) { // TODO(a.garipov): Put some of these to a middleware. h := w.Header() h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent()) h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent()) w.WriteHeader(code) err := json.NewEncoder(w).Encode(v) if err != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/next/websvc/json.go
package websvc import "net/http" // Middlewares // jsonMw sets the content type of the response to application/json. func jsonMw(h http.Handler) (wrapped http.HandlerFunc) {
</s> remove w.Header().Set("Content-Type", "application/json") </s> add w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) </s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { </s> remove s := r.Header.Get("X-Forwarded-For") </s> add s := r.Header.Get(httphdr.XForwardedFor) </s> remove w.Header().Set(HdrNameContentType, HdrValApplicationJSON) </s> add w.Header().Set(httphdr.ContentType, HdrValApplicationJSON)
import ( "net/http" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/httphdr" )
package websvc import ( "net/http" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/httphdr" ) // Middlewares // jsonMw sets the content type of the response to application/json. func jsonMw(h http.Handler) (wrapped http.HandlerFunc) {
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/next/websvc/middleware.go
// jsonMw sets the content type of the response to application/json. func jsonMw(h http.Handler) (wrapped http.HandlerFunc) { f := func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") h.ServeHTTP(w, r) } return http.HandlerFunc(f)
</s> remove import "net/http" </s> add import ( "net/http" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/httphdr" ) </s> remove if r.Header.Get(HdrNameContentType) != HdrValTextPlain { </s> add if r.Header.Get(httphdr.ContentType) != HdrValTextPlain { </s> remove cType := r.Header.Get(aghhttp.HdrNameContentType) </s> add cType := r.Header.Get(httphdr.ContentType) </s> remove s := r.Header.Get("X-Forwarded-For") </s> add s := r.Header.Get(httphdr.XForwardedFor) </s> remove w.Header().Set(HdrNameContentType, HdrValApplicationJSON) </s> add w.Header().Set(httphdr.ContentType, HdrValApplicationJSON)
w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON)
// jsonMw sets the content type of the response to application/json. func jsonMw(h http.Handler) (wrapped http.HandlerFunc) { f := func(w http.ResponseWriter, r *http.Request) { w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.ServeHTTP(w, r) } return http.HandlerFunc(f)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
internal/next/websvc/middleware.go
"sync" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghio" "github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/log"
</s>
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"sync" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghio" "github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/log"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
scripts/translations/main.go
"github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "golang.org/x/exp/maps" "golang.org/x/exp/slices" ) const (
</s> remove w.Header().Set("Content-Type", "application/xml") </s> add w.Header().Set(httphdr.ContentType, "application/xml")
"github.com/AdguardTeam/golibs/httphdr"
"github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/httphdr" "github.com/AdguardTeam/golibs/log" "golang.org/x/exp/maps" "golang.org/x/exp/slices" ) const (
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
scripts/translations/main.go
err = errors.WithDeferred(err, file.Close()) }() h := make(textproto.MIMEHeader) h.Set("Content-Type", "application/json") d := fmt.Sprintf("form-data; name=%q; filename=%q", "file", defaultBaseFile) h.Set("Content-Disposition", d) fw, err = w.CreatePart(h)
</s> remove h.Set("Content-Disposition", d) </s> add h.Set(httphdr.ContentDisposition, d) </s> remove h.Set(aghhttp.HdrNameContentType, aghhttp.HdrValApplicationJSON) h.Set(aghhttp.HdrNameServer, aghhttp.UserAgent()) </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent()) </s> remove "CF-Connecting-IP", "True-Client-IP", "X-Real-IP", </s> add httphdr.CFConnectingIP, httphdr.TrueClientIP, httphdr.XRealIP, </s> remove req.Header.Set("Content-Type", cType) </s> add req.Header.Set(httphdr.ContentType, cType) </s> remove respHdr.Set("Location", "/login.html") </s> add respHdr.Set(httphdr.Location, "/login.html")
h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON)
err = errors.WithDeferred(err, file.Close()) }() h := make(textproto.MIMEHeader) h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) d := fmt.Sprintf("form-data; name=%q; filename=%q", "file", defaultBaseFile) h.Set("Content-Disposition", d) fw, err = w.CreatePart(h)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
scripts/translations/main.go
h := make(textproto.MIMEHeader) h.Set("Content-Type", "application/json") d := fmt.Sprintf("form-data; name=%q; filename=%q", "file", defaultBaseFile) h.Set("Content-Disposition", d) fw, err = w.CreatePart(h) if err != nil { return nil, "", fmt.Errorf("creating part: %w", err) }
</s> remove h.Set("Content-Type", "application/json") </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) </s> remove req.Header.Set("Content-Type", cType) </s> add req.Header.Set(httphdr.ContentType, cType) </s> remove h.Set(aghhttp.HdrNameContentType, aghhttp.HdrValApplicationJSON) h.Set(aghhttp.HdrNameServer, aghhttp.UserAgent()) </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent()) </s> remove respHdr.Set("Location", "/login.html") </s> add respHdr.Set(httphdr.Location, "/login.html") </s> remove w.Header().Set(HdrNameContentType, HdrValApplicationJSON) </s> add w.Header().Set(httphdr.ContentType, HdrValApplicationJSON)
h.Set(httphdr.ContentDisposition, d)
h := make(textproto.MIMEHeader) h.Set("Content-Type", "application/json") d := fmt.Sprintf("form-data; name=%q; filename=%q", "file", defaultBaseFile) h.Set(httphdr.ContentDisposition, d) fw, err = w.CreatePart(h) if err != nil { return nil, "", fmt.Errorf("creating part: %w", err) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
scripts/translations/main.go
if err != nil { return fmt.Errorf("bad request: %w", err) } req.Header.Set("Content-Type", cType) resp, err := client.Do(req) if err != nil { return fmt.Errorf("client post form: %w", err) }
</s> remove h.Set("Content-Disposition", d) </s> add h.Set(httphdr.ContentDisposition, d) </s> remove respHdr.Set("Location", "/login.html") </s> add respHdr.Set(httphdr.Location, "/login.html") </s> remove w.Header().Set(HdrNameContentType, HdrValApplicationJSON) </s> add w.Header().Set(httphdr.ContentType, HdrValApplicationJSON) </s> remove w.Header().Set("Location", "/") </s> add w.Header().Set(httphdr.Location, "/") </s> remove h.Set(aghhttp.HdrNameContentType, aghhttp.HdrValApplicationJSON) h.Set(aghhttp.HdrNameServer, aghhttp.UserAgent()) </s> add h.Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON) h.Set(httphdr.Server, aghhttp.UserAgent())
req.Header.Set(httphdr.ContentType, cType)
if err != nil { return fmt.Errorf("bad request: %w", err) } req.Header.Set(httphdr.ContentType, cType) resp, err := client.Do(req) if err != nil { return fmt.Errorf("client post form: %w", err) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request 1807: upd-golibs Merge in DNS/adguard-home from upd-golibs to master Squashed commit of the following: commit cde42a72c2140245f345681cbb936ed3bc4645a1 Author: Ainar Garipov <[email protected]> Date: Fri Apr 7 13:57:02 2023 +0300 all: upd golibs, use hdrs
https://github.com/AdguardTeam/AdGuardHome/commit/15bba281ee36ff9af69aced1068a9fc6925a0a6b
scripts/translations/main.go
border-radius: 4px !important; pointer-events: auto !important; background-color: var(--white); z-index: 102; } .white-space--nowrap { white-space: nowrap !important; }
</s> remove .tooltip__container { overflow-y: scroll; } </s> add </s> remove scrollHide: PropTypes.bool, </s> add
overflow-y: scroll; max-height: 100%;
border-radius: 4px !important; pointer-events: auto !important; background-color: var(--white); z-index: 102; overflow-y: scroll; max-height: 100%; } .white-space--nowrap { white-space: nowrap !important; }
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Open tooltip on hover, show scroll on overflow y
https://github.com/AdguardTeam/AdGuardHome/commit/15db9e9c1daec31d5d6f1d6d77a59bc125fb00d5
client/src/components/Logs/Cells/Tooltip.css
.grid .key-colon, .grid .title--border { font-weight: bold; } .tooltip__container { overflow-y: scroll; } } .grid .key-colon:nth-child(odd)::after { content: ':'; }
</s> remove scrollHide: PropTypes.bool, </s> add
.grid .key-colon, .grid .title--border { font-weight: bold; } } .grid .key-colon:nth-child(odd)::after { content: ':'; }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Open tooltip on hover, show scroll on overflow y
https://github.com/AdguardTeam/AdGuardHome/commit/15db9e9c1daec31d5d6f1d6d77a59bc125fb00d5
client/src/components/Logs/Cells/Tooltip.css
import './Tooltip.css'; import 'react-popper-tooltip/dist/styles.css'; const getHintElement = ({ className, contentItemClass,
</s> remove scrollHide: PropTypes.bool, </s> add </s> remove .tooltip__container { overflow-y: scroll; } </s> add
import { HIDE_TOOLTIP_DELAY } from '../../../helpers/constants';
import './Tooltip.css'; import 'react-popper-tooltip/dist/styles.css'; import { HIDE_TOOLTIP_DELAY } from '../../../helpers/constants'; const getHintElement = ({ className, contentItemClass,
[ "keep", "add", "keep", "keep", "keep", "keep" ]
Open tooltip on hover, show scroll on overflow y
https://github.com/AdguardTeam/AdGuardHome/commit/15db9e9c1daec31d5d6f1d6d77a59bc125fb00d5
client/src/components/Logs/Cells/getHintElement.js
title: PropTypes.string, placement: PropTypes.string, canShowTooltip: PropTypes.string, xlinkHref: PropTypes.string, scrollHide: PropTypes.bool, content: PropTypes.oneOfType([ PropTypes.string, PropTypes.array, ]), renderContent: PropTypes.arrayOf(PropTypes.element),
</s> remove .tooltip__container { overflow-y: scroll; } </s> add
title: PropTypes.string, placement: PropTypes.string, canShowTooltip: PropTypes.string, xlinkHref: PropTypes.string, content: PropTypes.oneOfType([ PropTypes.string, PropTypes.array, ]), renderContent: PropTypes.arrayOf(PropTypes.element),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Open tooltip on hover, show scroll on overflow y
https://github.com/AdguardTeam/AdGuardHome/commit/15db9e9c1daec31d5d6f1d6d77a59bc125fb00d5
client/src/components/Logs/Cells/getHintElement.js
export const DEBOUNCE_FILTER_TIMEOUT = 500; export const CHECK_TIMEOUT = 1000; export const SUCCESS_TOAST_TIMEOUT = 5000; export const FAILURE_TOAST_TIMEOUT = 30000; export const UNSAFE_PORTS = [ 1, 7,
</s> remove scrollHide: PropTypes.bool, </s> add </s> remove .tooltip__container { overflow-y: scroll; } </s> add
export const HIDE_TOOLTIP_DELAY = 300;
export const DEBOUNCE_FILTER_TIMEOUT = 500; export const CHECK_TIMEOUT = 1000; export const SUCCESS_TOAST_TIMEOUT = 5000; export const FAILURE_TOAST_TIMEOUT = 30000; export const HIDE_TOOLTIP_DELAY = 300; export const UNSAFE_PORTS = [ 1, 7,
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Open tooltip on hover, show scroll on overflow y
https://github.com/AdguardTeam/AdGuardHome/commit/15db9e9c1daec31d5d6f1d6d77a59bc125fb00d5
client/src/helpers/constants.js
"runtime" "strconv" "strings" "github.com/AdguardTeam/golibs/log" ) // UnsupportedError is returned by functions and methods when a particular // operation Op cannot be performed on the current OS. type UnsupportedError struct {
</s> remove // Represents the program that will be launched by a service or daemon </s> add // program represents the program that will be launched by as a service or a // daemon. </s> remove // On OpenWrt it is important to run enable after the service installation // Otherwise, the service won't start on the system startup </s> add // On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup.
"github.com/AdguardTeam/golibs/errors"
"runtime" "strconv" "strings" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" ) // UnsupportedError is returned by functions and methods when a particular // operation Op cannot be performed on the current OS. type UnsupportedError struct {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/aghos/os.go
out, err := cmd.Output() if len(out) > MaxCmdOutputSize { out = out[:MaxCmdOutputSize] } if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %v: %s", command, err, string(out)) } return cmd.ProcessState.ExitCode(), string(out), nil }
</s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil { </s> remove s, err := service.New(prg, svcConfig) if err != nil { </s> add var s service.Service if s, err = service.New(prg, svcConfig); err != nil { </s> remove err := svcAction(s, "uninstall") if err != nil { </s> add if err := svcAction(s, "uninstall"); err != nil { </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil { </s> remove if action == "status" { </s> add switch action { case "status":
if errors.As(err, new(*exec.ExitError)) { return cmd.ProcessState.ExitCode(), string(out), nil } else if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out))
out, err := cmd.Output() if len(out) > MaxCmdOutputSize { out = out[:MaxCmdOutputSize] } if errors.As(err, new(*exec.ExitError)) { return cmd.ProcessState.ExitCode(), string(out), nil } else if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) if errors.As(err, new(*exec.ExitError)) { return cmd.ProcessState.ExitCode(), string(out), nil } else if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) } return cmd.ProcessState.ExitCode(), string(out), nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/aghos/os.go
} }() if args.serviceControlAction != "" { // TODO(a.garipov): github.com/kardianos/service doesn't seem to // support OpenBSD currently. Either patch it to do so or make // our own implementation of the service.System interface. if runtime.GOOS == "openbsd" { log.Fatal("service actions are not supported on openbsd, see issue 3226") } handleServiceControlAction(args, clientBuildFS) return }
</s> remove // Send SIGHUP to a process with ID taken from our pid-file // If pid-file doesn't exist, find our PID using 'ps' command </s> add // Send SIGHUP to a process with PID taken from our .pid file. If it doesn't // exist, find our PID using 'ps' command. </s> remove // On OpenWrt it is important to run enable after the service installation // Otherwise, the service won't start on the system startup </s> add // On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup. </s> remove err := svcAction(s, "uninstall") if err != nil { </s> add if err := svcAction(s, "uninstall"); err != nil {
} }() if args.serviceControlAction != "" { handleServiceControlAction(args, clientBuildFS) return }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/home.go
"strconv" "strings" "syscall" "github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/kardianos/service"
</s> remove err = os.Remove(launchdStdoutPath) </s> add err := os.Remove(launchdStdoutPath) </s> remove if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %v: %s", command, err, string(out)) </s> add if errors.As(err, new(*exec.ExitError)) { return cmd.ProcessState.ExitCode(), string(out), nil } else if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) </s> remove // TODO(a.garipov): github.com/kardianos/service doesn't seem to // support OpenBSD currently. Either patch it to do so or make // our own implementation of the service.System interface. if runtime.GOOS == "openbsd" { log.Fatal("service actions are not supported on openbsd, see issue 3226") } </s> add
"time"
"strconv" "strings" "syscall" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/kardianos/service"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
"github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/kardianos/service" )
</s> remove // Represents the program that will be launched by a service or daemon </s> add // program represents the program that will be launched by as a service or a // daemon. </s> remove err = os.Remove(launchdStdoutPath) </s> add err := os.Remove(launchdStdoutPath) </s> remove if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %v: %s", command, err, string(out)) </s> add if errors.As(err, new(*exec.ExitError)) { return cmd.ProcessState.ExitCode(), string(out), nil } else if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out))
"github.com/AdguardTeam/AdGuardHome/internal/version"
"github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/kardianos/service" )
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
serviceDisplayName = "AdGuard Home service" serviceDescription = "AdGuard Home: Network-level blocker" ) // Represents the program that will be launched by a service or daemon type program struct { clientBuildFS fs.FS opts options }
</s> remove // Start should quickly start the program func (p *program) Start(s service.Service) error { // Start should not block. Do the actual work async. </s> add // Start implements service.Interface interface for *program. func (p *program) Start(_ service.Service) (err error) { // Start should not block. Do the actual work async. </s> remove // Stop stops the program func (p *program) Stop(s service.Service) error { // Stop should not block. Return with a few seconds. </s> add // Stop implements service.Interface interface for *program. func (p *program) Stop(_ service.Service) error { // Stop should not block. Return with a few seconds.
// program represents the program that will be launched by as a service or a // daemon.
serviceDisplayName = "AdGuard Home service" serviceDescription = "AdGuard Home: Network-level blocker" ) // program represents the program that will be launched by as a service or a // daemon. type program struct { clientBuildFS fs.FS opts options }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
clientBuildFS fs.FS opts options } // Start should quickly start the program func (p *program) Start(s service.Service) error { // Start should not block. Do the actual work async. args := p.opts args.runningAsService = true go run(args, p.clientBuildFS) return nil
</s> remove // Stop stops the program func (p *program) Stop(s service.Service) error { // Stop should not block. Return with a few seconds. </s> add // Stop implements service.Interface interface for *program. func (p *program) Stop(_ service.Service) error { // Stop should not block. Return with a few seconds. </s> remove // Represents the program that will be launched by a service or daemon </s> add // program represents the program that will be launched by as a service or a // daemon. </s> remove // Start automatically after install </s> add // Start automatically after install. </s> remove // svcStatus check the service's status. </s> add // svcStatus returns the service's status. </s> remove // On OpenWrt it is important to run enable after the service installation // Otherwise, the service won't start on the system startup </s> add // On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup.
// Start implements service.Interface interface for *program. func (p *program) Start(_ service.Service) (err error) { // Start should not block. Do the actual work async.
clientBuildFS fs.FS opts options } // Start implements service.Interface interface for *program. func (p *program) Start(_ service.Service) (err error) { // Start should not block. Do the actual work async. // Start implements service.Interface interface for *program. func (p *program) Start(_ service.Service) (err error) { // Start should not block. Do the actual work async. // Start implements service.Interface interface for *program. func (p *program) Start(_ service.Service) (err error) { // Start should not block. Do the actual work async. args := p.opts args.runningAsService = true go run(args, p.clientBuildFS) return nil
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
return nil } // Stop stops the program func (p *program) Stop(s service.Service) error { // Stop should not block. Return with a few seconds. if Context.appSignalChannel == nil { os.Exit(0) } Context.appSignalChannel <- syscall.SIGINT return nil
</s> remove // Start should quickly start the program func (p *program) Start(s service.Service) error { // Start should not block. Do the actual work async. </s> add // Start implements service.Interface interface for *program. func (p *program) Start(_ service.Service) (err error) { // Start should not block. Do the actual work async. </s> remove // svcStatus check the service's status. </s> add // svcStatus returns the service's status. </s> remove // Send SIGHUP to a process with ID taken from our pid-file // If pid-file doesn't exist, find our PID using 'ps' command </s> add // Send SIGHUP to a process with PID taken from our .pid file. If it doesn't // exist, find our PID using 'ps' command. </s> remove if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %v: %s", command, err, string(out)) </s> add if errors.As(err, new(*exec.ExitError)) { return cmd.ProcessState.ExitCode(), string(out), nil } else if err != nil { return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out)) </s> remove // TODO(a.garipov): github.com/kardianos/service doesn't seem to // support OpenBSD currently. Either patch it to do so or make // our own implementation of the service.System interface. if runtime.GOOS == "openbsd" { log.Fatal("service actions are not supported on openbsd, see issue 3226") } </s> add
// Stop implements service.Interface interface for *program. func (p *program) Stop(_ service.Service) error { // Stop should not block. Return with a few seconds.
return nil } // Stop implements service.Interface interface for *program. func (p *program) Stop(_ service.Service) error { // Stop should not block. Return with a few seconds. // Stop implements service.Interface interface for *program. func (p *program) Stop(_ service.Service) error { // Stop should not block. Return with a few seconds. // Stop implements service.Interface interface for *program. func (p *program) Stop(_ service.Service) error { // Stop should not block. Return with a few seconds. if Context.appSignalChannel == nil { os.Exit(0) } Context.appSignalChannel <- syscall.SIGINT return nil
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
Context.appSignalChannel <- syscall.SIGINT return nil } // svcStatus check the service's status. // // On OpenWrt, the service utility may not exist. We use our service script // directly in this case. func svcStatus(s service.Service) (status service.Status, err error) { status, err = s.Status()
</s> remove // Stop stops the program func (p *program) Stop(s service.Service) error { // Stop should not block. Return with a few seconds. </s> add // Stop implements service.Interface interface for *program. func (p *program) Stop(_ service.Service) error { // Stop should not block. Return with a few seconds. </s> remove // On OpenWrt it is important to run enable after the service installation // Otherwise, the service won't start on the system startup </s> add // On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup. </s> remove // Start should quickly start the program func (p *program) Start(s service.Service) error { // Start should not block. Do the actual work async. </s> add // Start implements service.Interface interface for *program. func (p *program) Start(_ service.Service) (err error) { // Start should not block. Do the actual work async. </s> remove // handleServiceStatusCommand handles service "status" command </s> add // handleServiceStatusCommand handles service "status" command. </s> remove // Send SIGHUP to a process with ID taken from our pid-file // If pid-file doesn't exist, find our PID using 'ps' command </s> add // Send SIGHUP to a process with PID taken from our .pid file. If it doesn't // exist, find our PID using 'ps' command.
// svcStatus returns the service's status.
Context.appSignalChannel <- syscall.SIGINT return nil } // svcStatus returns the service's status. // // On OpenWrt, the service utility may not exist. We use our service script // directly in this case. func svcStatus(s service.Service) (status service.Status, err error) { status, err = s.Status()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
return err } // Send SIGHUP to a process with ID taken from our pid-file // If pid-file doesn't exist, find our PID using 'ps' command func sendSigReload() { if runtime.GOOS == "windows" { log.Error("not implemented on windows") return
</s> remove // TODO(a.garipov): github.com/kardianos/service doesn't seem to // support OpenBSD currently. Either patch it to do so or make // our own implementation of the service.System interface. if runtime.GOOS == "openbsd" { log.Fatal("service actions are not supported on openbsd, see issue 3226") } </s> add </s> remove // Stop stops the program func (p *program) Stop(s service.Service) error { // Stop should not block. Return with a few seconds. </s> add // Stop implements service.Interface interface for *program. func (p *program) Stop(_ service.Service) error { // Stop should not block. Return with a few seconds. </s> remove // svcStatus check the service's status. </s> add // svcStatus returns the service's status. </s> remove err := svcAction(s, "uninstall") if err != nil { </s> add if err := svcAction(s, "uninstall"); err != nil {
// Send SIGHUP to a process with PID taken from our .pid file. If it doesn't // exist, find our PID using 'ps' command.
return err } // Send SIGHUP to a process with PID taken from our .pid file. If it doesn't // exist, find our PID using 'ps' command. // Send SIGHUP to a process with PID taken from our .pid file. If it doesn't // exist, find our PID using 'ps' command. func sendSigReload() { if runtime.GOOS == "windows" { log.Error("not implemented on windows") return
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
// it is specified when we register a service, and it indicates to the app // that it is being run as a service/daemon. func handleServiceControlAction(opts options, clientBuildFS fs.FS) { action := opts.serviceControlAction log.Printf("Service control action: %s", action) if action == "reload" {
</s> remove // On OpenWrt it is important to run enable after the service installation // Otherwise, the service won't start on the system startup </s> add // On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup. </s> remove // Represents the program that will be launched by a service or daemon </s> add // program represents the program that will be launched by as a service or a // daemon. </s> remove // Send SIGHUP to a process with ID taken from our pid-file // If pid-file doesn't exist, find our PID using 'ps' command </s> add // Send SIGHUP to a process with PID taken from our .pid file. If it doesn't // exist, find our PID using 'ps' command. </s> remove // TODO(a.garipov): github.com/kardianos/service doesn't seem to // support OpenBSD currently. Either patch it to do so or make // our own implementation of the service.System interface. if runtime.GOOS == "openbsd" { log.Fatal("service actions are not supported on openbsd, see issue 3226") } </s> add
// Call chooseSystem expicitly to introduce OpenBSD support for service // package. It's a noop for other GOOS values. chooseSystem()
// it is specified when we register a service, and it indicates to the app // that it is being run as a service/daemon. func handleServiceControlAction(opts options, clientBuildFS fs.FS) { // Call chooseSystem expicitly to introduce OpenBSD support for service // package. It's a noop for other GOOS values. chooseSystem() action := opts.serviceControlAction log.Printf("Service control action: %s", action) if action == "reload" {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
prg := &program{ clientBuildFS: clientBuildFS, opts: runOpts, } s, err := service.New(prg, svcConfig) if err != nil { log.Fatal(err) } if action == "status" { handleServiceStatusCommand(s)
</s> remove if action == "status" { </s> add switch action { case "status": </s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil { </s> remove err := svcAction(s, "uninstall") if err != nil { </s> add if err := svcAction(s, "uninstall"); err != nil { </s> remove } else if action == "uninstall" { </s> add case "uninstall": </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil {
var s service.Service if s, err = service.New(prg, svcConfig); err != nil {
prg := &program{ clientBuildFS: clientBuildFS, opts: runOpts, } var s service.Service if s, err = service.New(prg, svcConfig); err != nil { var s service.Service if s, err = service.New(prg, svcConfig); err != nil { log.Fatal(err) } if action == "status" { handleServiceStatusCommand(s)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
if err != nil { log.Fatal(err) } if action == "status" { handleServiceStatusCommand(s) } else if action == "run" { err = s.Run() if err != nil { log.Fatalf("Failed to run service: %s", err)
</s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil { </s> remove } else if action == "install" { </s> add case "install": </s> remove s, err := service.New(prg, svcConfig) if err != nil { </s> add var s service.Service if s, err = service.New(prg, svcConfig); err != nil { </s> remove } else if action == "uninstall" { </s> add case "uninstall": </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil {
switch action { case "status":
if err != nil { log.Fatal(err) } switch action { case "status": handleServiceStatusCommand(s) } else if action == "run" { err = s.Run() if err != nil { log.Fatalf("Failed to run service: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
} if action == "status" { handleServiceStatusCommand(s) } else if action == "run" { err = s.Run() if err != nil { log.Fatalf("Failed to run service: %s", err) } } else if action == "install" { initConfigFilename(opts) initWorkingDir(opts)
</s> remove } else if action == "install" { </s> add case "install": </s> remove if action == "status" { </s> add switch action { case "status": </s> remove } else if action == "uninstall" { </s> add case "uninstall": </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil { </s> remove s, err := service.New(prg, svcConfig) if err != nil { </s> add var s service.Service if s, err = service.New(prg, svcConfig); err != nil {
case "run": if err = s.Run(); err != nil {
} if action == "status" { handleServiceStatusCommand(s) case "run": if err = s.Run(); err != nil { case "run": if err = s.Run(); err != nil { case "run": if err = s.Run(); err != nil { log.Fatalf("Failed to run service: %s", err) } } else if action == "install" { initConfigFilename(opts) initWorkingDir(opts)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
err = s.Run() if err != nil { log.Fatalf("Failed to run service: %s", err) } } else if action == "install" { initConfigFilename(opts) initWorkingDir(opts) handleServiceInstallCommand(s) } else if action == "uninstall" { handleServiceUninstallCommand(s)
</s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil { </s> remove } else if action == "uninstall" { </s> add case "uninstall": </s> remove if action == "status" { </s> add switch action { case "status": </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil { </s> remove // Start automatically after install </s> add // Start automatically after install.
case "install":
err = s.Run() if err != nil { log.Fatalf("Failed to run service: %s", err) } case "install": initConfigFilename(opts) initWorkingDir(opts) handleServiceInstallCommand(s) } else if action == "uninstall" { handleServiceUninstallCommand(s)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
} else if action == "install" { initConfigFilename(opts) initWorkingDir(opts) handleServiceInstallCommand(s) } else if action == "uninstall" { handleServiceUninstallCommand(s) } else { err = svcAction(s, action) if err != nil { log.Fatal(err)
</s> remove } else if action == "install" { </s> add case "install": </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil { </s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil { </s> remove if action == "status" { </s> add switch action { case "status": </s> remove err := svcAction(s, "uninstall") if err != nil { </s> add if err := svcAction(s, "uninstall"); err != nil {
case "uninstall":
} else if action == "install" { initConfigFilename(opts) initWorkingDir(opts) handleServiceInstallCommand(s) case "uninstall": handleServiceUninstallCommand(s) } else { err = svcAction(s, action) if err != nil { log.Fatal(err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
initWorkingDir(opts) handleServiceInstallCommand(s) } else if action == "uninstall" { handleServiceUninstallCommand(s) } else { err = svcAction(s, action) if err != nil { log.Fatal(err) } } log.Printf("Action %s has been done successfully on %s", action, service.ChosenSystem().String())
</s> remove } else if action == "uninstall" { </s> add case "uninstall": </s> remove log.Printf("Action %s has been done successfully on %s", action, service.ChosenSystem().String()) </s> add log.Printf("action %s has been done successfully on %s", action, service.ChosenSystem()) </s> remove } else if action == "install" { </s> add case "install": </s> remove // handleServiceStatusCommand handles service "status" command </s> add // handleServiceStatusCommand handles service "status" command. </s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil {
default: if err = svcAction(s, action); err != nil {
initWorkingDir(opts) handleServiceInstallCommand(s) } else if action == "uninstall" { handleServiceUninstallCommand(s) default: if err = svcAction(s, action); err != nil { default: if err = svcAction(s, action); err != nil { default: if err = svcAction(s, action); err != nil { log.Fatal(err) } } log.Printf("Action %s has been done successfully on %s", action, service.ChosenSystem().String())
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
log.Fatal(err) } } log.Printf("Action %s has been done successfully on %s", action, service.ChosenSystem().String()) } // handleServiceStatusCommand handles service "status" command func handleServiceStatusCommand(s service.Service) { status, errSt := svcStatus(s)
</s> remove // handleServiceStatusCommand handles service "status" command </s> add // handleServiceStatusCommand handles service "status" command. </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil { </s> remove // Start automatically after install </s> add // Start automatically after install. </s> remove // svcStatus check the service's status. </s> add // svcStatus returns the service's status.
log.Printf("action %s has been done successfully on %s", action, service.ChosenSystem())
log.Fatal(err) } } log.Printf("action %s has been done successfully on %s", action, service.ChosenSystem()) } // handleServiceStatusCommand handles service "status" command func handleServiceStatusCommand(s service.Service) { status, errSt := svcStatus(s)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
log.Printf("Action %s has been done successfully on %s", action, service.ChosenSystem().String()) } // handleServiceStatusCommand handles service "status" command func handleServiceStatusCommand(s service.Service) { status, errSt := svcStatus(s) if errSt != nil { log.Fatalf("failed to get service status: %s", errSt) }
</s> remove log.Printf("Action %s has been done successfully on %s", action, service.ChosenSystem().String()) </s> add log.Printf("action %s has been done successfully on %s", action, service.ChosenSystem()) </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil { </s> remove // Start automatically after install </s> add // Start automatically after install. </s> remove // On OpenWrt it is important to run enable after the service installation // Otherwise, the service won't start on the system startup </s> add // On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup. </s> remove // svcStatus check the service's status. </s> add // svcStatus returns the service's status.
// handleServiceStatusCommand handles service "status" command.
log.Printf("Action %s has been done successfully on %s", action, service.ChosenSystem().String()) } // handleServiceStatusCommand handles service "status" command. func handleServiceStatusCommand(s service.Service) { status, errSt := svcStatus(s) if errSt != nil { log.Fatalf("failed to get service status: %s", errSt) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
log.Fatal(err) } if aghos.IsOpenWrt() { // On OpenWrt it is important to run enable after the service installation // Otherwise, the service won't start on the system startup _, err = runInitdCommand("enable") if err != nil { log.Fatal(err) } }
</s> remove // Start automatically after install </s> add // Start automatically after install. </s> remove err := svcAction(s, "uninstall") if err != nil { </s> add if err := svcAction(s, "uninstall"); err != nil { </s> remove if action == "status" { </s> add switch action { case "status": </s> remove // svcStatus check the service's status. </s> add // svcStatus returns the service's status. </s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil {
// On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup.
log.Fatal(err) } if aghos.IsOpenWrt() { // On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup. // On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup. _, err = runInitdCommand("enable") if err != nil { log.Fatal(err) } }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
log.Fatal(err) } } // Start automatically after install err = svcAction(s, "start") if err != nil { log.Fatalf("Failed to start the service: %s", err) } log.Printf("Service has been started")
</s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil { </s> remove // On OpenWrt it is important to run enable after the service installation // Otherwise, the service won't start on the system startup </s> add // On OpenWrt it is important to run enable after the service // installation Otherwise, the service won't start on the system // startup. </s> remove if action == "status" { </s> add switch action { case "status": </s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil { </s> remove } else if action == "install" { </s> add case "install":
// Start automatically after install.
log.Fatal(err) } } // Start automatically after install. err = svcAction(s, "start") if err != nil { log.Fatalf("Failed to start the service: %s", err) } log.Printf("Service has been started")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
log.Fatal(err) } } err := svcAction(s, "uninstall") if err != nil { log.Fatal(err) } if runtime.GOOS == "darwin" { // Remove log files on cleanup and log errors.
</s> remove err = os.Remove(launchdStdoutPath) </s> add err := os.Remove(launchdStdoutPath) </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil { </s> remove } else if action == "uninstall" { </s> add case "uninstall": </s> remove s, err := service.New(prg, svcConfig) if err != nil { </s> add var s service.Service if s, err = service.New(prg, svcConfig); err != nil { </s> remove if action == "status" { </s> add switch action { case "status":
if err := svcAction(s, "uninstall"); err != nil {
log.Fatal(err) } } if err := svcAction(s, "uninstall"); err != nil { if err := svcAction(s, "uninstall"); err != nil { log.Fatal(err) } if runtime.GOOS == "darwin" { // Remove log files on cleanup and log errors.
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
} if runtime.GOOS == "darwin" { // Remove log files on cleanup and log errors. err = os.Remove(launchdStdoutPath) if err != nil && !errors.Is(err, os.ErrNotExist) { log.Printf("removing stdout file: %s", err) } err = os.Remove(launchdStderrPath)
</s> remove err := svcAction(s, "uninstall") if err != nil { </s> add if err := svcAction(s, "uninstall"); err != nil { </s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil { </s> remove if action == "status" { </s> add switch action { case "status": </s> remove } else { err = svcAction(s, action) if err != nil { </s> add default: if err = svcAction(s, action); err != nil { </s> remove } else if action == "install" { </s> add case "install":
err := os.Remove(launchdStdoutPath)
} if runtime.GOOS == "darwin" { // Remove log files on cleanup and log errors. err := os.Remove(launchdStdoutPath) if err != nil && !errors.Is(err, os.ErrNotExist) { log.Printf("removing stdout file: %s", err) } err = os.Remove(launchdStderrPath)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
} else if runtime.GOOS == "freebsd" { c.Option["SysvScript"] = freeBSDScript } } // runInitdCommand runs init.d service command // returns command code or error if any
</s> remove // handleServiceStatusCommand handles service "status" command </s> add // handleServiceStatusCommand handles service "status" command. </s> remove // TODO(a.garipov): github.com/kardianos/service doesn't seem to // support OpenBSD currently. Either patch it to do so or make // our own implementation of the service.System interface. if runtime.GOOS == "openbsd" { log.Fatal("service actions are not supported on openbsd, see issue 3226") } </s> add </s> remove } else if action == "run" { err = s.Run() if err != nil { </s> add case "run": if err = s.Run(); err != nil { </s> remove } else if action == "uninstall" { </s> add case "uninstall": </s> remove err := svcAction(s, "uninstall") if err != nil { </s> add if err := svcAction(s, "uninstall"); err != nil {
c.Option["RunComScript"] = openBSDScript c.Option["SvcInfo"] = fmt.Sprintf("%s %s", version.Full(), time.Now())
} else if runtime.GOOS == "freebsd" { c.Option["SysvScript"] = freeBSDScript } c.Option["RunComScript"] = openBSDScript c.Option["SvcInfo"] = fmt.Sprintf("%s %s", version.Full(), time.Now()) } // runInitdCommand runs init.d service command // returns command code or error if any
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 3226 support service on OpenBSD Merge in DNS/adguard-home from 3226-openbsd-svc to master Closes #3226. Squashed commit of the following: commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:43:31 2021 +0300 aghos: imp code commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8 Merge: 9e9225ec b92db25e Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:09:00 2021 +0300 Merge branch 'master' into 3226-openbsd-svc commit 9e9225ecb2af30fe46999b43c0683e4b3c946778 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 17:02:52 2021 +0300 home: fix lil bugs commit 03456f9a09081c6178dca0ac9887590b5d24f333 Author: Eugene Burkov <[email protected]> Date: Tue Aug 24 16:18:48 2021 +0300 home: imp code commit 5cdf4fcbae78c07b663190012228003fe94bfdee Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 23:32:15 2021 +0300 home: imp code, docs commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341 Author: Eugene Burkov <[email protected]> Date: Fri Aug 20 14:01:53 2021 +0300 home: sup service on openbsd
https://github.com/AdguardTeam/AdGuardHome/commit/16092e8ba9f2064f9e92374c77a804271741a051
internal/home/service.go
// prepare prepares the a new or decoded entry. func (r *RewriteEntry) prepare() { switch r.Answer { case "AAAA": r.IP = nil r.Type = dns.TypeAAAA
</s> remove assert.Equal(t, Rewritten, r.Reason) </s> add assert.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason) </s> remove require.Equal(t, Rewritten, r.Reason) </s> add require.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason)
// TODO(a.garipov): Write a case-agnostic version of strings.HasSuffix // and use it in matchDomainWildcard instead of using strings.ToLower // everywhere. r.Domain = strings.ToLower(r.Domain)
// prepare prepares the a new or decoded entry. func (r *RewriteEntry) prepare() { // TODO(a.garipov): Write a case-agnostic version of strings.HasSuffix // and use it in matchDomainWildcard instead of using strings.ToLower // everywhere. r.Domain = strings.ToLower(r.Domain) switch r.Answer { case "AAAA": r.IP = nil r.Type = dns.TypeAAAA
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite domain case Updates #3351. Squashed commit of the following: commit cc1c72cc13026ed703bb140e55dc3eb886846e48 Author: Ainar Garipov <[email protected]> Date: Tue Jul 13 17:23:33 2021 +0300 filtering: fix legacy rewrite domain case
https://github.com/AdguardTeam/AdGuardHome/commit/167447547aa52cfa01b48680d13aff73ba64fb42
internal/filtering/rewrites.go
Answer: "1.2.3.6", }, { Domain: "*.hostboth.com", Answer: "1234::5678", }} d.prepareRewrites() testCases := []struct { name string host string
</s> remove assert.Equal(t, Rewritten, r.Reason) </s> add assert.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason) </s> remove require.Equal(t, Rewritten, r.Reason) </s> add require.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason)
}, { Domain: "BIGHOST.COM", Answer: "1.2.3.7",
Answer: "1.2.3.6", }, { Domain: "*.hostboth.com", Answer: "1234::5678", }, { Domain: "BIGHOST.COM", Answer: "1.2.3.7", }} d.prepareRewrites() testCases := []struct { name string host string
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite domain case Updates #3351. Squashed commit of the following: commit cc1c72cc13026ed703bb140e55dc3eb886846e48 Author: Ainar Garipov <[email protected]> Date: Tue Jul 13 17:23:33 2021 +0300 filtering: fix legacy rewrite domain case
https://github.com/AdguardTeam/AdGuardHome/commit/167447547aa52cfa01b48680d13aff73ba64fb42
internal/filtering/rewrites_test.go
wantVals: []net.IP{net.ParseIP("1234::5678")}, dtyp: dns.TypeAAAA, }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { valsNum := len(tc.wantVals)
</s> remove assert.Equal(t, Rewritten, r.Reason) </s> add assert.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason) </s> remove require.Equal(t, Rewritten, r.Reason) </s> add require.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason)
}, { name: "issue3351", host: "bighost.com", wantCName: "", wantVals: []net.IP{{1, 2, 3, 7}}, dtyp: dns.TypeA,
wantVals: []net.IP{net.ParseIP("1234::5678")}, dtyp: dns.TypeAAAA, }, { name: "issue3351", host: "bighost.com", wantCName: "", wantVals: []net.IP{{1, 2, 3, 7}}, dtyp: dns.TypeA, }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { valsNum := len(tc.wantVals)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite domain case Updates #3351. Squashed commit of the following: commit cc1c72cc13026ed703bb140e55dc3eb886846e48 Author: Ainar Garipov <[email protected]> Date: Tue Jul 13 17:23:33 2021 +0300 filtering: fix legacy rewrite domain case
https://github.com/AdguardTeam/AdGuardHome/commit/167447547aa52cfa01b48680d13aff73ba64fb42
internal/filtering/rewrites_test.go
return } require.Equal(t, Rewritten, r.Reason) if tc.wantCName != "" { assert.Equal(t, tc.wantCName, r.CanonName) } require.Len(t, r.IPList, valsNum)
</s> remove assert.Equal(t, Rewritten, r.Reason) </s> add assert.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason)
require.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason)
return } require.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason) if tc.wantCName != "" { assert.Equal(t, tc.wantCName, r.CanonName) } require.Len(t, r.IPList, valsNum)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite domain case Updates #3351. Squashed commit of the following: commit cc1c72cc13026ed703bb140e55dc3eb886846e48 Author: Ainar Garipov <[email protected]> Date: Tue Jul 13 17:23:33 2021 +0300 filtering: fix legacy rewrite domain case
https://github.com/AdguardTeam/AdGuardHome/commit/167447547aa52cfa01b48680d13aff73ba64fb42
internal/filtering/rewrites_test.go
return } assert.Equal(t, Rewritten, r.Reason) require.Len(t, r.IPList, len(tc.want)) for _, ip := range tc.want { assert.True(t, ip.Equal(r.IPList[0]))
</s> remove require.Equal(t, Rewritten, r.Reason) </s> add require.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason)
assert.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason)
return } assert.Equalf(t, Rewritten, r.Reason, "got %s", r.Reason) require.Len(t, r.IPList, len(tc.want)) for _, ip := range tc.want { assert.True(t, ip.Equal(r.IPList[0]))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite domain case Updates #3351. Squashed commit of the following: commit cc1c72cc13026ed703bb140e55dc3eb886846e48 Author: Ainar Garipov <[email protected]> Date: Tue Jul 13 17:23:33 2021 +0300 filtering: fix legacy rewrite domain case
https://github.com/AdguardTeam/AdGuardHome/commit/167447547aa52cfa01b48680d13aff73ba64fb42
internal/filtering/rewrites_test.go
go 1.16 require ( github.com/AdguardTeam/dnsproxy v0.39.5 github.com/AdguardTeam/golibs v0.9.2 github.com/AdguardTeam/urlfilter v0.14.6 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.2.2 github.com/digineo/go-ipset/v2 v2.2.1 github.com/fsnotify/fsnotify v1.4.9
</s> remove github.com/AdguardTeam/golibs v0.9.2 h1:H3BDFkaosxvb+UgFlNVyN66GZ+JglcZULnJ7z7PukyQ= </s> add </s> remove // ServerAddresses is a list of plain DNS server IP addresses used to // resolve the hostname in ServerURL or ServerName. ServerAddresses []string `plist:",omitempty"` </s> add // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"`
github.com/AdguardTeam/golibs v0.9.3
go 1.16 require ( github.com/AdguardTeam/dnsproxy v0.39.5 github.com/AdguardTeam/golibs v0.9.3 github.com/AdguardTeam/urlfilter v0.14.6 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.2.2 github.com/digineo/go-ipset/v2 v2.2.1 github.com/fsnotify/fsnotify v1.4.9
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
go.mod
github.com/AdguardTeam/dnsproxy v0.39.5 h1:SQorhRLR1241t6hy9CiAGZUjRULhsDJlPJTl0UGX8uw= github.com/AdguardTeam/dnsproxy v0.39.5/go.mod h1:eDpJKAdkHORRwAedjuERv+7SWlcz4cn+5uwrbUAWHRY= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.9.2 h1:H3BDFkaosxvb+UgFlNVyN66GZ+JglcZULnJ7z7PukyQ= github.com/AdguardTeam/golibs v0.9.2/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.14.6 h1:emqoKZElooHACYehRBYENeKVN1a/rspxiqTIMYLuoIo= github.com/AdguardTeam/urlfilter v0.14.6/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
</s> remove github.com/AdguardTeam/golibs v0.9.2 </s> add github.com/AdguardTeam/golibs v0.9.3 </s> remove // ServerAddresses is a list of plain DNS server IP addresses used to // resolve the hostname in ServerURL or ServerName. ServerAddresses []string `plist:",omitempty"` </s> add // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"` </s> remove Port: 53, </s> add Port: defaultPortDNS, </s> remove PortHTTPS: 443, PortDNSOverTLS: 853, // needs to be passed through to dnsproxy PortDNSOverQUIC: 784, </s> add PortHTTPS: defaultPortHTTPS, PortDNSOverTLS: defaultPortTLS, // needs to be passed through to dnsproxy PortDNSOverQUIC: defaultPortQUIC,
github.com/AdguardTeam/dnsproxy v0.39.5 h1:SQorhRLR1241t6hy9CiAGZUjRULhsDJlPJTl0UGX8uw= github.com/AdguardTeam/dnsproxy v0.39.5/go.mod h1:eDpJKAdkHORRwAedjuERv+7SWlcz4cn+5uwrbUAWHRY= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.9.2/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.14.6 h1:emqoKZElooHACYehRBYENeKVN1a/rspxiqTIMYLuoIo= github.com/AdguardTeam/urlfilter v0.14.6/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
go.sum
github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.9.2/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.14.6 h1:emqoKZElooHACYehRBYENeKVN1a/rspxiqTIMYLuoIo= github.com/AdguardTeam/urlfilter v0.14.6/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
</s> remove github.com/AdguardTeam/golibs v0.9.2 h1:H3BDFkaosxvb+UgFlNVyN66GZ+JglcZULnJ7z7PukyQ= </s> add </s> remove github.com/AdguardTeam/golibs v0.9.2 </s> add github.com/AdguardTeam/golibs v0.9.3 </s> remove // ServerAddresses is a list of plain DNS server IP addresses used to // resolve the hostname in ServerURL or ServerName. ServerAddresses []string `plist:",omitempty"` </s> add // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"` </s> remove Port: 53, </s> add Port: defaultPortDNS, </s> remove PortHTTPS: 443, PortDNSOverTLS: 853, // needs to be passed through to dnsproxy PortDNSOverQUIC: 784, </s> add PortHTTPS: defaultPortHTTPS, PortDNSOverTLS: defaultPortTLS, // needs to be passed through to dnsproxy PortDNSOverQUIC: defaultPortQUIC,
github.com/AdguardTeam/golibs v0.9.3 h1:noeKHJEzrSwxzX0Zi3USM3cXf1qQV99SO772jet/uEY= github.com/AdguardTeam/golibs v0.9.3/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY=
github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.9.2/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY= github.com/AdguardTeam/golibs v0.9.3 h1:noeKHJEzrSwxzX0Zi3USM3cXf1qQV99SO772jet/uEY= github.com/AdguardTeam/golibs v0.9.3/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.14.6 h1:emqoKZElooHACYehRBYENeKVN1a/rspxiqTIMYLuoIo= github.com/AdguardTeam/urlfilter v0.14.6/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
go.sum
AuthAttempts: 5, AuthBlockMin: 15, DNS: dnsConfig{ BindHosts: []net.IP{{0, 0, 0, 0}}, Port: 53, StatsInterval: 1, FilteringConfig: dnsforward.FilteringConfig{ ProtectionEnabled: true, // whether or not use any of filtering features BlockingMode: "default", // mode how to answer filtered requests BlockedResponseTTL: 10, // in seconds
</s> remove FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, </s> add BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, </s> remove PortHTTPS: 443, PortDNSOverTLS: 853, // needs to be passed through to dnsproxy PortDNSOverQUIC: 784, </s> add PortHTTPS: defaultPortHTTPS, PortDNSOverTLS: defaultPortTLS, // needs to be passed through to dnsproxy PortDNSOverQUIC: defaultPortQUIC, </s> remove // ServerAddresses is a list of plain DNS server IP addresses used to // resolve the hostname in ServerURL or ServerName. ServerAddresses []string `plist:",omitempty"` </s> add // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"`
Port: defaultPortDNS,
AuthAttempts: 5, AuthBlockMin: 15, DNS: dnsConfig{ BindHosts: []net.IP{{0, 0, 0, 0}}, Port: defaultPortDNS, StatsInterval: 1, FilteringConfig: dnsforward.FilteringConfig{ ProtectionEnabled: true, // whether or not use any of filtering features BlockingMode: "default", // mode how to answer filtered requests BlockedResponseTTL: 10, // in seconds
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/config.go
ResolveClients: true, UsePrivateRDNS: true, }, TLS: tlsConfigSettings{ PortHTTPS: 443, PortDNSOverTLS: 853, // needs to be passed through to dnsproxy PortDNSOverQUIC: 784, }, logSettings: logSettings{ LogCompress: false, LogLocalTime: false, LogMaxBackups: 0,
</s> remove Port: 53, </s> add Port: defaultPortDNS, </s> remove const defaultHTTPSPort = 443 </s> add </s> remove FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, </s> add BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, </s> remove // ServerAddresses is a list of plain DNS server IP addresses used to // resolve the hostname in ServerURL or ServerName. ServerAddresses []string `plist:",omitempty"` </s> add // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"`
PortHTTPS: defaultPortHTTPS, PortDNSOverTLS: defaultPortTLS, // needs to be passed through to dnsproxy PortDNSOverQUIC: defaultPortQUIC,
ResolveClients: true, UsePrivateRDNS: true, }, TLS: tlsConfigSettings{ PortHTTPS: defaultPortHTTPS, PortDNSOverTLS: defaultPortTLS, // needs to be passed through to dnsproxy PortDNSOverQUIC: defaultPortQUIC, PortHTTPS: defaultPortHTTPS, PortDNSOverTLS: defaultPortTLS, // needs to be passed through to dnsproxy PortDNSOverQUIC: defaultPortQUIC, PortHTTPS: defaultPortHTTPS, PortDNSOverTLS: defaultPortTLS, // needs to be passed through to dnsproxy PortDNSOverQUIC: defaultPortQUIC, }, logSettings: logSettings{ LogCompress: false, LogLocalTime: false, LogMaxBackups: 0,
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/config.go
// addresses to a slice of strings. func appendDNSAddrs(dst []string, addrs ...net.IP) (res []string) { for _, addr := range addrs { var hostport string if config.DNS.Port != 53 { hostport = netutil.JoinHostPort(addr.String(), config.DNS.Port) } else { hostport = addr.String() }
</s> remove // cloneBootstrap returns a clone of the current bootstrap DNS servers. func cloneBootstrap() (bootstrap []string) { config.RLock() defer config.RUnlock() return stringutil.CloneSlice(config.DNS.BootstrapDNS) } </s> add </s> remove if tlsConf.PortHTTPS != 443 { </s> add if tlsConf.PortHTTPS != defaultPortHTTPS { </s> remove // testBootstrapDNS are the bootstrap plain DNS server addresses for tests. var testBootstrapDNS = []string{ "94.140.14.14", "94.140.15.15", } // setupBootstraps is a helper that sets up the bootstrap plain DNS server // configuration for tests and also tears it down in a cleanup function. func setupBootstraps(t testing.TB) { </s> add // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { </s> remove // ServerAddresses is a list of plain DNS server IP addresses used to // resolve the hostname in ServerURL or ServerName. ServerAddresses []string `plist:",omitempty"` </s> add // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"` </s> remove if port := web.conf.PortHTTPS; port != defaultHTTPSPort { </s> add if port := web.conf.PortHTTPS; port != defaultPortHTTPS {
if config.DNS.Port != defaultPortDNS {
// addresses to a slice of strings. func appendDNSAddrs(dst []string, addrs ...net.IP) (res []string) { for _, addr := range addrs { var hostport string if config.DNS.Port != defaultPortDNS { hostport = netutil.JoinHostPort(addr.String(), config.DNS.Port) } else { hostport = addr.String() }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/control.go
func preInstallHandler(handler http.Handler) http.Handler { return &preInstallHandlerStruct{handler} } const defaultHTTPSPort = 443 // handleHTTPSRedirect redirects the request to HTTPS, if needed. If ok is // true, the middleware must continue handling the request. func handleHTTPSRedirect(w http.ResponseWriter, r *http.Request) (ok bool) { web := Context.web if web.httpsServer.server == nil {
</s> remove // cloneBootstrap returns a clone of the current bootstrap DNS servers. func cloneBootstrap() (bootstrap []string) { config.RLock() defer config.RUnlock() return stringutil.CloneSlice(config.DNS.BootstrapDNS) } </s> add </s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS </s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS </s> remove if port := web.conf.PortHTTPS; port != defaultHTTPSPort { </s> add if port := web.conf.PortHTTPS; port != defaultPortHTTPS {
func preInstallHandler(handler http.Handler) http.Handler { return &preInstallHandlerStruct{handler} } // handleHTTPSRedirect redirects the request to HTTPS, if needed. If ok is // true, the middleware must continue handling the request. func handleHTTPSRedirect(w http.ResponseWriter, r *http.Request) (ok bool) { web := Context.web if web.httpsServer.server == nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/control.go
} if r.TLS == nil && web.forceHTTPS { hostPort := host if port := web.conf.PortHTTPS; port != defaultHTTPSPort { hostPort = netutil.JoinHostPort(host, port) } httpsURL := &url.URL{ Scheme: schemeHTTPS,
</s> remove if tlsConf.PortHTTPS != 443 { </s> add if tlsConf.PortHTTPS != defaultPortHTTPS { </s> remove const defaultHTTPSPort = 443 </s> add </s> remove ServerAddresses: cloneBootstrap(), </s> add ServerAddresses: dnsIPs, </s> remove if config.DNS.Port != 53 { </s> add if config.DNS.Port != defaultPortDNS {
if port := web.conf.PortHTTPS; port != defaultPortHTTPS {
} if r.TLS == nil && web.forceHTTPS { hostPort := host if port := web.conf.PortHTTPS; port != defaultPortHTTPS { hostPort = netutil.JoinHostPort(host, port) } httpsURL := &url.URL{ Scheme: schemeHTTPS,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/control.go
// handleInstallGetAddresses is the handler for /install/get_addresses endpoint. func (web *Web) handleInstallGetAddresses(w http.ResponseWriter, r *http.Request) { data := getAddrsResponse{} data.WebPort = 80 data.DNSPort = 53 ifaces, err := aghnet.GetValidNetInterfacesForWeb() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return
</s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS </s> remove const defaultHTTPSPort = 443 </s> add </s> remove ServerAddresses: cloneBootstrap(), </s> add ServerAddresses: dnsIPs, </s> remove // cloneBootstrap returns a clone of the current bootstrap DNS servers. func cloneBootstrap() (bootstrap []string) { config.RLock() defer config.RUnlock() return stringutil.CloneSlice(config.DNS.BootstrapDNS) } </s> add
data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS
// handleInstallGetAddresses is the handler for /install/get_addresses endpoint. func (web *Web) handleInstallGetAddresses(w http.ResponseWriter, r *http.Request) { data := getAddrsResponse{} data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS ifaces, err := aghnet.GetValidNetInterfacesForWeb() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/controlinstall.go
// 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{} data.WebPort = 80 data.DNSPort = 53 ifaces, err := aghnet.GetValidNetInterfacesForWeb() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return
</s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS </s> remove const defaultHTTPSPort = 443 </s> add </s> remove // cloneBootstrap returns a clone of the current bootstrap DNS servers. func cloneBootstrap() (bootstrap []string) { config.RLock() defer config.RUnlock() return stringutil.CloneSlice(config.DNS.BootstrapDNS) } </s> add </s> remove ServerAddresses: cloneBootstrap(), </s> add ServerAddresses: dnsIPs,
data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS
// 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{} data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS ifaces, err := aghnet.GetValidNetInterfacesForWeb() if err != nil { httpError(w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) return
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/controlinstall.go
yaml "gopkg.in/yaml.v2" ) // Called by other modules when configuration is changed func onConfigModified() { _ = config.write() }
</s> remove // testBootstrapDNS are the bootstrap plain DNS server addresses for tests. var testBootstrapDNS = []string{ "94.140.14.14", "94.140.15.15", } // setupBootstraps is a helper that sets up the bootstrap plain DNS server // configuration for tests and also tears it down in a cleanup function. func setupBootstraps(t testing.TB) { </s> add // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { </s> remove // cloneBootstrap returns a clone of the current bootstrap DNS servers. func cloneBootstrap() (bootstrap []string) { config.RLock() defer config.RUnlock() return stringutil.CloneSlice(config.DNS.BootstrapDNS) } </s> add </s> remove "github.com/AdguardTeam/golibs/stringutil" </s> add </s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS
// Default ports. const ( defaultPortDNS = 53 defaultPortHTTP = 80 defaultPortHTTPS = 443 defaultPortQUIC = 784 defaultPortTLS = 853 )
yaml "gopkg.in/yaml.v2" ) // Default ports. const ( defaultPortDNS = 53 defaultPortHTTP = 80 defaultPortHTTPS = 443 defaultPortQUIC = 784 defaultPortTLS = 853 ) // Called by other modules when configuration is changed func onConfigModified() { _ = config.write() }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/dns.go
if tlsConf.Enabled && len(tlsConf.ServerName) != 0 { hostname := tlsConf.ServerName if tlsConf.PortHTTPS != 0 { addr := hostname if tlsConf.PortHTTPS != 443 { addr = netutil.JoinHostPort(addr, tlsConf.PortHTTPS) } de.https = (&url.URL{ Scheme: "https",
</s> remove if port := web.conf.PortHTTPS; port != defaultHTTPSPort { </s> add if port := web.conf.PortHTTPS; port != defaultPortHTTPS { </s> remove if config.DNS.Port != 53 { </s> add if config.DNS.Port != defaultPortDNS { </s> remove ServerAddresses: cloneBootstrap(), </s> add ServerAddresses: dnsIPs, </s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS </s> remove const defaultHTTPSPort = 443 </s> add
if tlsConf.PortHTTPS != defaultPortHTTPS {
if tlsConf.Enabled && len(tlsConf.ServerName) != 0 { hostname := tlsConf.ServerName if tlsConf.PortHTTPS != 0 { addr := hostname if tlsConf.PortHTTPS != defaultPortHTTPS { addr = netutil.JoinHostPort(addr, tlsConf.PortHTTPS) } de.https = (&url.URL{ Scheme: "https",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/dns.go
import ( "encoding/json" "fmt" "net/http" "net/url" "path" "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/golibs/errors"
</s> remove "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" </s> add "github.com/AdguardTeam/golibs/netutil" </s> remove "github.com/AdguardTeam/golibs/stringutil" </s> add </s> remove github.com/AdguardTeam/golibs v0.9.2 </s> add github.com/AdguardTeam/golibs v0.9.3
"net"
import ( "encoding/json" "fmt" "net" "net/http" "net/url" "path" "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/golibs/errors"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig.go
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/stringutil" uuid "github.com/satori/go.uuid" "howett.net/plist" ) // dnsSettings is the DNSSetting.DNSSettings mobileconfig profile.
</s> remove "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" </s> add "github.com/AdguardTeam/golibs/netutil" </s> remove // testBootstrapDNS are the bootstrap plain DNS server addresses for tests. var testBootstrapDNS = []string{ "94.140.14.14", "94.140.15.15", } // setupBootstraps is a helper that sets up the bootstrap plain DNS server // configuration for tests and also tears it down in a cleanup function. func setupBootstraps(t testing.TB) { </s> add // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { </s> remove // ServerAddresses is a list of plain DNS server IP addresses used to // resolve the hostname in ServerURL or ServerName. ServerAddresses []string `plist:",omitempty"` </s> add // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"`
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" uuid "github.com/satori/go.uuid" "howett.net/plist" ) // dnsSettings is the DNSSetting.DNSSettings mobileconfig profile.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig.go
// ServerName is the hostname of the DoT server. It must be empty if // DNSProtocol is not "TLS". ServerName string `plist:",omitempty"` // ServerAddresses is a list of plain DNS server IP addresses used to // resolve the hostname in ServerURL or ServerName. ServerAddresses []string `plist:",omitempty"` } // payloadContent is a Device Management Profile payload. // // See https://developer.apple.com/documentation/devicemanagement/configuring_multiple_devices_using_profiles#3234127.
</s> remove // testBootstrapDNS are the bootstrap plain DNS server addresses for tests. var testBootstrapDNS = []string{ "94.140.14.14", "94.140.15.15", } // setupBootstraps is a helper that sets up the bootstrap plain DNS server // configuration for tests and also tears it down in a cleanup function. func setupBootstraps(t testing.TB) { </s> add // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { </s> remove const defaultHTTPSPort = 443 </s> add </s> remove if config.DNS.Port != 53 { </s> add if config.DNS.Port != defaultPortDNS { </s> remove Port: 53, </s> add Port: defaultPortDNS,
// ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"`
// ServerName is the hostname of the DoT server. It must be empty if // DNSProtocol is not "TLS". ServerName string `plist:",omitempty"` // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"` // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"` // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"` } // payloadContent is a Device Management Profile payload. // // See https://developer.apple.com/documentation/devicemanagement/configuring_multiple_devices_using_profiles#3234127.
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig.go
return } } d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: dnsIPs, }
</s> remove ServerAddresses: cloneBootstrap(), </s> add ServerAddresses: dnsIPs, </s> remove // cloneBootstrap returns a clone of the current bootstrap DNS servers. func cloneBootstrap() (bootstrap []string) { config.RLock() defer config.RUnlock() return stringutil.CloneSlice(config.DNS.BootstrapDNS) } </s> add </s> remove setupBootstraps(t) </s> add setupDNSIPs(t) </s> remove if port := web.conf.PortHTTPS; port != defaultHTTPSPort { </s> add if port := web.conf.PortHTTPS; port != defaultPortHTTPS {
dnsIPs, err := collectDNSIPs() if err != nil { // Don't add a lot of formatting, since the error is already // wrapped by collectDNSIPs. respondJSONError(w, http.StatusInternalServerError, err.Error()) return }
return } } dnsIPs, err := collectDNSIPs() if err != nil { // Don't add a lot of formatting, since the error is already // wrapped by collectDNSIPs. respondJSONError(w, http.StatusInternalServerError, err.Error()) return } d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: dnsIPs, }
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig.go
d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: cloneBootstrap(), } mobileconfig, err := encodeMobileConfig(d, clientID) if err != nil { respondJSONError(w, http.StatusInternalServerError, err.Error())
</s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS </s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS </s> remove if port := web.conf.PortHTTPS; port != defaultHTTPSPort { </s> add if port := web.conf.PortHTTPS; port != defaultPortHTTPS { </s> remove if tlsConf.PortHTTPS != 443 { </s> add if tlsConf.PortHTTPS != defaultPortHTTPS {
ServerAddresses: dnsIPs,
d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: dnsIPs, } mobileconfig, err := encodeMobileConfig(d, clientID) if err != nil { respondJSONError(w, http.StatusInternalServerError, err.Error())
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig.go
_, _ = w.Write(mobileconfig) } // cloneBootstrap returns a clone of the current bootstrap DNS servers. func cloneBootstrap() (bootstrap []string) { config.RLock() defer config.RUnlock() return stringutil.CloneSlice(config.DNS.BootstrapDNS) } func handleMobileConfigDoH(w http.ResponseWriter, r *http.Request) { handleMobileConfig(w, r, dnsProtoHTTPS) } func handleMobileConfigDoT(w http.ResponseWriter, r *http.Request) {
</s> remove const defaultHTTPSPort = 443 </s> add </s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS </s> remove if config.DNS.Port != 53 { </s> add if config.DNS.Port != defaultPortDNS { </s> remove data.WebPort = 80 data.DNSPort = 53 </s> add data.WebPort = defaultPortHTTP data.DNSPort = defaultPortDNS </s> remove // testBootstrapDNS are the bootstrap plain DNS server addresses for tests. var testBootstrapDNS = []string{ "94.140.14.14", "94.140.15.15", } // setupBootstraps is a helper that sets up the bootstrap plain DNS server // configuration for tests and also tears it down in a cleanup function. func setupBootstraps(t testing.TB) { </s> add // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) {
_, _ = w.Write(mobileconfig) } func handleMobileConfigDoH(w http.ResponseWriter, r *http.Request) { handleMobileConfig(w, r, dnsProtoHTTPS) } func handleMobileConfigDoT(w http.ResponseWriter, r *http.Request) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig.go
"bytes" "encoding/json" "net/http" "net/http/httptest" "testing" "github.com/AdguardTeam/golibs/netutil" "github.com/stretchr/testify/assert"
</s> remove "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" </s> add "github.com/AdguardTeam/golibs/netutil" </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove "github.com/AdguardTeam/golibs/stringutil" </s> add </s> remove github.com/AdguardTeam/golibs v0.9.2 h1:H3BDFkaosxvb+UgFlNVyN66GZ+JglcZULnJ7z7PukyQ= </s> add
"net"
"bytes" "encoding/json" "net" "net/http" "net/http/httptest" "testing" "github.com/AdguardTeam/golibs/netutil" "github.com/stretchr/testify/assert"
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
"net/http" "net/http/httptest" "testing" "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "howett.net/plist" )
</s> remove "github.com/AdguardTeam/golibs/stringutil" </s> add </s> remove // testBootstrapDNS are the bootstrap plain DNS server addresses for tests. var testBootstrapDNS = []string{ "94.140.14.14", "94.140.15.15", } // setupBootstraps is a helper that sets up the bootstrap plain DNS server // configuration for tests and also tears it down in a cleanup function. func setupBootstraps(t testing.TB) { </s> add // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) {
"github.com/AdguardTeam/golibs/netutil"
"net/http" "net/http/httptest" "testing" "github.com/AdguardTeam/golibs/netutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "howett.net/plist" )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
"github.com/stretchr/testify/require" "howett.net/plist" ) // testBootstrapDNS are the bootstrap plain DNS server addresses for tests. var testBootstrapDNS = []string{ "94.140.14.14", "94.140.15.15", } // setupBootstraps is a helper that sets up the bootstrap plain DNS server // configuration for tests and also tears it down in a cleanup function. func setupBootstraps(t testing.TB) { t.Helper() prevConfig := config t.Cleanup(func() { config = prevConfig
</s> remove // ServerAddresses is a list of plain DNS server IP addresses used to // resolve the hostname in ServerURL or ServerName. ServerAddresses []string `plist:",omitempty"` </s> add // ServerAddresses is a list IP addresses of the server. ServerAddresses []net.IP `plist:",omitempty"` </s> remove // cloneBootstrap returns a clone of the current bootstrap DNS servers. func cloneBootstrap() (bootstrap []string) { config.RLock() defer config.RUnlock() return stringutil.CloneSlice(config.DNS.BootstrapDNS) } </s> add </s> remove if config.DNS.Port != 53 { </s> add if config.DNS.Port != defaultPortDNS {
// setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) {
"github.com/stretchr/testify/require" "howett.net/plist" ) // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { t.Helper() prevConfig := config t.Cleanup(func() { config = prevConfig
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
func setupDNSIPs(t testing.TB) { t.Helper() prevConfig := config t.Cleanup(func() { config = prevConfig Context.tls = prevTLS }) config = &configuration{
</s> remove FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, </s> add BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, </s> remove // testBootstrapDNS are the bootstrap plain DNS server addresses for tests. var testBootstrapDNS = []string{ "94.140.14.14", "94.140.15.15", } // setupBootstraps is a helper that sets up the bootstrap plain DNS server // configuration for tests and also tears it down in a cleanup function. func setupBootstraps(t testing.TB) { </s> add // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) { </s> remove setupBootstraps(t) </s> add setupDNSIPs(t)
prevTLS := Context.tls
func setupDNSIPs(t testing.TB) { t.Helper() prevConfig := config prevTLS := Context.tls t.Cleanup(func() { config = prevConfig Context.tls = prevTLS }) config = &configuration{
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
t.Cleanup(func() { config = prevConfig }) config = &configuration{ DNS: dnsConfig{ BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS,
</s> remove FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, </s> add BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, </s> remove Port: 53, </s> add Port: defaultPortDNS, </s> remove // testBootstrapDNS are the bootstrap plain DNS server addresses for tests. var testBootstrapDNS = []string{ "94.140.14.14", "94.140.15.15", } // setupBootstraps is a helper that sets up the bootstrap plain DNS server // configuration for tests and also tears it down in a cleanup function. func setupBootstraps(t testing.TB) { </s> add // setupDNSIPs is a helper that sets up the server IP address configuration for // tests and also tears it down in a cleanup function. func setupDNSIPs(t testing.TB) {
Context.tls = prevTLS
t.Cleanup(func() { config = prevConfig Context.tls = prevTLS }) config = &configuration{ DNS: dnsConfig{ BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS,
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
config = prevConfig }) config = &configuration{ DNS: dnsConfig{ FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, }, } } func TestHandleMobileConfigDoH(t *testing.T) {
</s> remove setupBootstraps(t) </s> add setupDNSIPs(t) </s> remove Port: 53, </s> add Port: defaultPortDNS,
BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS,
config = prevConfig }) config = &configuration{ DNS: dnsConfig{ BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, }, } } func TestHandleMobileConfigDoH(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, }, } } func TestHandleMobileConfigDoH(t *testing.T) { setupDNSIPs(t)
</s> remove FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, </s> add BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, </s> remove setupBootstraps(t) </s> add setupDNSIPs(t) </s> remove setupBootstraps(t) </s> add setupDNSIPs(t) </s> remove Port: 53, </s> add Port: defaultPortDNS,
Context.tls = &TLSMod{}
BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, }, } Context.tls = &TLSMod{} } func TestHandleMobileConfigDoH(t *testing.T) { setupDNSIPs(t)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
} } func TestHandleMobileConfigDoH(t *testing.T) { setupBootstraps(t) t.Run("success", func(t *testing.T) { r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/doh.mobileconfig?host=example.org", nil) require.NoError(t, err)
</s> remove setupBootstraps(t) </s> add setupDNSIPs(t) </s> remove FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, </s> add BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses)
setupDNSIPs(t)
} } func TestHandleMobileConfigDoH(t *testing.T) { setupDNSIPs(t) t.Run("success", func(t *testing.T) { r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/doh.mobileconfig?host=example.org", nil) require.NoError(t, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.Equal(t, testBootstrapDNS, s.ServerAddresses) assert.Empty(t, s.ServerName) assert.Equal(t, "https://example.org/dns-query", s.ServerURL) }) t.Run("error_no_host", func(t *testing.T) {
</s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove setupBootstraps(t) </s> add setupDNSIPs(t) </s> remove setupBootstraps(t) </s> add setupDNSIPs(t)
assert.NotEmpty(t, s.ServerAddresses)
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.NotEmpty(t, s.ServerAddresses) assert.Empty(t, s.ServerName) assert.Equal(t, "https://example.org/dns-query", s.ServerURL) }) t.Run("error_no_host", func(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.Equal(t, testBootstrapDNS, s.ServerAddresses) assert.Empty(t, s.ServerName) assert.Equal(t, "https://example.org/dns-query/cli42", s.ServerURL) }) }
</s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, </s> add BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, </s> remove setupBootstraps(t) </s> add setupDNSIPs(t)
assert.NotEmpty(t, s.ServerAddresses)
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.NotEmpty(t, s.ServerAddresses) assert.Empty(t, s.ServerName) assert.Equal(t, "https://example.org/dns-query/cli42", s.ServerURL) }) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
}) } func TestHandleMobileConfigDoT(t *testing.T) { setupBootstraps(t) t.Run("success", func(t *testing.T) { r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/dot.mobileconfig?host=example.org", nil) require.NoError(t, err)
</s> remove setupBootstraps(t) </s> add setupDNSIPs(t) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, </s> add BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS,
setupDNSIPs(t)
}) } func TestHandleMobileConfigDoT(t *testing.T) { setupDNSIPs(t) t.Run("success", func(t *testing.T) { r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/dot.mobileconfig?host=example.org", nil) require.NoError(t, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.Equal(t, testBootstrapDNS, s.ServerAddresses) assert.Equal(t, "example.org", s.ServerName) assert.Empty(t, s.ServerURL) }) t.Run("error_no_host", func(t *testing.T) {
</s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove setupBootstraps(t) </s> add setupDNSIPs(t) </s> remove setupBootstraps(t) </s> add setupDNSIPs(t)
assert.NotEmpty(t, s.ServerAddresses)
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.NotEmpty(t, s.ServerAddresses) assert.Equal(t, "example.org", s.ServerName) assert.Empty(t, s.ServerURL) }) t.Run("error_no_host", func(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.Equal(t, testBootstrapDNS, s.ServerAddresses) assert.Equal(t, "cli42.example.org", s.ServerName) assert.Empty(t, s.ServerURL) }) }
</s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove assert.Equal(t, testBootstrapDNS, s.ServerAddresses) </s> add assert.NotEmpty(t, s.ServerAddresses) </s> remove FilteringConfig: dnsforward.FilteringConfig{ BootstrapDNS: testBootstrapDNS, }, </s> add BindHosts: []net.IP{netutil.IPv4Zero()}, Port: defaultPortDNS, </s> remove setupBootstraps(t) </s> add setupDNSIPs(t)
assert.NotEmpty(t, s.ServerAddresses)
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.NotEmpty(t, s.ServerAddresses) assert.Equal(t, "cli42.example.org", s.ServerName) assert.Empty(t, s.ServerURL) }) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
Pull request: home: provide correct server addrs in mobileconfig Updates #3607. Updates #3568. Squashed commit of the following: commit a02f9788f88b3a9339a0900baa02881a77f1fb9b Author: Ainar Garipov <[email protected]> Date: Fri Sep 17 18:18:31 2021 +0300 home: provide correct server addrs in mobileconfig
https://github.com/AdguardTeam/AdGuardHome/commit/1714a986e3305450f80acbee61596a1475f1c3b4
internal/home/mobileconfig_test.go
import { createAction } from 'redux-actions'; import Api from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; import { normalizeTopStats } from '../helpers/helpers'; const apiClient = new Api(); export const getStatsConfigRequest = createAction('GET_LOGS_CONFIG_REQUEST'); export const getStatsConfigFailure = createAction('GET_LOGS_CONFIG_FAILURE');
</s> remove {avgProcessingTime ? `${round(avgProcessingTime, 2)} ms` : 0} </s> add {avgProcessingTime ? `${round(avgProcessingTime)} ms` : 0}
import { normalizeTopStats, secondsToMilliseconds } from '../helpers/helpers';
import { createAction } from 'redux-actions'; import Api from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; import { normalizeTopStats, secondsToMilliseconds } from '../helpers/helpers'; const apiClient = new Api(); export const getStatsConfigRequest = createAction('GET_LOGS_CONFIG_REQUEST'); export const getStatsConfigFailure = createAction('GET_LOGS_CONFIG_FAILURE');
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
- client: convert average processing time to milliseconds
https://github.com/AdguardTeam/AdGuardHome/commit/17a26155cdf0150ea9d8cf915311f16fafa6354a
client/src/actions/stats.js
...stats, top_blocked_domains: normalizeTopStats(stats.top_blocked_domains), top_clients: normalizeTopStats(stats.top_clients), top_queried_domains: normalizeTopStats(stats.top_queried_domains), }; dispatch(getStatsSuccess(normalizedStats)); } catch (error) { dispatch(addErrorToast({ error }));
</s> remove import { normalizeTopStats } from '../helpers/helpers'; </s> add import { normalizeTopStats, secondsToMilliseconds } from '../helpers/helpers'; </s> remove {avgProcessingTime ? `${round(avgProcessingTime, 2)} ms` : 0} </s> add {avgProcessingTime ? `${round(avgProcessingTime)} ms` : 0}
avg_processing_time: secondsToMilliseconds(stats.avg_processing_time),
...stats, top_blocked_domains: normalizeTopStats(stats.top_blocked_domains), top_clients: normalizeTopStats(stats.top_clients), top_queried_domains: normalizeTopStats(stats.top_queried_domains), avg_processing_time: secondsToMilliseconds(stats.avg_processing_time), }; dispatch(getStatsSuccess(normalizedStats)); } catch (error) { dispatch(addErrorToast({ error }));
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
- client: convert average processing time to milliseconds
https://github.com/AdguardTeam/AdGuardHome/commit/17a26155cdf0150ea9d8cf915311f16fafa6354a
client/src/actions/stats.js
<Tooltip text={t('average_processing_time_hint')} type={tooltipType} /> </td> <td className="text-right"> <span className="text-muted"> {avgProcessingTime ? `${round(avgProcessingTime, 2)} ms` : 0} </span> </td> </tr> </tbody> </table>
</s> remove import { normalizeTopStats } from '../helpers/helpers'; </s> add import { normalizeTopStats, secondsToMilliseconds } from '../helpers/helpers';
{avgProcessingTime ? `${round(avgProcessingTime)} ms` : 0}
<Tooltip text={t('average_processing_time_hint')} type={tooltipType} /> </td> <td className="text-right"> <span className="text-muted"> {avgProcessingTime ? `${round(avgProcessingTime)} ms` : 0} </span> </td> </tr> </tbody> </table>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
- client: convert average processing time to milliseconds
https://github.com/AdguardTeam/AdGuardHome/commit/17a26155cdf0150ea9d8cf915311f16fafa6354a
client/src/components/Dashboard/Counters.js
export const toggleAllServices = (services, change, isSelected) => { services.forEach(service => change(`blocked_services.${service.id}`, isSelected)); };
</s> remove import { normalizeTopStats } from '../helpers/helpers'; </s> add import { normalizeTopStats, secondsToMilliseconds } from '../helpers/helpers'; </s> remove {avgProcessingTime ? `${round(avgProcessingTime, 2)} ms` : 0} </s> add {avgProcessingTime ? `${round(avgProcessingTime)} ms` : 0}
export const secondsToMilliseconds = (seconds) => { if (seconds) { return seconds * 1000; } return seconds; };
export const toggleAllServices = (services, change, isSelected) => { services.forEach(service => change(`blocked_services.${service.id}`, isSelected)); }; export const secondsToMilliseconds = (seconds) => { if (seconds) { return seconds * 1000; } return seconds; };
[ "keep", "keep", "keep", "add" ]
- client: convert average processing time to milliseconds
https://github.com/AdguardTeam/AdGuardHome/commit/17a26155cdf0150ea9d8cf915311f16fafa6354a
client/src/helpers/helpers.js
const hasV4Interface = !!interfaces[selectedInterface]?.ipv4_addresses; const hasV6Interface = !!interfaces[selectedInterface]?.ipv6_addresses; if ((hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) || (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.ERROR)) { isError = true; dispatch(addErrorToast({ error: 'dhcp_error' })); if (v4.other_server.error) { dispatch(addErrorToast({ error: v4.other_server.error })); }
</s> remove dispatch(addErrorToast({ error: 'dhcp_error' })); </s> add
if (hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) {
const hasV4Interface = !!interfaces[selectedInterface]?.ipv4_addresses; const hasV6Interface = !!interfaces[selectedInterface]?.ipv6_addresses; if (hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) { if (hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) { isError = true; dispatch(addErrorToast({ error: 'dhcp_error' })); if (v4.other_server.error) { dispatch(addErrorToast({ error: v4.other_server.error })); }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix DHCP check when there is no V6 interface
https://github.com/AdguardTeam/AdGuardHome/commit/1806816d9c1a655467e6ed3934beec96a6944d4a
client/src/actions/index.js
if ((hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) || (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.ERROR)) { isError = true; dispatch(addErrorToast({ error: 'dhcp_error' })); if (v4.other_server.error) { dispatch(addErrorToast({ error: v4.other_server.error })); } if (v6.other_server.error) { dispatch(addErrorToast({ error: v6.other_server.error }));
</s> remove if ((hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) || (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.ERROR)) { </s> add if (hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) {
if ((hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) || (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.ERROR)) { isError = true; if (v4.other_server.error) { dispatch(addErrorToast({ error: v4.other_server.error })); } if (v6.other_server.error) { dispatch(addErrorToast({ error: v6.other_server.error }));
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix DHCP check when there is no V6 interface
https://github.com/AdguardTeam/AdGuardHome/commit/1806816d9c1a655467e6ed3934beec96a6944d4a
client/src/actions/index.js
if (v4.other_server.error) { dispatch(addErrorToast({ error: v4.other_server.error })); } if (v6.other_server.error) { dispatch(addErrorToast({ error: v6.other_server.error })); } } if (hasV4Interface && v4.static_ip.static === STATUS_RESPONSE.ERROR) {
</s> remove if ((hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) || (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.ERROR)) { </s> add if (hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) { </s> remove dispatch(addErrorToast({ error: 'dhcp_error' })); </s> add
} if (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.ERROR) { isError = true;
if (v4.other_server.error) { dispatch(addErrorToast({ error: v4.other_server.error })); } } if (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.ERROR) { isError = true; if (v6.other_server.error) { dispatch(addErrorToast({ error: v6.other_server.error })); } } if (hasV4Interface && v4.static_ip.static === STATUS_RESPONSE.ERROR) {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Fix DHCP check when there is no V6 interface
https://github.com/AdguardTeam/AdGuardHome/commit/1806816d9c1a655467e6ed3934beec96a6944d4a
client/src/actions/index.js
} if (isError) { return; } if ((hasV4Interface && v4.other_server.found === STATUS_RESPONSE.YES) || (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.YES)) {
</s> remove if ((hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) || (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.ERROR)) { </s> add if (hasV4Interface && v4.other_server.found === STATUS_RESPONSE.ERROR) { </s> remove dispatch(addErrorToast({ error: 'dhcp_error' })); </s> add
dispatch(addErrorToast({ error: 'dhcp_error' }));
} if (isError) { dispatch(addErrorToast({ error: 'dhcp_error' })); return; } if ((hasV4Interface && v4.other_server.found === STATUS_RESPONSE.YES) || (hasV6Interface && v6.other_server.found === STATUS_RESPONSE.YES)) {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Fix DHCP check when there is no V6 interface
https://github.com/AdguardTeam/AdGuardHome/commit/1806816d9c1a655467e6ed3934beec96a6944d4a
client/src/actions/index.js
func (d *DNSFilter) processRewrites(host string, qtype uint16) (res Result) { d.confLock.RLock() defer d.confLock.RUnlock() rr := findRewrites(d.Rewrites, host) if len(rr) != 0 { res.Reason = Rewritten } cnames := aghstrings.NewSet()
</s> remove if (r.Type == dns.TypeA && qtype == dns.TypeA) || (r.Type == dns.TypeAAAA && qtype == dns.TypeAAAA) { </s> add if r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA) { </s> remove rr = findRewrites(d.Rewrites, host) </s> add rr = findRewrites(d.Rewrites, host, qtype) </s> remove if r.Domain != host { if !matchDomainWildcard(host, r.Domain) { continue } </s> add if r.Domain != host && !matchDomainWildcard(host, r.Domain) { continue } // Return CNAMEs for all types requests, but only the // appropriate ones for A and AAAA. if r.Type == dns.TypeCNAME || (r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA)) { rr = append(rr, r) </s> remove rr = append(rr, r) </s> add
rr := findRewrites(d.Rewrites, host, qtype)
func (d *DNSFilter) processRewrites(host string, qtype uint16) (res Result) { d.confLock.RLock() defer d.confLock.RUnlock() rr := findRewrites(d.Rewrites, host, qtype) if len(rr) != 0 { res.Reason = Rewritten } cnames := aghstrings.NewSet()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite wildcards Updates #3343. Squashed commit of the following: commit ab3c3e002a6d2a11bc3207fdaaeb292aaa194907 Author: Ainar Garipov <[email protected]> Date: Mon Jul 12 20:58:57 2021 +0300 filtering: fix legacy rewrite wildcards
https://github.com/AdguardTeam/AdGuardHome/commit/194ea6ef9529e4d34ae764eaf4c5f60960aa3ed2
internal/filtering/filtering.go
} cnames.Add(host) res.CanonName = rr[0].Answer rr = findRewrites(d.Rewrites, host) } for _, r := range rr { if (r.Type == dns.TypeA && qtype == dns.TypeA) || (r.Type == dns.TypeAAAA && qtype == dns.TypeAAAA) {
</s> remove if (r.Type == dns.TypeA && qtype == dns.TypeA) || (r.Type == dns.TypeAAAA && qtype == dns.TypeAAAA) { </s> add if r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA) { </s> remove res.Reason = 0 </s> add res.Reason = NotFilteredNotFound </s> remove if r.Domain != host { if !matchDomainWildcard(host, r.Domain) { continue } </s> add if r.Domain != host && !matchDomainWildcard(host, r.Domain) { continue } // Return CNAMEs for all types requests, but only the // appropriate ones for A and AAAA. if r.Type == dns.TypeCNAME || (r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA)) { rr = append(rr, r) </s> remove rr := findRewrites(d.Rewrites, host) </s> add rr := findRewrites(d.Rewrites, host, qtype) </s> remove } else if r.Answer == "A" { </s> add case "A":
rr = findRewrites(d.Rewrites, host, qtype)
} cnames.Add(host) res.CanonName = rr[0].Answer rr = findRewrites(d.Rewrites, host, qtype) } for _, r := range rr { if (r.Type == dns.TypeA && qtype == dns.TypeA) || (r.Type == dns.TypeAAAA && qtype == dns.TypeAAAA) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite wildcards Updates #3343. Squashed commit of the following: commit ab3c3e002a6d2a11bc3207fdaaeb292aaa194907 Author: Ainar Garipov <[email protected]> Date: Mon Jul 12 20:58:57 2021 +0300 filtering: fix legacy rewrite wildcards
https://github.com/AdguardTeam/AdGuardHome/commit/194ea6ef9529e4d34ae764eaf4c5f60960aa3ed2
internal/filtering/filtering.go
rr = findRewrites(d.Rewrites, host) } for _, r := range rr { if (r.Type == dns.TypeA && qtype == dns.TypeA) || (r.Type == dns.TypeAAAA && qtype == dns.TypeAAAA) { if r.IP == nil { // IP exception res.Reason = 0 return res }
</s> remove rr = findRewrites(d.Rewrites, host) </s> add rr = findRewrites(d.Rewrites, host, qtype) </s> remove res.Reason = 0 </s> add res.Reason = NotFilteredNotFound </s> remove if r.Domain != host { if !matchDomainWildcard(host, r.Domain) { continue } </s> add if r.Domain != host && !matchDomainWildcard(host, r.Domain) { continue } // Return CNAMEs for all types requests, but only the // appropriate ones for A and AAAA. if r.Type == dns.TypeCNAME || (r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA)) { rr = append(rr, r) </s> remove rr := findRewrites(d.Rewrites, host) </s> add rr := findRewrites(d.Rewrites, host, qtype) </s> remove } else if r.Answer == "A" { </s> add case "A":
if r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA) {
rr = findRewrites(d.Rewrites, host) } for _, r := range rr { if r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA) { if r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA) { if r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA) { if r.IP == nil { // IP exception res.Reason = 0 return res }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite wildcards Updates #3343. Squashed commit of the following: commit ab3c3e002a6d2a11bc3207fdaaeb292aaa194907 Author: Ainar Garipov <[email protected]> Date: Mon Jul 12 20:58:57 2021 +0300 filtering: fix legacy rewrite wildcards
https://github.com/AdguardTeam/AdGuardHome/commit/194ea6ef9529e4d34ae764eaf4c5f60960aa3ed2
internal/filtering/filtering.go
if (r.Type == dns.TypeA && qtype == dns.TypeA) || (r.Type == dns.TypeAAAA && qtype == dns.TypeAAAA) { if r.IP == nil { // IP exception res.Reason = 0 return res } res.IPList = append(res.IPList, r.IP) log.Debug("rewrite: A/AAAA for %s is %s", host, r.IP)
</s> remove if (r.Type == dns.TypeA && qtype == dns.TypeA) || (r.Type == dns.TypeAAAA && qtype == dns.TypeAAAA) { </s> add if r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA) { </s> remove rr = findRewrites(d.Rewrites, host) </s> add rr = findRewrites(d.Rewrites, host, qtype) </s> remove if r.Domain != host { if !matchDomainWildcard(host, r.Domain) { continue } </s> add if r.Domain != host && !matchDomainWildcard(host, r.Domain) { continue } // Return CNAMEs for all types requests, but only the // appropriate ones for A and AAAA. if r.Type == dns.TypeCNAME || (r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA)) { rr = append(rr, r) </s> remove } else if r.Answer == "A" { </s> add case "A": </s> remove if r.Answer == "AAAA" { </s> add switch r.Answer { case "AAAA":
res.Reason = NotFilteredNotFound
if (r.Type == dns.TypeA && qtype == dns.TypeA) || (r.Type == dns.TypeAAAA && qtype == dns.TypeAAAA) { if r.IP == nil { // IP exception res.Reason = NotFilteredNotFound return res } res.IPList = append(res.IPList, r.IP) log.Debug("rewrite: A/AAAA for %s is %s", host, r.IP)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite wildcards Updates #3343. Squashed commit of the following: commit ab3c3e002a6d2a11bc3207fdaaeb292aaa194907 Author: Ainar Garipov <[email protected]> Date: Mon Jul 12 20:58:57 2021 +0300 filtering: fix legacy rewrite wildcards
https://github.com/AdguardTeam/AdGuardHome/commit/194ea6ef9529e4d34ae764eaf4c5f60960aa3ed2
internal/filtering/filtering.go
) // RewriteEntry is a rewrite array element type RewriteEntry struct { Domain string `yaml:"domain"` // Answer is the IP address, canonical name, or one of the special // values: "A" or "AAAA". Answer string `yaml:"answer"` // IP is the IP address that should be used in the response if Type is // A or AAAA.
</s> remove Answer string `yaml:"answer"` // IP address or canonical name Type uint16 `yaml:"-"` // DNS record type: CNAME, A or AAAA IP net.IP `yaml:"-"` // Parsed IP address (if Type is A or AAAA) </s> add // Answer is the IP address, canonical name, or one of the special // values: "A" or "AAAA". Answer string `yaml:"answer"` // IP is the IP address that should be used in the response if Type is // A or AAAA. IP net.IP `yaml:"-"` // Type is the DNS record type: A, AAAA, or CNAME. Type uint16 `yaml:"-"` </s> remove // Get the list of matched rewrite entries. // Priority: CNAME, A/AAAA; exact, wildcard. // If matched exactly, don't return wildcard entries. // If matched by several wildcards, select the more specific one func findRewrites(a []RewriteEntry, host string) []RewriteEntry { rr := rewritesArray{} </s> add // findRewrites returns the list of matched rewrite entries. The priority is: // CNAME, then A and AAAA; exact, then wildcard. If the host is matched // exactly, wildcard entries aren't returned. If the host matched by wildcards, // return the most specific for the question type. func findRewrites(a []RewriteEntry, host string, qtype uint16) []RewriteEntry { rr := rewritesSorted{} </s> remove // Prepare entry for use </s> add // prepare prepares the a new or decoded entry. </s> remove type rewritesArray []RewriteEntry </s> add // rewritesSorted is a slice of legacy rewrites for sorting. // // The sorting priority: // // A and AAAA > CNAME // wildcard > exact // lower level wildcard > higher level wildcard // type rewritesSorted []RewriteEntry </s> remove res.Reason = 0 </s> add res.Reason = NotFilteredNotFound
// Domain is the domain for which this rewrite should work.
) // RewriteEntry is a rewrite array element type RewriteEntry struct { // Domain is the domain for which this rewrite should work. Domain string `yaml:"domain"` // Answer is the IP address, canonical name, or one of the special // values: "A" or "AAAA". Answer string `yaml:"answer"` // IP is the IP address that should be used in the response if Type is // A or AAAA.
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite wildcards Updates #3343. Squashed commit of the following: commit ab3c3e002a6d2a11bc3207fdaaeb292aaa194907 Author: Ainar Garipov <[email protected]> Date: Mon Jul 12 20:58:57 2021 +0300 filtering: fix legacy rewrite wildcards
https://github.com/AdguardTeam/AdGuardHome/commit/194ea6ef9529e4d34ae764eaf4c5f60960aa3ed2
internal/filtering/rewrites.go
// RewriteEntry is a rewrite array element type RewriteEntry struct { Domain string `yaml:"domain"` Answer string `yaml:"answer"` // IP address or canonical name Type uint16 `yaml:"-"` // DNS record type: CNAME, A or AAAA IP net.IP `yaml:"-"` // Parsed IP address (if Type is A or AAAA) } func (r *RewriteEntry) equals(b RewriteEntry) bool { return r.Domain == b.Domain && r.Answer == b.Answer }
</s> remove // Prepare entry for use </s> add // prepare prepares the a new or decoded entry. </s> remove return len(host) >= 2 && host[0] == '*' && host[1] == '.' </s> add return len(host) > 1 && host[0] == '*' && host[1] == '.' </s> remove type rewritesArray []RewriteEntry </s> add // rewritesSorted is a slice of legacy rewrites for sorting. // // The sorting priority: // // A and AAAA > CNAME // wildcard > exact // lower level wildcard > higher level wildcard // type rewritesSorted []RewriteEntry </s> remove res.Reason = 0 </s> add res.Reason = NotFilteredNotFound
// Answer is the IP address, canonical name, or one of the special // values: "A" or "AAAA". Answer string `yaml:"answer"` // IP is the IP address that should be used in the response if Type is // A or AAAA. IP net.IP `yaml:"-"` // Type is the DNS record type: A, AAAA, or CNAME. Type uint16 `yaml:"-"`
// RewriteEntry is a rewrite array element type RewriteEntry struct { Domain string `yaml:"domain"` // Answer is the IP address, canonical name, or one of the special // values: "A" or "AAAA". Answer string `yaml:"answer"` // IP is the IP address that should be used in the response if Type is // A or AAAA. IP net.IP `yaml:"-"` // Type is the DNS record type: A, AAAA, or CNAME. Type uint16 `yaml:"-"` // Answer is the IP address, canonical name, or one of the special // values: "A" or "AAAA". Answer string `yaml:"answer"` // IP is the IP address that should be used in the response if Type is // A or AAAA. IP net.IP `yaml:"-"` // Type is the DNS record type: A, AAAA, or CNAME. Type uint16 `yaml:"-"` // Answer is the IP address, canonical name, or one of the special // values: "A" or "AAAA". Answer string `yaml:"answer"` // IP is the IP address that should be used in the response if Type is // A or AAAA. IP net.IP `yaml:"-"` // Type is the DNS record type: A, AAAA, or CNAME. Type uint16 `yaml:"-"` } func (r *RewriteEntry) equals(b RewriteEntry) bool { return r.Domain == b.Domain && r.Answer == b.Answer }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite wildcards Updates #3343. Squashed commit of the following: commit ab3c3e002a6d2a11bc3207fdaaeb292aaa194907 Author: Ainar Garipov <[email protected]> Date: Mon Jul 12 20:58:57 2021 +0300 filtering: fix legacy rewrite wildcards
https://github.com/AdguardTeam/AdGuardHome/commit/194ea6ef9529e4d34ae764eaf4c5f60960aa3ed2
internal/filtering/rewrites.go
return r.Domain == b.Domain && r.Answer == b.Answer } func isWildcard(host string) bool { return len(host) >= 2 && host[0] == '*' && host[1] == '.' } // Return TRUE of host name matches a wildcard pattern func matchDomainWildcard(host, wildcard string) bool { return isWildcard(wildcard) &&
</s> remove // Return TRUE of host name matches a wildcard pattern func matchDomainWildcard(host, wildcard string) bool { return isWildcard(wildcard) && strings.HasSuffix(host, wildcard[1:]) </s> add // matchDomainWildcard returns true if host matches the wildcard pattern. func matchDomainWildcard(host, wildcard string) (ok bool) { return isWildcard(wildcard) && strings.HasSuffix(host, wildcard[1:]) </s> remove // Priority: // . CNAME < A/AAAA; // . exact < wildcard; // . higher level wildcard < lower level wildcard func (a rewritesArray) Less(i, j int) bool { </s> add // Less implements the sort.Interface interface for legacyRewritesSorted. func (a rewritesSorted) Less(i, j int) bool { </s> remove if r.Domain != host { if !matchDomainWildcard(host, r.Domain) { continue } </s> add if r.Domain != host && !matchDomainWildcard(host, r.Domain) { continue } // Return CNAMEs for all types requests, but only the // appropriate ones for A and AAAA. if r.Type == dns.TypeCNAME || (r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA)) { rr = append(rr, r) </s> remove if (r.Type == dns.TypeA && qtype == dns.TypeA) || (r.Type == dns.TypeAAAA && qtype == dns.TypeAAAA) { </s> add if r.Type == qtype && (qtype == dns.TypeA || qtype == dns.TypeAAAA) { </s> remove type rewritesArray []RewriteEntry </s> add // rewritesSorted is a slice of legacy rewrites for sorting. // // The sorting priority: // // A and AAAA > CNAME // wildcard > exact // lower level wildcard > higher level wildcard // type rewritesSorted []RewriteEntry
return len(host) > 1 && host[0] == '*' && host[1] == '.'
return r.Domain == b.Domain && r.Answer == b.Answer } func isWildcard(host string) bool { return len(host) > 1 && host[0] == '*' && host[1] == '.' return len(host) > 1 && host[0] == '*' && host[1] == '.' } // Return TRUE of host name matches a wildcard pattern func matchDomainWildcard(host, wildcard string) bool { return isWildcard(wildcard) &&
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite wildcards Updates #3343. Squashed commit of the following: commit ab3c3e002a6d2a11bc3207fdaaeb292aaa194907 Author: Ainar Garipov <[email protected]> Date: Mon Jul 12 20:58:57 2021 +0300 filtering: fix legacy rewrite wildcards
https://github.com/AdguardTeam/AdGuardHome/commit/194ea6ef9529e4d34ae764eaf4c5f60960aa3ed2
internal/filtering/rewrites.go
return len(host) >= 2 && host[0] == '*' && host[1] == '.' } // Return TRUE of host name matches a wildcard pattern func matchDomainWildcard(host, wildcard string) bool { return isWildcard(wildcard) && strings.HasSuffix(host, wildcard[1:]) } type rewritesArray []RewriteEntry func (a rewritesArray) Len() int { return len(a) }
</s> remove return len(host) >= 2 && host[0] == '*' && host[1] == '.' </s> add return len(host) > 1 && host[0] == '*' && host[1] == '.' </s> remove type rewritesArray []RewriteEntry </s> add // rewritesSorted is a slice of legacy rewrites for sorting. // // The sorting priority: // // A and AAAA > CNAME // wildcard > exact // lower level wildcard > higher level wildcard // type rewritesSorted []RewriteEntry </s> remove // Priority: // . CNAME < A/AAAA; // . exact < wildcard; // . higher level wildcard < lower level wildcard func (a rewritesArray) Less(i, j int) bool { </s> add // Less implements the sort.Interface interface for legacyRewritesSorted. func (a rewritesSorted) Less(i, j int) bool { </s> remove func (a rewritesArray) Len() int { return len(a) } </s> add // Len implements the sort.Interface interface for legacyRewritesSorted. func (a rewritesSorted) Len() int { return len(a) } </s> remove func (a rewritesArray) Swap(i, j int) { a[i], a[j] = a[j], a[i] } </s> add // Swap implements the sort.Interface interface for legacyRewritesSorted. func (a rewritesSorted) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
// matchDomainWildcard returns true if host matches the wildcard pattern. func matchDomainWildcard(host, wildcard string) (ok bool) { return isWildcard(wildcard) && strings.HasSuffix(host, wildcard[1:])
return len(host) >= 2 && host[0] == '*' && host[1] == '.' } // matchDomainWildcard returns true if host matches the wildcard pattern. func matchDomainWildcard(host, wildcard string) (ok bool) { return isWildcard(wildcard) && strings.HasSuffix(host, wildcard[1:]) // matchDomainWildcard returns true if host matches the wildcard pattern. func matchDomainWildcard(host, wildcard string) (ok bool) { return isWildcard(wildcard) && strings.HasSuffix(host, wildcard[1:]) // matchDomainWildcard returns true if host matches the wildcard pattern. func matchDomainWildcard(host, wildcard string) (ok bool) { return isWildcard(wildcard) && strings.HasSuffix(host, wildcard[1:]) // matchDomainWildcard returns true if host matches the wildcard pattern. func matchDomainWildcard(host, wildcard string) (ok bool) { return isWildcard(wildcard) && strings.HasSuffix(host, wildcard[1:]) } type rewritesArray []RewriteEntry func (a rewritesArray) Len() int { return len(a) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: filtering: fix legacy rewrite wildcards Updates #3343. Squashed commit of the following: commit ab3c3e002a6d2a11bc3207fdaaeb292aaa194907 Author: Ainar Garipov <[email protected]> Date: Mon Jul 12 20:58:57 2021 +0300 filtering: fix legacy rewrite wildcards
https://github.com/AdguardTeam/AdGuardHome/commit/194ea6ef9529e4d34ae764eaf4c5f60960aa3ed2
internal/filtering/rewrites.go