docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
listlengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
<use xlinkHref="#delete"/>
<mask> this.handleDelete(ip, mac, hostname) <mask> } <mask> > <mask> <svg className="icons"> <mask> <use xlinkHref="#delete" /> <mask> </svg> <mask> </button> <mask> </div> <mask> ); <mask> }, </s> - client: fix table pagination </s> remove pageSize={100} showPagination={true} </s> add pageSize={SMALL_TABLE_DEFAULT_PAGE_SIZE} showPageSizeOptions={false} showPagination={staticLeases.length > SMALL_TABLE_DEFAULT_PAGE_SIZE} </s> remove pageSize={100} showPagination={true} </s> add pageSize={SMALL_TABLE_DEFAULT_PAGE_SIZE} showPageSizeOptions={false} showPagination={leases.length > SMALL_TABLE_DEFAULT_PAGE_SIZE} </s> remove } </s> add }; </s> remove } </s> add };
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f446186db146b74cc6af3d29cf53ff69adc26e4f
client/src/components/Settings/Dhcp/StaticLeases/index.js
pageSize={SMALL_TABLE_DEFAULT_PAGE_SIZE} showPageSizeOptions={false} showPagination={staticLeases.length > SMALL_TABLE_DEFAULT_PAGE_SIZE}
<mask> ); <mask> }, <mask> }, <mask> ]} <mask> pageSize={100} <mask> showPagination={true} <mask> noDataText={t('dhcp_static_leases_not_found')} <mask> className="-striped -highlight card-table-overflow" <mask> minRows={6} <mask> /> <mask> <Modal </s> - client: fix table pagination </s> remove pageSize={100} showPagination={true} </s> add pageSize={SMALL_TABLE_DEFAULT_PAGE_SIZE} showPageSizeOptions={false} showPagination={leases.length > SMALL_TABLE_DEFAULT_PAGE_SIZE} </s> remove <use xlinkHref="#delete" /> </s> add <use xlinkHref="#delete"/> </s> remove } </s> add }; </s> remove } </s> add };
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f446186db146b74cc6af3d29cf53ff69adc26e4f
client/src/components/Settings/Dhcp/StaticLeases/index.js
export const SMALL_TABLE_DEFAULT_PAGE_SIZE = 20;
<mask> <mask> export const DEFAULT_LANGUAGE = 'en'; <mask> <mask> export const TABLE_DEFAULT_PAGE_SIZE = 100; <mask> export const RESPONSE_FILTER = { <mask> ALL: 'all', <mask> FILTERED: 'filtered', <mask> }; </s> - client: fix table pagination </s> remove } </s> add }; </s> remove } </s> add }; </s> remove pageSize={100} showPagination={true} </s> add pageSize={SMALL_TABLE_DEFAULT_PAGE_SIZE} showPageSizeOptions={false} showPagination={staticLeases.length > SMALL_TABLE_DEFAULT_PAGE_SIZE}
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f446186db146b74cc6af3d29cf53ff69adc26e4f
client/src/helpers/constants.js
'dockerGo': 'adguard/golang-ubuntu:4.4'
<mask> 'name': 'AdGuard Home - Build and publish release' <mask> # Make sure to sync any changes with the branch overrides below. <mask> 'variables': <mask> 'channel': 'edge' <mask> 'dockerGo': 'adguard/golang-ubuntu:4.3' <mask> <mask> 'stages': <mask> - 'Make release': <mask> 'manual': false <mask> 'final': false </s> Pull request: all: upd go Merge in DNS/adguard-home from upd-go to master Squashed commit of the following: commit b0bec8926508fb7ee3f26c2303d9628e21f0b62f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jun 2 15:47:51 2022 +0300 all: upd go </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4' </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4' </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4'
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f46c9f74d5b03f8caa60d8e648bbc46fe306714d
bamboo-specs/release.yaml
'dockerGo': 'adguard/golang-ubuntu:4.4'
<mask> # Set the default release channel on the release branch to beta, as we may <mask> # need to build a few of these. <mask> 'variables': <mask> 'channel': 'beta' <mask> 'dockerGo': 'adguard/golang-ubuntu:4.3' <mask> # release-vX.Y.Z branches are the branches from which the actual final release <mask> # is built. <mask> - '^release-v[0-9]+\.[0-9]+\.[0-9]+': <mask> # Disable integration branches for release branches. <mask> 'branch-config': </s> Pull request: all: upd go Merge in DNS/adguard-home from upd-go to master Squashed commit of the following: commit b0bec8926508fb7ee3f26c2303d9628e21f0b62f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jun 2 15:47:51 2022 +0300 all: upd go </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4' </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4' </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4'
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f46c9f74d5b03f8caa60d8e648bbc46fe306714d
bamboo-specs/release.yaml
'dockerGo': 'adguard/golang-ubuntu:4.4'
<mask> # Set the default release channel on the final branch to release, as these <mask> # are the ones that actually get released. <mask> 'variables': <mask> 'channel': 'release' <mask> 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> Pull request: all: upd go Merge in DNS/adguard-home from upd-go to master Squashed commit of the following: commit b0bec8926508fb7ee3f26c2303d9628e21f0b62f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jun 2 15:47:51 2022 +0300 all: upd go </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4' </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4' </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4'
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f46c9f74d5b03f8caa60d8e648bbc46fe306714d
bamboo-specs/release.yaml
'dockerGo': 'adguard/golang-ubuntu:4.4'
<mask> 'project-key': 'AGH' <mask> 'key': 'AHBRTSPECS' <mask> 'name': 'AdGuard Home - Build and run tests' <mask> 'variables': <mask> 'dockerGo': 'adguard/golang-ubuntu:4.3' <mask> <mask> 'stages': <mask> - 'Tests': <mask> 'manual': false <mask> 'final': false </s> Pull request: all: upd go Merge in DNS/adguard-home from upd-go to master Squashed commit of the following: commit b0bec8926508fb7ee3f26c2303d9628e21f0b62f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jun 2 15:47:51 2022 +0300 all: upd go </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4' </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4' </s> remove 'dockerGo': 'adguard/golang-ubuntu:4.3' </s> add 'dockerGo': 'adguard/golang-ubuntu:4.4'
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f46c9f74d5b03f8caa60d8e648bbc46fe306714d
bamboo-specs/test.yaml
// Return 0 on success func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int { log.Tracef("got certificate: %s", certChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(certChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type)
<mask> }() <mask> } <mask> } <mask> <mask> /* Process certificate data and its private key. <mask> CertificateChain, PrivateKey parameters are optional. <mask> On error, return partially set object <mask> with 'WarningValidation' field containing error description. <mask> */ <mask> func validateCertificates(CertificateChain, PrivateKey, ServerName string) tlsConfigStatus { <mask> var err error <mask> var data tlsConfigStatus <mask> <mask> // check only public certificate separately from the key <mask> if CertificateChain != "" { <mask> log.Tracef("got certificate: %s", CertificateChain) <mask> <mask> // now do a more extended validation <mask> var certs []*pem.Block // PEM-encoded certificates <mask> var skippedBytes []string // skipped bytes <mask> <mask> pemblock := []byte(CertificateChain) <mask> for { <mask> var decoded *pem.Block <mask> decoded, pemblock = pem.Decode(pemblock) <mask> if decoded == nil { <mask> break <mask> } <mask> if decoded.Type == "CERTIFICATE" { <mask> certs = append(certs, decoded) <mask> } else { <mask> skippedBytes = append(skippedBytes, decoded.Type) <mask> } <mask> } <mask> <mask> var parsedCerts []*x509.Certificate <mask> <mask> for _, cert := range certs { </s> * validateCertificates(): split the function's code </s> remove if key == nil { data.WarningValidation = "No valid keys were found" </s> add data.ValidKey = true data.KeyType = keytype return 0 } /* Process certificate data and its private key. All parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(certChain, pkey, serverName string) tlsConfigStatus { var data tlsConfigStatus // check only public certificate separately from the key if certChain != "" { if verifyCertChain(&data, certChain, serverName) != 0 { </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 } </s> remove // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true </s> add // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true } // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames } return 0 } // Return 0 on success func validatePkey(data *tlsConfigStatus, pkey string) int { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(pkey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break </s> remove var parsedCerts []*x509.Certificate </s> add var parsedCerts []*x509.Certificate </s> remove // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames </s> add if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
}
<mask> } else { <mask> skippedBytes = append(skippedBytes, decoded.Type) <mask> } <mask> <mask> var parsedCerts []*x509.Certificate <mask> <mask> for _, cert := range certs { </s> * validateCertificates(): split the function's code </s> remove var parsedCerts []*x509.Certificate </s> add var parsedCerts []*x509.Certificate </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1 </s> remove /* Process certificate data and its private key. CertificateChain, PrivateKey parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(CertificateChain, PrivateKey, ServerName string) tlsConfigStatus { var err error var data tlsConfigStatus // check only public certificate separately from the key if CertificateChain != "" { log.Tracef("got certificate: %s", CertificateChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(CertificateChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) } </s> add // Return 0 on success func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int { log.Tracef("got certificate: %s", certChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(certChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) } opts.Intermediates = pool </s> add log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
var parsedCerts []*x509.Certificate
<mask> skippedBytes = append(skippedBytes, decoded.Type) <mask> } <mask> } <mask> <mask> var parsedCerts []*x509.Certificate <mask> <mask> for _, cert := range certs { <mask> parsed, err := x509.ParseCertificate(cert.Bytes) <mask> if err != nil { <mask> data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) </s> * validateCertificates(): split the function's code </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1 </s> remove /* Process certificate data and its private key. CertificateChain, PrivateKey parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(CertificateChain, PrivateKey, ServerName string) tlsConfigStatus { var err error var data tlsConfigStatus // check only public certificate separately from the key if CertificateChain != "" { log.Tracef("got certificate: %s", CertificateChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(CertificateChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) } </s> add // Return 0 on success func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int { log.Tracef("got certificate: %s", certChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(certChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1
<mask> } <mask> <mask> var parsedCerts []*x509.Certificate <mask> <mask> for _, cert := range certs { <mask> parsed, err := x509.ParseCertificate(cert.Bytes) <mask> if err != nil { <mask> data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) <mask> return data <mask> } <mask> parsedCerts = append(parsedCerts, parsed) <mask> } <mask> <mask> if len(parsedCerts) == 0 { <mask> data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") <mask> return data </s> * validateCertificates(): split the function's code </s> remove var parsedCerts []*x509.Certificate </s> add var parsedCerts []*x509.Certificate </s> remove if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return data } </s> add if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return 1 } </s> remove data.ValidCert = true </s> add data.ValidCert = true </s> remove /* Process certificate data and its private key. CertificateChain, PrivateKey parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(CertificateChain, PrivateKey, ServerName string) tlsConfigStatus { var err error var data tlsConfigStatus // check only public certificate separately from the key if CertificateChain != "" { log.Tracef("got certificate: %s", CertificateChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(CertificateChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) } </s> add // Return 0 on success func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int { log.Tracef("got certificate: %s", certChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(certChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
parsedCerts = append(parsedCerts, parsed) }
<mask> data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) <mask> return 1 <mask> } <mask> <mask> if len(parsedCerts) == 0 { <mask> data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") <mask> return 1 <mask> } <mask> </s> * validateCertificates(): split the function's code </s> remove if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return data } </s> add if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return 1 } </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1 </s> remove data.ValidCert = true </s> add data.ValidCert = true </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 } </s> remove var parsedCerts []*x509.Certificate </s> add var parsedCerts []*x509.Certificate
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return 1 }
<mask> } <mask> parsedCerts = append(parsedCerts, parsed) <mask> } <mask> <mask> if len(parsedCerts) == 0 { <mask> data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") <mask> return data <mask> } <mask> <mask> data.ValidCert = true <mask> <mask> // spew.Dump(parsedCerts) <mask> </s> * validateCertificates(): split the function's code </s> remove data.ValidCert = true </s> add data.ValidCert = true </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1 </s> remove opts := x509.VerifyOptions{ DNSName: ServerName, } </s> add opts := x509.VerifyOptions{ DNSName: serverName, } </s> remove // spew.Dump(parsedCerts) </s> add // spew.Dump(parsedCerts)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
data.ValidCert = true
<mask> data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") <mask> return data <mask> } <mask> <mask> data.ValidCert = true <mask> <mask> // spew.Dump(parsedCerts) <mask> <mask> opts := x509.VerifyOptions{ <mask> DNSName: ServerName, </s> * validateCertificates(): split the function's code </s> remove if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return data } </s> add if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return 1 } </s> remove // spew.Dump(parsedCerts) </s> add // spew.Dump(parsedCerts) </s> remove opts := x509.VerifyOptions{ DNSName: ServerName, } </s> add opts := x509.VerifyOptions{ DNSName: serverName, } </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
// spew.Dump(parsedCerts)
<mask> } <mask> <mask> data.ValidCert = true <mask> <mask> // spew.Dump(parsedCerts) <mask> <mask> opts := x509.VerifyOptions{ <mask> DNSName: ServerName, <mask> } <mask> </s> * validateCertificates(): split the function's code </s> remove opts := x509.VerifyOptions{ DNSName: ServerName, } </s> add opts := x509.VerifyOptions{ DNSName: serverName, } </s> remove data.ValidCert = true </s> add data.ValidCert = true </s> remove log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) } opts.Intermediates = pool </s> add log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) </s> remove if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return data } </s> add if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return 1 } </s> remove // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true </s> add // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true } // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames } return 0 } // Return 0 on success func validatePkey(data *tlsConfigStatus, pkey string) int { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(pkey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
opts := x509.VerifyOptions{ DNSName: serverName, }
<mask> data.ValidCert = true <mask> <mask> // spew.Dump(parsedCerts) <mask> <mask> opts := x509.VerifyOptions{ <mask> DNSName: ServerName, <mask> } <mask> <mask> log.Printf("number of certs - %d", len(parsedCerts)) <mask> if len(parsedCerts) > 1 { <mask> // set up an intermediate <mask> pool := x509.NewCertPool() </s> * validateCertificates(): split the function's code </s> remove log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) } opts.Intermediates = pool </s> add log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) </s> remove // spew.Dump(parsedCerts) </s> add // spew.Dump(parsedCerts) </s> remove data.ValidCert = true </s> add data.ValidCert = true </s> remove if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return data } </s> add if len(parsedCerts) == 0 { data.WarningValidation = fmt.Sprintf("You have specified an empty certificate") return 1 } </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert)
<mask> opts := x509.VerifyOptions{ <mask> DNSName: ServerName, <mask> } <mask> <mask> log.Printf("number of certs - %d", len(parsedCerts)) <mask> if len(parsedCerts) > 1 { <mask> // set up an intermediate <mask> pool := x509.NewCertPool() <mask> for _, cert := range parsedCerts[1:] { <mask> log.Printf("got an intermediate cert") <mask> pool.AddCert(cert) <mask> } <mask> opts.Intermediates = pool <mask> } <mask> <mask> // TODO: save it as a warning rather than error it out -- shouldn't be a big problem <mask> mainCert := parsedCerts[0] <mask> _, err := mainCert.Verify(opts) </s> * validateCertificates(): split the function's code </s> remove opts := x509.VerifyOptions{ DNSName: ServerName, } </s> add opts := x509.VerifyOptions{ DNSName: serverName, } </s> remove // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true </s> add // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true } // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames } return 0 } // Return 0 on success func validatePkey(data *tlsConfigStatus, pkey string) int { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(pkey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1 </s> remove data.ValidCert = true </s> add data.ValidCert = true
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
opts.Intermediates = pool }
<mask> pool.AddCert(cert) <mask> } <mask> <mask> // TODO: save it as a warning rather than error it out -- shouldn't be a big problem <mask> mainCert := parsedCerts[0] <mask> _, err := mainCert.Verify(opts) <mask> if err != nil { <mask> // let self-signed certs through </s> * validateCertificates(): split the function's code </s> remove // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true </s> add // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true } // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames } return 0 } // Return 0 on success func validatePkey(data *tlsConfigStatus, pkey string) int { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(pkey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break </s> remove log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) } opts.Intermediates = pool </s> add log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) </s> remove /* Process certificate data and its private key. CertificateChain, PrivateKey parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(CertificateChain, PrivateKey, ServerName string) tlsConfigStatus { var err error var data tlsConfigStatus // check only public certificate separately from the key if CertificateChain != "" { log.Tracef("got certificate: %s", CertificateChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(CertificateChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) } </s> add // Return 0 on success func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int { log.Tracef("got certificate: %s", certChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(certChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 } </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
// TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true } // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames } return 0 } // Return 0 on success func validatePkey(data *tlsConfigStatus, pkey string) int { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(pkey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break
<mask> } <mask> opts.Intermediates = pool <mask> } <mask> <mask> // TODO: save it as a warning rather than error it out -- shouldn't be a big problem <mask> mainCert := parsedCerts[0] <mask> _, err := mainCert.Verify(opts) <mask> if err != nil { <mask> // let self-signed certs through <mask> data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) <mask> } else { <mask> data.ValidChain = true <mask> } <mask> // spew.Dump(chains) <mask> <mask> // update status <mask> if mainCert != nil { </s> * validateCertificates(): split the function's code </s> remove log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) } opts.Intermediates = pool </s> add log.Printf("number of certs - %d", len(parsedCerts)) if len(parsedCerts) > 1 { // set up an intermediate pool := x509.NewCertPool() for _, cert := range parsedCerts[1:] { log.Printf("got an intermediate cert") pool.AddCert(cert) </s> remove // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames </s> add if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove /* Process certificate data and its private key. CertificateChain, PrivateKey parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(CertificateChain, PrivateKey, ServerName string) tlsConfigStatus { var err error var data tlsConfigStatus // check only public certificate separately from the key if CertificateChain != "" { log.Tracef("got certificate: %s", CertificateChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(CertificateChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) } </s> add // Return 0 on success func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int { log.Tracef("got certificate: %s", certChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(certChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type)
<mask> data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) <mask> } else { <mask> data.ValidChain = true <mask> } <mask> // spew.Dump(chains) <mask> <mask> // update status <mask> if mainCert != nil { <mask> notAfter := mainCert.NotAfter <mask> data.Subject = mainCert.Subject.String() <mask> data.Issuer = mainCert.Issuer.String() <mask> data.NotAfter = notAfter <mask> data.NotBefore = mainCert.NotBefore <mask> data.DNSNames = mainCert.DNSNames <mask> } <mask> } <mask> <mask> // validate private key (right now the only validation possible is just parsing it) <mask> if PrivateKey != "" { </s> * validateCertificates(): split the function's code </s> remove // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true </s> add // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true } // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames } return 0 } // Return 0 on success func validatePkey(data *tlsConfigStatus, pkey string) int { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(pkey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break </s> remove // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) </s> add // validate private key (right now the only validation possible is just parsing it) if pkey != "" { if validatePkey(&data, pkey) != 0 { </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 } </s> remove if PrivateKey != "" && CertificateChain != "" { _, err = tls.X509KeyPair([]byte(CertificateChain), []byte(PrivateKey)) </s> add if pkey != "" && certChain != "" { _, err := tls.X509KeyPair([]byte(certChain), []byte(pkey))
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 }
<mask> data.DNSNames = mainCert.DNSNames <mask> } <mask> } <mask> <mask> // validate private key (right now the only validation possible is just parsing it) <mask> if PrivateKey != "" { <mask> // now do a more extended validation <mask> var key *pem.Block // PEM-encoded certificates <mask> var skippedBytes []string // skipped bytes <mask> <mask> // go through all pem blocks, but take first valid pem block and drop the rest <mask> pemblock := []byte(PrivateKey) <mask> for { <mask> var decoded *pem.Block <mask> decoded, pemblock = pem.Decode(pemblock) <mask> if decoded == nil { <mask> break <mask> } <mask> if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { <mask> key = decoded <mask> break <mask> } else { <mask> skippedBytes = append(skippedBytes, decoded.Type) <mask> } <mask> } <mask> <mask> if key == nil { <mask> data.WarningValidation = "No valid keys were found" <mask> return data <mask> } </s> * validateCertificates(): split the function's code </s> remove // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true </s> add // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true } // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames } return 0 } // Return 0 on success func validatePkey(data *tlsConfigStatus, pkey string) int { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(pkey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break </s> remove /* Process certificate data and its private key. CertificateChain, PrivateKey parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(CertificateChain, PrivateKey, ServerName string) tlsConfigStatus { var err error var data tlsConfigStatus // check only public certificate separately from the key if CertificateChain != "" { log.Tracef("got certificate: %s", CertificateChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(CertificateChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) } </s> add // Return 0 on success func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int { log.Tracef("got certificate: %s", certChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(certChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames </s> add if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) </s> add // validate private key (right now the only validation possible is just parsing it) if pkey != "" { if validatePkey(&data, pkey) != 0 { </s> remove if key == nil { data.WarningValidation = "No valid keys were found" </s> add data.ValidKey = true data.KeyType = keytype return 0 } /* Process certificate data and its private key. All parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(certChain, pkey, serverName string) tlsConfigStatus { var data tlsConfigStatus // check only public certificate separately from the key if certChain != "" { if verifyCertChain(&data, certChain, serverName) != 0 {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "ke...
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
data.ValidKey = true data.KeyType = keytype return 0 } /* Process certificate data and its private key. All parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(certChain, pkey, serverName string) tlsConfigStatus { var data tlsConfigStatus // check only public certificate separately from the key if certChain != "" { if verifyCertChain(&data, certChain, serverName) != 0 {
<mask> skippedBytes = append(skippedBytes, decoded.Type) <mask> } <mask> } <mask> <mask> if key == nil { <mask> data.WarningValidation = "No valid keys were found" <mask> return data <mask> } <mask> <mask> // parse the decoded key <mask> _, keytype, err := parsePrivateKey(key.Bytes) </s> * validateCertificates(): split the function's code </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 } </s> remove // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) </s> add // validate private key (right now the only validation possible is just parsing it) if pkey != "" { if validatePkey(&data, pkey) != 0 { </s> remove // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames </s> add if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove /* Process certificate data and its private key. CertificateChain, PrivateKey parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(CertificateChain, PrivateKey, ServerName string) tlsConfigStatus { var err error var data tlsConfigStatus // check only public certificate separately from the key if CertificateChain != "" { log.Tracef("got certificate: %s", CertificateChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(CertificateChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) } </s> add // Return 0 on success func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int { log.Tracef("got certificate: %s", certChain) // now do a more extended validation var certs []*pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes pemblock := []byte(certChain) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "CERTIFICATE" { certs = append(certs, decoded) } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true </s> add // TODO: save it as a warning rather than error it out -- shouldn't be a big problem mainCert := parsedCerts[0] _, err := mainCert.Verify(opts) if err != nil { // let self-signed certs through data.WarningValidation = fmt.Sprintf("Your certificate does not verify: %s", err) } else { data.ValidChain = true } // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames } return 0 } // Return 0 on success func validatePkey(data *tlsConfigStatus, pkey string) int { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(pkey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
}
<mask> if certChain != "" { <mask> if verifyCertChain(&data, certChain, serverName) != 0 { <mask> return data <mask> } <mask> <mask> // validate private key (right now the only validation possible is just parsing it) <mask> if pkey != "" { <mask> if validatePkey(&data, pkey) != 0 { <mask> return data </s> * validateCertificates(): split the function's code </s> remove // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) </s> add // validate private key (right now the only validation possible is just parsing it) if pkey != "" { if validatePkey(&data, pkey) != 0 { </s> remove if key == nil { data.WarningValidation = "No valid keys were found" </s> add data.ValidKey = true data.KeyType = keytype return 0 } /* Process certificate data and its private key. All parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(certChain, pkey, serverName string) tlsConfigStatus { var data tlsConfigStatus // check only public certificate separately from the key if certChain != "" { if verifyCertChain(&data, certChain, serverName) != 0 { </s> remove // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames </s> add if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 } </s> remove if PrivateKey != "" && CertificateChain != "" { _, err = tls.X509KeyPair([]byte(CertificateChain), []byte(PrivateKey)) </s> add if pkey != "" && certChain != "" { _, err := tls.X509KeyPair([]byte(certChain), []byte(pkey))
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
// validate private key (right now the only validation possible is just parsing it) if pkey != "" { if validatePkey(&data, pkey) != 0 {
<mask> data.WarningValidation = "No valid keys were found" <mask> return data <mask> } <mask> <mask> // parse the decoded key <mask> _, keytype, err := parsePrivateKey(key.Bytes) <mask> if err != nil { <mask> data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) <mask> return data <mask> } <mask> <mask> data.ValidKey = true <mask> data.KeyType = keytype </s> * validateCertificates(): split the function's code </s> remove if key == nil { data.WarningValidation = "No valid keys were found" </s> add data.ValidKey = true data.KeyType = keytype return 0 } /* Process certificate data and its private key. All parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(certChain, pkey, serverName string) tlsConfigStatus { var data tlsConfigStatus // check only public certificate separately from the key if certChain != "" { if verifyCertChain(&data, certChain, serverName) != 0 { </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 } </s> remove data.ValidKey = true data.KeyType = keytype </s> add </s> remove if PrivateKey != "" && CertificateChain != "" { _, err = tls.X509KeyPair([]byte(CertificateChain), []byte(PrivateKey)) </s> add if pkey != "" && certChain != "" { _, err := tls.X509KeyPair([]byte(certChain), []byte(pkey)) </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
<mask> if err != nil { <mask> data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) <mask> return data <mask> } <mask> <mask> data.ValidKey = true <mask> data.KeyType = keytype <mask> } <mask> <mask> // if both are set, validate both in unison <mask> if PrivateKey != "" && CertificateChain != "" { <mask> _, err = tls.X509KeyPair([]byte(CertificateChain), []byte(PrivateKey)) </s> * validateCertificates(): split the function's code </s> remove if PrivateKey != "" && CertificateChain != "" { _, err = tls.X509KeyPair([]byte(CertificateChain), []byte(PrivateKey)) </s> add if pkey != "" && certChain != "" { _, err := tls.X509KeyPair([]byte(certChain), []byte(pkey)) </s> remove // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) </s> add // validate private key (right now the only validation possible is just parsing it) if pkey != "" { if validatePkey(&data, pkey) != 0 { </s> remove if key == nil { data.WarningValidation = "No valid keys were found" </s> add data.ValidKey = true data.KeyType = keytype return 0 } /* Process certificate data and its private key. All parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(certChain, pkey, serverName string) tlsConfigStatus { var data tlsConfigStatus // check only public certificate separately from the key if certChain != "" { if verifyCertChain(&data, certChain, serverName) != 0 { </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 } </s> remove for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return data } parsedCerts = append(parsedCerts, parsed) </s> add for _, cert := range certs { parsed, err := x509.ParseCertificate(cert.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) return 1
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
if pkey != "" && certChain != "" { _, err := tls.X509KeyPair([]byte(certChain), []byte(pkey))
<mask> data.KeyType = keytype <mask> } <mask> <mask> // if both are set, validate both in unison <mask> if PrivateKey != "" && CertificateChain != "" { <mask> _, err = tls.X509KeyPair([]byte(CertificateChain), []byte(PrivateKey)) <mask> if err != nil { <mask> data.WarningValidation = fmt.Sprintf("Invalid certificate or key: %s", err) <mask> return data <mask> } <mask> data.usable = true </s> * validateCertificates(): split the function's code </s> remove data.ValidKey = true data.KeyType = keytype </s> add </s> remove // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) </s> add // validate private key (right now the only validation possible is just parsing it) if pkey != "" { if validatePkey(&data, pkey) != 0 { </s> remove if key == nil { data.WarningValidation = "No valid keys were found" </s> add data.ValidKey = true data.KeyType = keytype return 0 } /* Process certificate data and its private key. All parameters are optional. On error, return partially set object with 'WarningValidation' field containing error description. */ func validateCertificates(certChain, pkey, serverName string) tlsConfigStatus { var data tlsConfigStatus // check only public certificate separately from the key if certChain != "" { if verifyCertChain(&data, certChain, serverName) != 0 { </s> remove // validate private key (right now the only validation possible is just parsing it) if PrivateKey != "" { // now do a more extended validation var key *pem.Block // PEM-encoded certificates var skippedBytes []string // skipped bytes // go through all pem blocks, but take first valid pem block and drop the rest pemblock := []byte(PrivateKey) for { var decoded *pem.Block decoded, pemblock = pem.Decode(pemblock) if decoded == nil { break } if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type) } } </s> add if key == nil { data.WarningValidation = "No valid keys were found" return 1 } // parse the decoded key _, keytype, err := parsePrivateKey(key.Bytes) if err != nil { data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) return 1 } </s> remove // spew.Dump(chains) // update status if mainCert != nil { notAfter := mainCert.NotAfter data.Subject = mainCert.Subject.String() data.Issuer = mainCert.Issuer.String() data.NotAfter = notAfter data.NotBefore = mainCert.NotBefore data.DNSNames = mainCert.DNSNames </s> add if decoded.Type == "PRIVATE KEY" || strings.HasSuffix(decoded.Type, " PRIVATE KEY") { key = decoded break } else { skippedBytes = append(skippedBytes, decoded.Type)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f4a6ca726c56febfac49ff72cb05533f404ae4c9
control.go
<mask> "extends": ".eslintrc", <mask> "rules": { <mask> "no-debugger":"warn", <mask> } <mask> } </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove "timeUpdated": "2023-03-29T00:10:35.167Z", </s> add "timeUpdated": "2023-04-06T10:46:09.881Z", </s> remove } </s> add </s> remove } </s> add </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ]
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
client/dev.eslintrc
}
<mask> "rules": { <mask> "no-debugger":"warn", <mask> } <mask> } </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove } </s> add </s> remove "timeUpdated": "2023-03-29T00:10:35.167Z", </s> add "timeUpdated": "2023-04-06T10:46:09.881Z", </s> remove } </s> add </s> remove } </s> add </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ]
[ "keep", "keep", "keep", "add" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
client/dev.eslintrc
"timeUpdated": "2023-04-06T10:46:09.881Z",
<mask> { <mask> "timeUpdated": "2023-03-29T00:10:35.167Z", <mask> "categories": { <mask> "0": "audio_video_player", <mask> "1": "comments", <mask> "2": "customer_interaction", <mask> "3": "pornvertising", </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove } </s> add </s> remove } </s> add </s> remove } </s> add </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ]
[ "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
client/src/helpers/trackers/trackers.json
<mask> "appmetrica.yandex.com": "yandex_appmetrica", <mask> "3gppnetwork.org": "3gpp", <mask> "3gpp.org": "3gpp" <mask> } <mask> } </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ] </s> remove 1.2.3.4 0x1 0x2 12:34:56:78:910 * wan </s> add </s> remove source ./testdata/* </s> add
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
client/src/helpers/trackers/trackers.json
}
<mask> "3gppnetwork.org": "3gpp", <mask> "3gpp.org": "3gpp" <mask> } <mask> } </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove } </s> add </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ] </s> remove 1.2.3.4 0x1 0x2 12:34:56:78:910 * wan </s> add </s> remove source ./testdata/* </s> add
[ "keep", "keep", "keep", "add" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
client/src/helpers/trackers/trackers.json
<mask> } else { <mask> print addrs[i] ":" port <mask> } <mask> } <mask> } </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove } </s> add </s> remove "timeUpdated": "2023-03-29T00:10:35.167Z", </s> add "timeUpdated": "2023-04-06T10:46:09.881Z", </s> remove } </s> add </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ]
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
docker/dns-bind.awk
<mask> print "http://[" host "]:" port <mask> } else { <mask> print "http://" host ":" port <mask> } <mask> } </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove } </s> add </s> remove "timeUpdated": "2023-03-29T00:10:35.167Z", </s> add "timeUpdated": "2023-04-06T10:46:09.881Z", </s> remove } </s> add </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ]
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
docker/web-bind.awk
<mask> ::42 domain.alias domain <mask> 1.3.5.7 domain4 domain4.alias <mask> 7.5.3.1 domain4.alias domain4 <mask> ::13 domain6 domain6.alias <mask> ::31 domain6.alias domain6 </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ] </s> remove 1.2.3.4 0x1 0x2 12:34:56:78:910 * wan </s> add </s> remove source ./testdata/* </s> add </s> remove } </s> add
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
internal/aghnet/testdata/etc_hosts
<mask> # The "testdata" part is added here because the test is actually run from the <mask> # parent directory. Real interface files usually contain only absolute paths. <mask> <mask> source ./testdata/ifaces <mask> source ./testdata/* </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ] </s> remove 1.2.3.4 0x1 0x2 12:34:56:78:910 * wan </s> add </s> remove ::31 domain6.alias domain6 </s> add </s> remove } </s> add
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
internal/aghnet/testdata/include-subsources
<mask> 192.168.1.2 0x1 0x2 ab:cd:ef:ab:cd:ef * wan <mask> ::ffff:ffff 0x1 0x0 ef:cd:ab:ef:cd:ab * br-lan <mask> 0.0.0.0 0x0 0x0 00:00:00:00:00:00 * unspec <mask> 1.2.3.4.5 0x1 0x2 aa:bb:cc:dd:ee:ff * wan <mask> 1.2.3.4 0x1 0x2 12:34:56:78:910 * wan </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ] </s> remove source ./testdata/* </s> add </s> remove ::31 domain6.alias domain6 </s> add </s> remove } </s> add
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
internal/aghnet/testdata/proc_net_arp
1.2.3.4 0x1 0x2 12:34:56:78:910 * wan
<mask> ::ffff:ffff 0x1 0x0 ef:cd:ab:ef:cd:ab * br-lan <mask> 0.0.0.0 0x0 0x0 00:00:00:00:00:00 * unspec <mask> 1.2.3.4.5 0x1 0x2 aa:bb:cc:dd:ee:ff * wan <mask> 1.2.3.4 0x1 0x2 12:34:56:78:910 * wan </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove 1.2.3.4 0x1 0x2 12:34:56:78:910 * wan </s> add </s> remove if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] </s> add if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ] </s> remove source ./testdata/* </s> add </s> remove ::31 domain6.alias domain6 </s> add </s> remove } </s> add
[ "keep", "keep", "keep", "add" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
internal/aghnet/testdata/proc_net_arp
if [ "$( git diff --cached --name-only -- '*.md' '*.txt' '*.yaml' '*.yml' )" ]
<mask> then <mask> make VERBOSE="$verbose" go-os-check go-lint go-test <mask> fi <mask> <mask> if [ "$( git diff --cached --name-only -- '*.md' '*.yaml' '*.yml' )" ] <mask> then <mask> make VERBOSE="$verbose" txt-lint <mask> fi <mask> <mask> if [ "$( git diff --cached --name-only -- './openapi/openapi.yaml' )" ] </s> Pull request 1804: newline-lint Merge in DNS/adguard-home from newline-lint to master Squashed commit of the following: commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 14:16:14 2023 +0300 client: rm line commit 10246727179a84094edd17fad5cd6f0a5c38b821 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 6 13:51:06 2023 +0300 all: add newline lint </s> remove 1.2.3.4 0x1 0x2 12:34:56:78:910 * wan </s> add </s> remove source ./testdata/* </s> add </s> remove ::31 domain6.alias domain6 </s> add </s> remove } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f553eee842080aba34d9c2a5e0ddcffeef07e0ae
scripts/hooks/pre-commit
<mask> github.com/kardianos/service v1.2.1 <mask> github.com/lucas-clemente/quic-go v0.28.1 <mask> github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 <mask> github.com/mdlayher/netlink v1.6.0 <mask> github.com/mdlayher/packet v1.0.0 <mask> // TODO(a.garipov): This package is deprecated; find a new one or use <mask> // our own code for that. <mask> github.com/mdlayher/raw v0.1.0 // indirect <mask> github.com/miekg/dns v1.1.50 <mask> github.com/stretchr/testify v1.7.1 </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove // our own code for that. github.com/mdlayher/raw v0.1.0 // indirect </s> add // our own code for that. Perhaps, use gopacket. github.com/mdlayher/raw v0.1.0 </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> add // raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> remove packet.Addr </s> add raw.Addr
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
go.mod
// our own code for that. Perhaps, use gopacket. github.com/mdlayher/raw v0.1.0
<mask> github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 <mask> github.com/mdlayher/netlink v1.6.0 <mask> github.com/mdlayher/packet v1.0.0 <mask> // TODO(a.garipov): This package is deprecated; find a new one or use <mask> // our own code for that. <mask> github.com/mdlayher/raw v0.1.0 // indirect <mask> github.com/miekg/dns v1.1.50 <mask> github.com/stretchr/testify v1.7.1 <mask> github.com/ti-mo/netfilter v0.4.0 <mask> go.etcd.io/bbolt v1.3.6 <mask> golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove github.com/mdlayher/packet v1.0.0 </s> add </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> add // raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> remove packet.Addr </s> add raw.Addr
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
go.mod
github.com/mdlayher/packet v1.0.0 // indirect
<mask> github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect <mask> github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect <mask> github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect <mask> github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1 // indirect <mask> github.com/mdlayher/socket v0.2.3 // indirect <mask> github.com/nxadm/tail v1.4.8 // indirect <mask> github.com/onsi/ginkgo v1.16.5 // indirect <mask> github.com/patrickmn/go-cache v2.1.0+incompatible // indirect <mask> github.com/pkg/errors v0.9.1 // indirect </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove github.com/mdlayher/packet v1.0.0 </s> add </s> remove // our own code for that. github.com/mdlayher/raw v0.1.0 // indirect </s> add // our own code for that. Perhaps, use gopacket. github.com/mdlayher/raw v0.1.0 </s> remove // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> add // raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove packet.Addr </s> add raw.Addr
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
go.mod
//lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw"
<mask> "github.com/google/gopacket/layers" <mask> "github.com/insomniacslk/dhcp/dhcpv4" <mask> "github.com/insomniacslk/dhcp/dhcpv4/server4" <mask> "github.com/mdlayher/ethernet" <mask> "github.com/mdlayher/packet" <mask> ) <mask> <mask> // dhcpUnicastAddr is the combination of MAC and IP addresses for responding to <mask> // the unconfigured host. <mask> type dhcpUnicastAddr struct { </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> add // raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> remove packet.Addr </s> add raw.Addr </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove "github.com/mdlayher/packet" </s> add </s> remove Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, </s> add Addr: raw.Addr{HardwareAddr: req.ClientHWAddr},
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/conn_unix.go
// raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without
<mask> <mask> // dhcpUnicastAddr is the combination of MAC and IP addresses for responding to <mask> // the unconfigured host. <mask> type dhcpUnicastAddr struct { <mask> // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without <mask> // actually implementing all methods. It also contains the client's <mask> // hardware address. <mask> packet.Addr <mask> <mask> // yiaddr is an IP address just allocated by server for the host. </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove packet.Addr </s> add raw.Addr </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, </s> add Addr: raw.Addr{HardwareAddr: req.ClientHWAddr}, </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove // our own code for that. github.com/mdlayher/raw v0.1.0 // indirect </s> add // our own code for that. Perhaps, use gopacket. github.com/mdlayher/raw v0.1.0
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/conn_unix.go
raw.Addr
<mask> type dhcpUnicastAddr struct { <mask> // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without <mask> // actually implementing all methods. It also contains the client's <mask> // hardware address. <mask> packet.Addr <mask> <mask> // yiaddr is an IP address just allocated by server for the host. <mask> yiaddr net.IP <mask> } <mask> </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> add // raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, </s> add Addr: raw.Addr{HardwareAddr: req.ClientHWAddr}, </s> remove // our own code for that. github.com/mdlayher/raw v0.1.0 // indirect </s> add // our own code for that. Perhaps, use gopacket. github.com/mdlayher/raw v0.1.0 </s> remove github.com/mdlayher/packet v1.0.0 </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/conn_unix.go
if ucast, err = raw.ListenPacket(iface, uint16(ethernet.EtherTypeIPv4), nil); err != nil {
<mask> <mask> // newDHCPConn creates the special connection for DHCP server. <mask> func (s *v4Server) newDHCPConn(iface *net.Interface) (c net.PacketConn, err error) { <mask> var ucast net.PacketConn <mask> ucast, err = packet.Listen( <mask> iface, <mask> packet.Raw, <mask> int(ethernet.EtherTypeIPv4), <mask> nil, <mask> ) <mask> if err != nil { <mask> return nil, fmt.Errorf("creating raw udp connection: %w", err) <mask> } <mask> <mask> // Create the UDP connection. <mask> var bcast net.PacketConn </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove Addr: packet.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> add Addr: raw.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> remove Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, </s> add Addr: raw.Addr{HardwareAddr: req.ClientHWAddr}, </s> remove "github.com/mdlayher/packet" </s> add </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw"
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/conn_unix.go
<mask> "github.com/AdguardTeam/golibs/testutil" <mask> "github.com/google/gopacket" <mask> "github.com/google/gopacket/layers" <mask> "github.com/insomniacslk/dhcp/dhcpv4" <mask> "github.com/mdlayher/packet" <mask> "github.com/stretchr/testify/assert" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> <mask> func TestDHCPConn_WriteTo_common(t *testing.T) { </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove "github.com/mdlayher/packet" </s> add </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/conn_unix_test.go
//lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw"
<mask> "github.com/stretchr/testify/assert" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> <mask> func TestDHCPConn_WriteTo_common(t *testing.T) { <mask> respData := (&dhcpv4.DHCPv4{}).ToBytes() <mask> udpAddr := &net.UDPAddr{ <mask> IP: net.IP{1, 2, 3, 4}, </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove Addr: packet.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, </s> add Addr: raw.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, </s> remove "github.com/mdlayher/packet" </s> add </s> remove Addr: packet.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> add Addr: raw.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> remove "github.com/mdlayher/packet" </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/conn_unix_test.go
Addr: raw.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}},
<mask> srcMAC: net.HardwareAddr{1, 2, 3, 4, 5, 6}, <mask> srcIP: net.IP{1, 2, 3, 4}, <mask> } <mask> peer := &dhcpUnicastAddr{ <mask> Addr: packet.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, <mask> yiaddr: net.IP{4, 3, 2, 1}, <mask> } <mask> payload := (&dhcpv4.DHCPv4{}).ToBytes() <mask> <mask> t.Run("success", func(t *testing.T) { </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove Addr: packet.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> add Addr: raw.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> remove Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, </s> add Addr: raw.Addr{HardwareAddr: req.ClientHWAddr}, </s> remove Addr: packet.Addr{HardwareAddr: knownMAC}, </s> add Addr: raw.Addr{HardwareAddr: knownMAC}, </s> remove "github.com/mdlayher/packet" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/conn_unix_test.go
Addr: raw.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}},
<mask> <mask> t.Run("serializing_error", func(t *testing.T) { <mask> // Create a peer with invalid MAC. <mask> badPeer := &dhcpUnicastAddr{ <mask> Addr: packet.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, <mask> yiaddr: net.IP{4, 3, 2, 1}, <mask> } <mask> <mask> pkt, err := conn.buildEtherPkt(payload, badPeer) <mask> require.Error(t, err) </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove Addr: packet.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, </s> add Addr: raw.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, </s> remove Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, </s> add Addr: raw.Addr{HardwareAddr: req.ClientHWAddr}, </s> remove ucast, err = packet.Listen( iface, packet.Raw, int(ethernet.EtherTypeIPv4), nil, ) if err != nil { </s> add if ucast, err = raw.ListenPacket(iface, uint16(ethernet.EtherTypeIPv4), nil); err != nil { </s> remove Addr: packet.Addr{HardwareAddr: knownMAC}, </s> add Addr: raw.Addr{HardwareAddr: knownMAC},
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/conn_unix_test.go
//lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw"
<mask> "github.com/AdguardTeam/golibs/timeutil" <mask> "github.com/go-ping/ping" <mask> "github.com/insomniacslk/dhcp/dhcpv4" <mask> "github.com/insomniacslk/dhcp/dhcpv4/server4" <mask> "github.com/mdlayher/packet" <mask> ) <mask> <mask> // v4Server is a DHCPv4 server. <mask> // <mask> // TODO(a.garipov): Think about unifying this and v6Server. </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove github.com/mdlayher/packet v1.0.0 </s> add </s> remove // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> add // raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> remove // our own code for that. github.com/mdlayher/raw v0.1.0 // indirect </s> add // our own code for that. Perhaps, use gopacket. github.com/mdlayher/raw v0.1.0 </s> remove Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, </s> add Addr: raw.Addr{HardwareAddr: req.ClientHWAddr},
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/v4.go
Addr: raw.Addr{HardwareAddr: req.ClientHWAddr},
<mask> case !req.IsBroadcast() && req.ClientHWAddr != nil: <mask> // Unicast DHCPOFFER and DHCPACK messages to the client's <mask> // hardware address and yiaddr. <mask> peer = &dhcpUnicastAddr{ <mask> Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, <mask> yiaddr: resp.YourIPAddr, <mask> } <mask> default: <mask> // Go on since peer is already set to broadcast. <mask> } </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> add // raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without </s> remove Addr: packet.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> add Addr: raw.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> remove packet.Addr </s> add raw.Addr </s> remove Addr: packet.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, </s> add Addr: raw.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/v4.go
<mask> <mask> "github.com/AdguardTeam/golibs/stringutil" <mask> "github.com/AdguardTeam/golibs/testutil" <mask> "github.com/insomniacslk/dhcp/dhcpv4" <mask> "github.com/mdlayher/packet" <mask> "github.com/stretchr/testify/assert" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> <mask> var ( </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove "github.com/mdlayher/packet" </s> add </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw" </s> remove "github.com/mdlayher/packet" </s> add //lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/v4_test.go
//lint:ignore SA1019 See the TODO in go.mod. "github.com/mdlayher/raw"
<mask> "github.com/AdguardTeam/golibs/testutil" <mask> "github.com/insomniacslk/dhcp/dhcpv4" <mask> "github.com/stretchr/testify/assert" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> <mask> var ( <mask> DefaultRangeStart = net.IP{192, 168, 10, 100} <mask> DefaultRangeEnd = net.IP{192, 168, 10, 200} <mask> DefaultGatewayIP = net.IP{192, 168, 10, 1} </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove "github.com/mdlayher/packet" </s> add </s> remove ucast, err = packet.Listen( iface, packet.Raw, int(ethernet.EtherTypeIPv4), nil, ) if err != nil { </s> add if ucast, err = raw.ListenPacket(iface, uint16(ethernet.EtherTypeIPv4), nil); err != nil { </s> remove "github.com/mdlayher/packet" </s> add </s> remove Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, </s> add Addr: raw.Addr{HardwareAddr: req.ClientHWAddr},
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/v4_test.go
Addr: raw.Addr{HardwareAddr: knownMAC},
<mask> name: "chaddr", <mask> req: &dhcpv4.DHCPv4{ClientHWAddr: knownMAC}, <mask> resp: &dhcpv4.DHCPv4{YourIPAddr: knownIP}, <mask> want: &dhcpUnicastAddr{ <mask> Addr: packet.Addr{HardwareAddr: knownMAC}, <mask> yiaddr: knownIP, <mask> }, <mask> }, { <mask> name: "who_are_you", <mask> req: &dhcpv4.DHCPv4{}, </s> Pull request: 4836-revert-dhcp-upd Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd </s> remove Addr: packet.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> add Addr: raw.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, </s> remove Addr: packet.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, </s> add Addr: raw.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, </s> remove Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, </s> add Addr: raw.Addr{HardwareAddr: req.ClientHWAddr}, </s> remove "github.com/mdlayher/packet" </s> add </s> remove ucast, err = packet.Listen( iface, packet.Raw, int(ethernet.EtherTypeIPv4), nil, ) if err != nil { </s> add if ucast, err = raw.ListenPacket(iface, uint16(ethernet.EtherTypeIPv4), nil); err != nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f58265ec98dbdcfee030cc77d89e5d02b02da389
internal/dhcpd/v4_test.go
.card-table .logs__row { overflow: visible; }
<mask> overflow: hidden; <mask> text-overflow: ellipsis; <mask> } <mask> <mask> .logs__row--center { <mask> justify-content: center; <mask> } <mask> <mask> .logs__row--column { </s> - client: Display DomainCell popover Close #1817 Squashed commit of the following: commit 203d52e9b23013cb516765c3d41c288f8ce9d90c Merge: 5c78d918 205680b7 Author: ArtemBaskal <a.baskal@adguard.com> Date: Fri Jul 3 11:15:28 2020 +0300 Merge branch 'master' into fix/1817 commit 5c78d918ee2901ff138d5d06046e74ed00dc230d Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Jul 2 17:50:59 2020 +0300 - client: Display DomainCell popover </s> remove <svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg> </s> add <svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"> <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path> <circle cx="12" cy="12" r="3"></circle> </svg> </s> remove <Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}><strong>{data.name}</strong></a> </s> add <Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}> <strong>{data.name}</strong> </a> </s> remove <Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}><strong>{sourceData.name}</strong></a> </s> add <Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}> <strong>{sourceData.name}</strong> </a>
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5a1f311033c38272c8c017271a1832709c46ed3
client/src/components/Logs/Logs.css
<Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}> <strong>{sourceData.name}</strong> </a>
<mask> const sourceData = getSourceData(data); <mask> <mask> const source = ( <mask> <div className="popover__list-item"> <mask> <Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}><strong>{sourceData.name}</strong></a> <mask> </div> <mask> ); <mask> <mask> const tracker = ( <mask> <div className="popover__list-item"> </s> - client: Display DomainCell popover Close #1817 Squashed commit of the following: commit 203d52e9b23013cb516765c3d41c288f8ce9d90c Merge: 5c78d918 205680b7 Author: ArtemBaskal <a.baskal@adguard.com> Date: Fri Jul 3 11:15:28 2020 +0300 Merge branch 'master' into fix/1817 commit 5c78d918ee2901ff138d5d06046e74ed00dc230d Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Jul 2 17:50:59 2020 +0300 - client: Display DomainCell popover </s> remove <Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}><strong>{data.name}</strong></a> </s> add <Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}> <strong>{data.name}</strong> </a> </s> remove <svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg> </s> add <svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"> <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path> <circle cx="12" cy="12" r="3"></circle> </svg>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5a1f311033c38272c8c017271a1832709c46ed3
client/src/components/ui/Popover.js
<Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}> <strong>{data.name}</strong> </a>
<mask> ); <mask> <mask> const tracker = ( <mask> <div className="popover__list-item"> <mask> <Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}><strong>{data.name}</strong></a> <mask> </div> <mask> ); <mask> <mask> const categoryName = captitalizeWords(data.category); <mask> </s> - client: Display DomainCell popover Close #1817 Squashed commit of the following: commit 203d52e9b23013cb516765c3d41c288f8ce9d90c Merge: 5c78d918 205680b7 Author: ArtemBaskal <a.baskal@adguard.com> Date: Fri Jul 3 11:15:28 2020 +0300 Merge branch 'master' into fix/1817 commit 5c78d918ee2901ff138d5d06046e74ed00dc230d Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Jul 2 17:50:59 2020 +0300 - client: Display DomainCell popover </s> remove <Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}><strong>{sourceData.name}</strong></a> </s> add <Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}> <strong>{sourceData.name}</strong> </a> </s> remove <svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg> </s> add <svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"> <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path> <circle cx="12" cy="12" r="3"></circle> </svg>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5a1f311033c38272c8c017271a1832709c46ed3
client/src/components/ui/Popover.js
<svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"> <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path> <circle cx="12" cy="12" r="3"></circle> </svg>
<mask> <mask> return ( <mask> <div className="popover-wrap"> <mask> <div className="popover__trigger"> <mask> <svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg> <mask> </div> <mask> <div className="popover__body"> <mask> <div className="popover__list"> <mask> <div className="popover__list-title"> <mask> <Trans>found_in_known_domain_db</Trans> </s> - client: Display DomainCell popover Close #1817 Squashed commit of the following: commit 203d52e9b23013cb516765c3d41c288f8ce9d90c Merge: 5c78d918 205680b7 Author: ArtemBaskal <a.baskal@adguard.com> Date: Fri Jul 3 11:15:28 2020 +0300 Merge branch 'master' into fix/1817 commit 5c78d918ee2901ff138d5d06046e74ed00dc230d Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Jul 2 17:50:59 2020 +0300 - client: Display DomainCell popover </s> remove <Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}><strong>{sourceData.name}</strong></a> </s> add <Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}> <strong>{sourceData.name}</strong> </a> </s> remove <Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}><strong>{data.name}</strong></a> </s> add <Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}> <strong>{data.name}</strong> </a>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5a1f311033c38272c8c017271a1832709c46ed3
client/src/components/ui/Popover.js
.card-table .ReactTable .rt-td { overflow: visible; }
<mask> text-overflow: ellipsis; <mask> } <mask> <mask> .ReactTable .rt-tbody { <mask> overflow: visible; <mask> } <mask> </s> - client: Display DomainCell popover Close #1817 Squashed commit of the following: commit 203d52e9b23013cb516765c3d41c288f8ce9d90c Merge: 5c78d918 205680b7 Author: ArtemBaskal <a.baskal@adguard.com> Date: Fri Jul 3 11:15:28 2020 +0300 Merge branch 'master' into fix/1817 commit 5c78d918ee2901ff138d5d06046e74ed00dc230d Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu Jul 2 17:50:59 2020 +0300 - client: Display DomainCell popover </s> remove <svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg> </s> add <svg className="popover__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"> <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path> <circle cx="12" cy="12" r="3"></circle> </svg> </s> remove <Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}><strong>{data.name}</strong></a> </s> add <Trans>name_table_header</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={data.url}> <strong>{data.name}</strong> </a> </s> remove <Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}><strong>{sourceData.name}</strong></a> </s> add <Trans>source_label</Trans>: <a className="popover__link" target="_blank" rel="noopener noreferrer" href={sourceData.url}> <strong>{sourceData.name}</strong> </a>
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5a1f311033c38272c8c017271a1832709c46ed3
client/src/components/ui/ReactTable.css
// errBadAddrPassed is returned when dialFunc can't parse an IP address. errBadAddrPassed agherr.Error = "the passed string is not a valid IP address"
<mask> refresh() (err error) <mask> } <mask> <mask> const ( <mask> // fakeDialErr is an error which dialFunc is expected to return. <mask> fakeDialErr agherr.Error = "this error signals the successful dialFunc work" <mask> <mask> // badAddrPassedErr is returned when dialFunc can't parse an IP address. <mask> badAddrPassedErr agherr.Error = "the passed string is not a valid IP address" <mask> ) <mask> </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove // badAddrPassedErr is returned when dialFunc can't parse an IP address. badAddrPassedErr agherr.Error = "the passed string is not a valid IP address" </s> add // errFakeDial is an error which dialFunc is expected to return. errFakeDial agherr.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat agherr.Error = "unexpected host format" </s> remove // TODO(e.burkov): Maybe use a structured badAddrPassedErr to </s> add // TODO(e.burkov): Maybe use a structured errBadAddrPassed to </s> remove return nil, fmt.Errorf("%s: %w", err, badAddrPassedErr) </s> add return nil, fmt.Errorf("%s: %w", err, errBadAddrPassed) </s> remove return nil, fakeDialErr </s> add return nil, errFakeDial </s> remove if net.ParseIP(host) == nil { return nil, fmt.Errorf("parsing %q: %w", host, badAddrPassedErr) </s> add err = validateDialedHost(host) if err != nil { return nil, fmt.Errorf("validating dialed host: %w", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers.go
// errFakeDial is an error which dialFunc is expected to return. errFakeDial agherr.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat agherr.Error = "unexpected host format"
<mask> const ( <mask> // fakeDialErr is an error which dialFunc is expected to return. <mask> fakeDialErr agherr.Error = "this error signals the successful dialFunc work" <mask> <mask> // badAddrPassedErr is returned when dialFunc can't parse an IP address. <mask> badAddrPassedErr agherr.Error = "the passed string is not a valid IP address" <mask> ) <mask> <mask> // refreshWithTicker refreshes the cache of sr after each tick form tickCh. <mask> func refreshWithTicker(sr SystemResolvers, tickCh <-chan time.Time) { <mask> defer agherr.LogPanic("systemResolvers") </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove // fakeDialErr is an error which dialFunc is expected to return. fakeDialErr agherr.Error = "this error signals the successful dialFunc work" </s> add // errBadAddrPassed is returned when dialFunc can't parse an IP address. errBadAddrPassed agherr.Error = "the passed string is not a valid IP address" </s> remove // TODO(e.burkov): Maybe use a structured badAddrPassedErr to </s> add // TODO(e.burkov): Maybe use a structured errBadAddrPassed to </s> remove return nil, fmt.Errorf("%s: %w", err, badAddrPassedErr) </s> add return nil, fmt.Errorf("%s: %w", err, errBadAddrPassed) </s> remove return nil, fakeDialErr </s> add return nil, errFakeDial </s> remove if net.ParseIP(host) == nil { return nil, fmt.Errorf("parsing %q: %w", host, badAddrPassedErr) </s> add err = validateDialedHost(host) if err != nil { return nil, fmt.Errorf("validating dialed host: %w", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers.go
"strings"
<mask> "errors" <mask> "fmt" <mask> "net" <mask> "sync" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove want: badAddrPassedErr, </s> add </s> remove want: badAddrPassedErr, </s> add </s> remove want: fakeDialErr, </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others.go
if errors.As(err, &dnserr) && dnserr.Err == errFakeDial.Error() {
<mask> defer agherr.Annotate("systemResolvers: %w", &err) <mask> <mask> _, err = sr.resolver.LookupHost(context.Background(), sr.hostGenFunc()) <mask> dnserr := &net.DNSError{} <mask> if errors.As(err, &dnserr) && dnserr.Err == fakeDialErr.Error() { <mask> return nil <mask> } <mask> <mask> return err <mask> } </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove if net.ParseIP(host) == nil { return nil, fmt.Errorf("parsing %q: %w", host, badAddrPassedErr) </s> add err = validateDialedHost(host) if err != nil { return nil, fmt.Errorf("validating dialed host: %w", err) </s> remove return nil, fmt.Errorf("%s: %w", err, badAddrPassedErr) </s> add return nil, fmt.Errorf("%s: %w", err, errBadAddrPassed) </s> remove // TODO(e.burkov): Maybe use a structured badAddrPassedErr to </s> add // TODO(e.burkov): Maybe use a structured errBadAddrPassed to </s> remove return nil, fakeDialErr </s> add return nil, errFakeDial </s> remove want: badAddrPassedErr, </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others.go
// TODO(e.burkov): Maybe use a structured errBadAddrPassed to
<mask> // Just validate the passed address is a valid IP. <mask> var host string <mask> host, err = SplitHost(address) <mask> if err != nil { <mask> // TODO(e.burkov): Maybe use a structured badAddrPassedErr to <mask> // allow unwrapping of the real error. <mask> return nil, fmt.Errorf("%s: %w", err, badAddrPassedErr) <mask> } <mask> <mask> if net.ParseIP(host) == nil { </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove return nil, fmt.Errorf("%s: %w", err, badAddrPassedErr) </s> add return nil, fmt.Errorf("%s: %w", err, errBadAddrPassed) </s> remove if net.ParseIP(host) == nil { return nil, fmt.Errorf("parsing %q: %w", host, badAddrPassedErr) </s> add err = validateDialedHost(host) if err != nil { return nil, fmt.Errorf("validating dialed host: %w", err) </s> remove // badAddrPassedErr is returned when dialFunc can't parse an IP address. badAddrPassedErr agherr.Error = "the passed string is not a valid IP address" </s> add // errFakeDial is an error which dialFunc is expected to return. errFakeDial agherr.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat agherr.Error = "unexpected host format" </s> remove // fakeDialErr is an error which dialFunc is expected to return. fakeDialErr agherr.Error = "this error signals the successful dialFunc work" </s> add // errBadAddrPassed is returned when dialFunc can't parse an IP address. errBadAddrPassed agherr.Error = "the passed string is not a valid IP address" </s> remove if errors.As(err, &dnserr) && dnserr.Err == fakeDialErr.Error() { </s> add if errors.As(err, &dnserr) && dnserr.Err == errFakeDial.Error() {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others.go
return nil, fmt.Errorf("%s: %w", err, errBadAddrPassed)
<mask> host, err = SplitHost(address) <mask> if err != nil { <mask> // TODO(e.burkov): Maybe use a structured badAddrPassedErr to <mask> // allow unwrapping of the real error. <mask> return nil, fmt.Errorf("%s: %w", err, badAddrPassedErr) <mask> } <mask> <mask> if net.ParseIP(host) == nil { <mask> return nil, fmt.Errorf("parsing %q: %w", host, badAddrPassedErr) <mask> } </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove // TODO(e.burkov): Maybe use a structured badAddrPassedErr to </s> add // TODO(e.burkov): Maybe use a structured errBadAddrPassed to </s> remove if net.ParseIP(host) == nil { return nil, fmt.Errorf("parsing %q: %w", host, badAddrPassedErr) </s> add err = validateDialedHost(host) if err != nil { return nil, fmt.Errorf("validating dialed host: %w", err) </s> remove if errors.As(err, &dnserr) && dnserr.Err == fakeDialErr.Error() { </s> add if errors.As(err, &dnserr) && dnserr.Err == errFakeDial.Error() { </s> remove return nil, fakeDialErr </s> add return nil, errFakeDial </s> remove // badAddrPassedErr is returned when dialFunc can't parse an IP address. badAddrPassedErr agherr.Error = "the passed string is not a valid IP address" </s> add // errFakeDial is an error which dialFunc is expected to return. errFakeDial agherr.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat agherr.Error = "unexpected host format"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others.go
err = validateDialedHost(host) if err != nil { return nil, fmt.Errorf("validating dialed host: %w", err)
<mask> // allow unwrapping of the real error. <mask> return nil, fmt.Errorf("%s: %w", err, badAddrPassedErr) <mask> } <mask> <mask> if net.ParseIP(host) == nil { <mask> return nil, fmt.Errorf("parsing %q: %w", host, badAddrPassedErr) <mask> } <mask> <mask> sr.addrsLock.Lock() <mask> defer sr.addrsLock.Unlock() <mask> </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove return nil, fmt.Errorf("%s: %w", err, badAddrPassedErr) </s> add return nil, fmt.Errorf("%s: %w", err, errBadAddrPassed) </s> remove // TODO(e.burkov): Maybe use a structured badAddrPassedErr to </s> add // TODO(e.burkov): Maybe use a structured errBadAddrPassed to </s> remove return nil, fakeDialErr </s> add return nil, errFakeDial </s> remove if errors.As(err, &dnserr) && dnserr.Err == fakeDialErr.Error() { </s> add if errors.As(err, &dnserr) && dnserr.Err == errFakeDial.Error() { </s> remove // badAddrPassedErr is returned when dialFunc can't parse an IP address. badAddrPassedErr agherr.Error = "the passed string is not a valid IP address" </s> add // errFakeDial is an error which dialFunc is expected to return. errFakeDial agherr.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat agherr.Error = "unexpected host format"
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others.go
return nil, errFakeDial
<mask> defer sr.addrsLock.Unlock() <mask> <mask> sr.addrs.Add(host) <mask> <mask> return nil, fakeDialErr <mask> } <mask> <mask> func (sr *systemResolvers) Get() (rs []string) { <mask> sr.addrsLock.RLock() <mask> defer sr.addrsLock.RUnlock() </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove if net.ParseIP(host) == nil { return nil, fmt.Errorf("parsing %q: %w", host, badAddrPassedErr) </s> add err = validateDialedHost(host) if err != nil { return nil, fmt.Errorf("validating dialed host: %w", err) </s> remove if errors.As(err, &dnserr) && dnserr.Err == fakeDialErr.Error() { </s> add if errors.As(err, &dnserr) && dnserr.Err == errFakeDial.Error() { </s> remove return nil, fmt.Errorf("%s: %w", err, badAddrPassedErr) </s> add return nil, fmt.Errorf("%s: %w", err, errBadAddrPassed) </s> remove // badAddrPassedErr is returned when dialFunc can't parse an IP address. badAddrPassedErr agherr.Error = "the passed string is not a valid IP address" </s> add // errFakeDial is an error which dialFunc is expected to return. errFakeDial agherr.Error = "this error signals the successful dialFunc work" // errUnexpectedHostFormat is returned by validateDialedHost when the host has // more than one percent sign. errUnexpectedHostFormat agherr.Error = "unexpected host format" </s> remove // TODO(e.burkov): Maybe use a structured badAddrPassedErr to </s> add // TODO(e.burkov): Maybe use a structured errBadAddrPassed to
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others.go
want error
<mask> imp := createTestSystemResolversImp(t, 0, nil) <mask> <mask> testCases := []struct { <mask> name string <mask> address string <mask> }{{ <mask> want: errFakeDial, <mask> name: "valid", <mask> address: "127.0.0.1", </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove want error </s> add </s> remove want: badAddrPassedErr, </s> add </s> remove want: fakeDialErr, </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others_test.go
<mask> <mask> testCases := []struct { <mask> name string <mask> address string <mask> want error <mask> }{{ <mask> name: "valid", <mask> address: "127.0.0.1", <mask> want: fakeDialErr, <mask> }, { </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove want: fakeDialErr, </s> add </s> remove want: badAddrPassedErr, </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others_test.go
want: errFakeDial,
<mask> name string <mask> address string <mask> }{{ <mask> name: "valid", <mask> address: "127.0.0.1", <mask> }, { <mask> want: errFakeDial, <mask> name: "valid_ipv6_port", <mask> address: "[::1]:53", </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove want error </s> add </s> remove want: fakeDialErr, </s> add </s> remove // TODO(e.burkov): Maybe use a structured badAddrPassedErr to </s> add // TODO(e.burkov): Maybe use a structured errBadAddrPassed to
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others_test.go
<mask> want error <mask> }{{ <mask> name: "valid", <mask> address: "127.0.0.1", <mask> want: fakeDialErr, <mask> }, { <mask> name: "invalid_split_host", <mask> address: "127.0.0.1::123", <mask> want: badAddrPassedErr, <mask> }, { </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove want error </s> add </s> remove want: badAddrPassedErr, </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others_test.go
want: errFakeDial, name: "valid_ipv6_port", address: "[::1]:53", }, { want: errFakeDial, name: "valid_ipv6_zone_port", address: "[::1%lo0]:53", }, { want: errBadAddrPassed,
<mask> name: "valid", <mask> address: "127.0.0.1", <mask> }, { <mask> name: "invalid_split_host", <mask> address: "127.0.0.1::123", <mask> }, { <mask> want: errUnexpectedHostFormat, </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove want: fakeDialErr, </s> add </s> remove want: badAddrPassedErr, </s> add </s> remove want error </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others_test.go
<mask> want: fakeDialErr, <mask> }, { <mask> name: "invalid_split_host", <mask> address: "127.0.0.1::123", <mask> want: badAddrPassedErr, <mask> }, { <mask> name: "invalid_parse_ip", <mask> address: "not-ip", <mask> want: badAddrPassedErr, <mask> }} </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove want: badAddrPassedErr, </s> add </s> remove want: fakeDialErr, </s> add </s> remove want error </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others_test.go
want: errUnexpectedHostFormat, name: "invalid_ipv6_zone_port", address: "[::1%%lo0]:53", }, { want: errBadAddrPassed,
<mask> name: "invalid_split_host", <mask> address: "127.0.0.1::123", <mask> }, { <mask> name: "invalid_parse_ip", <mask> address: "not-ip", <mask> }} <mask> <mask> for _, tc := range testCases { </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove want: badAddrPassedErr, </s> add </s> remove want: badAddrPassedErr, </s> add </s> remove want: fakeDialErr, </s> add </s> remove want error </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others_test.go
<mask> want: badAddrPassedErr, <mask> }, { <mask> name: "invalid_parse_ip", <mask> address: "not-ip", <mask> want: badAddrPassedErr, <mask> }} <mask> <mask> for _, tc := range testCases { <mask> t.Run(tc.name, func(t *testing.T) { <mask> conn, err := imp.dialFunc(context.Background(), "", tc.address) </s> Pull request: aghnet: imp host validation for system resolvers Updates #3022. Squashed commit of the following: commit 2f63b4e1765d9c9bfeadafcfa42c9d8741b628e1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:29:28 2021 +0300 aghnet: fix doc commit efdc1bb2c8959a9f888d558c32c415e6f3678b0c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:19:54 2021 +0300 all: doc changes commit 8154797095874771bcf04d109644e6ae33fcb470 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Apr 28 21:15:42 2021 +0300 aghnet: imp host validation for system resolvers </s> remove want: badAddrPassedErr, </s> add </s> remove want: fakeDialErr, </s> add </s> remove if errors.As(err, &dnserr) && dnserr.Err == fakeDialErr.Error() { </s> add if errors.As(err, &dnserr) && dnserr.Err == errFakeDial.Error() { </s> remove want error </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f5adf15c8c5ee0162169b0abb7554709df856542
internal/aghnet/systemresolvers_others_test.go
"strconv"
<mask> "encoding/json" <mask> "fmt" <mask> "net" <mask> "net/http" <mask> "strings" <mask> "sync" <mask> "time" <mask> </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) </s> add var arl *authRateLimiter if config.AuthAttempts > 0 && config.AuthBlockMin > 0 { arl = newAuthRateLimiter( time.Duration(config.AuthBlockMin)*time.Minute, config.AuthAttempts, ) } else { log.Info("authratelimiter is disabled") } Context.auth = InitAuth( sessFilename, config.Users, config.WebSessionTTLHours*60*60, arl, ) </s> remove func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth { </s> add func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateLimiter) *Auth { </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove a.users = users </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
blocker *authRateLimiter
<mask> <mask> // Auth - global object <mask> type Auth struct { <mask> db *bbolt.DB <mask> sessions map[string]*session <mask> users []User <mask> lock sync.Mutex <mask> sessionTTL uint32 <mask> } </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth { </s> add func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateLimiter) *Auth { </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) </s> add var arl *authRateLimiter if config.AuthAttempts > 0 && config.AuthBlockMin > 0 { arl = newAuthRateLimiter( time.Duration(config.AuthBlockMin)*time.Minute, config.AuthAttempts, ) } else { log.Info("authratelimiter is disabled") } Context.auth = InitAuth( sessFilename, config.Users, config.WebSessionTTLHours*60*60, arl, ) </s> remove return &a </s> add return a </s> remove a = InitAuth(fn, users, 60) </s> add a = InitAuth(fn, users, 60, nil)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateLimiter) *Auth {
<mask> PasswordHash string `yaml:"password"` // bcrypt hash <mask> } <mask> <mask> // InitAuth - create a global object <mask> func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth { <mask> log.Info("Initializing auth module: %s", dbFilename) <mask> <mask> a := Auth{} <mask> a.sessionTTL = sessionTTL <mask> a.sessions = make(map[string]*session) </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove return &a </s> add return a </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove func (a *Auth) httpCookie(req loginJSON) (string, error) { </s> add func (a *Auth) httpCookie(req loginJSON, addr string) (cookie string, err error) { blocker := a.blocker
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, }
<mask> // InitAuth - create a global object <mask> func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth { <mask> log.Info("Initializing auth module: %s", dbFilename) <mask> <mask> a := Auth{} <mask> a.sessionTTL = sessionTTL <mask> a.sessions = make(map[string]*session) <mask> var err error <mask> a.db, err = bbolt.Open(dbFilename, 0o644, nil) <mask> if err != nil { <mask> log.Error("auth: open DB: %s: %s", dbFilename, err) <mask> if err.Error() == "invalid argument" { </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth { </s> add func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateLimiter) *Auth { </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove sess, err := newSessionToken() </s> add if blocker != nil { blocker.remove(addr) } var sess []byte sess, err = newSessionToken() </s> remove return "", nil </s> add if blocker != nil { blocker.inc(addr) } return "", err
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
<mask> <mask> return nil <mask> } <mask> a.loadSessions() <mask> a.users = users <mask> log.Info("auth: initialized. users:%d sessions:%d", len(a.users), len(a.sessions)) <mask> <mask> return &a <mask> } <mask> </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove return &a </s> add return a </s> remove sess, err := newSessionToken() </s> add if blocker != nil { blocker.remove(addr) } var sess []byte sess, err = newSessionToken() </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove return "", nil </s> add if blocker != nil { blocker.inc(addr) } return "", err </s> remove func (a *Auth) httpCookie(req loginJSON) (string, error) { </s> add func (a *Auth) httpCookie(req loginJSON, addr string) (cookie string, err error) { blocker := a.blocker
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
return a
<mask> a.loadSessions() <mask> a.users = users <mask> log.Info("auth: initialized. users:%d sessions:%d", len(a.users), len(a.sessions)) <mask> <mask> return &a <mask> } <mask> <mask> // Close - close module <mask> func (a *Auth) Close() { <mask> _ = a.db.Close() </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove a.users = users </s> add </s> remove func (a *Auth) httpCookie(req loginJSON) (string, error) { </s> add func (a *Auth) httpCookie(req loginJSON, addr string) (cookie string, err error) { blocker := a.blocker </s> remove return "", nil </s> add if blocker != nil { blocker.inc(addr) } return "", err </s> remove Context.auth = InitAuth(fn, users, 60) </s> add Context.auth = InitAuth(fn, users, 60, nil) </s> remove func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth { </s> add func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateLimiter) *Auth {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
func (a *Auth) httpCookie(req loginJSON, addr string) (cookie string, err error) { blocker := a.blocker
<mask> func cookieExpiryFormat(exp time.Time) (formatted string) { <mask> return exp.Format(cookieTimeFormat) <mask> } <mask> <mask> func (a *Auth) httpCookie(req loginJSON) (string, error) { <mask> u := a.UserFind(req.Name, req.Password) <mask> if len(u.Name) == 0 { <mask> return "", nil <mask> } <mask> </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove return "", nil </s> add if blocker != nil { blocker.inc(addr) } return "", err </s> remove sess, err := newSessionToken() </s> add if blocker != nil { blocker.remove(addr) } var sess []byte sess, err = newSessionToken() </s> remove return &a </s> add return a </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) </s> add var arl *authRateLimiter if config.AuthAttempts > 0 && config.AuthBlockMin > 0 { arl = newAuthRateLimiter( time.Duration(config.AuthBlockMin)*time.Minute, config.AuthAttempts, ) } else { log.Info("authratelimiter is disabled") } Context.auth = InitAuth( sessFilename, config.Users, config.WebSessionTTLHours*60*60, arl, )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
if blocker != nil { blocker.inc(addr) } return "", err
<mask> <mask> func (a *Auth) httpCookie(req loginJSON) (string, error) { <mask> u := a.UserFind(req.Name, req.Password) <mask> if len(u.Name) == 0 { <mask> return "", nil <mask> } <mask> <mask> sess, err := newSessionToken() <mask> if err != nil { <mask> return "", err </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove func (a *Auth) httpCookie(req loginJSON) (string, error) { </s> add func (a *Auth) httpCookie(req loginJSON, addr string) (cookie string, err error) { blocker := a.blocker </s> remove sess, err := newSessionToken() </s> add if blocker != nil { blocker.remove(addr) } var sess []byte sess, err = newSessionToken() </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
if blocker != nil { blocker.remove(addr) } var sess []byte sess, err = newSessionToken()
<mask> if len(u.Name) == 0 { <mask> return "", nil <mask> } <mask> <mask> sess, err := newSessionToken() <mask> if err != nil { <mask> return "", err <mask> } <mask> <mask> now := time.Now().UTC() </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove return "", nil </s> add if blocker != nil { blocker.inc(addr) } return "", err </s> remove func (a *Auth) httpCookie(req loginJSON) (string, error) { </s> add func (a *Auth) httpCookie(req loginJSON, addr string) (cookie string, err error) { blocker := a.blocker </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
return } var remoteAddr string // The realIP couldn't be used here due to security issues. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2799. // // TODO(e.burkov): Use realIP when the issue will be fixed. if remoteAddr, err = aghnet.SplitHost(r.RemoteAddr); err != nil { httpError(w, http.StatusBadRequest, "auth: getting remote address: %s", err)
<mask> if err != nil { <mask> httpError(w, http.StatusBadRequest, "json decode: %s", err) <mask> return <mask> } <mask> <mask> if blocker := Context.auth.blocker; blocker != nil { <mask> if left := blocker.check(remoteAddr); left > 0 { <mask> w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove sess, err := newSessionToken() </s> add if blocker != nil { blocker.remove(addr) } var sess []byte sess, err = newSessionToken() </s> remove return "", nil </s> add if blocker != nil { blocker.inc(addr) } return "", err </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove func (a *Auth) httpCookie(req loginJSON) (string, error) { </s> add func (a *Auth) httpCookie(req loginJSON, addr string) (cookie string, err error) { blocker := a.blocker
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr)
<mask> httpError(w, http.StatusBadRequest, "json decode: %s", err) <mask> return <mask> } <mask> <mask> cookie, err := Context.auth.httpCookie(req) <mask> if err != nil { <mask> httpError(w, http.StatusBadRequest, "crypto rand reader: %s", err) <mask> <mask> return <mask> } </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove sess, err := newSessionToken() </s> add if blocker != nil { blocker.remove(addr) } var sess []byte sess, err = newSessionToken() </s> remove return "", nil </s> add if blocker != nil { blocker.inc(addr) } return "", err </s> remove cookie, err := Context.auth.httpCookie(loginJSON{Name: "name", Password: "password"}) </s> add cookie, err := Context.auth.httpCookie(loginJSON{Name: "name", Password: "password"}, "")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth.go
a := InitAuth(fn, nil, 60, nil)
<mask> users := []User{{ <mask> Name: "name", <mask> PasswordHash: "$2y$05$..vyzAECIhJPfaQiOK17IukcQnqEgKJHy0iETyYqxn3YXJl8yZuo2", <mask> }} <mask> a := InitAuth(fn, nil, 60) <mask> s := session{} <mask> <mask> user := User{Name: "name"} <mask> a.UserAdd(&user, "password") <mask> </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove Context.auth = InitAuth(fn, users, 60) </s> add Context.auth = InitAuth(fn, users, 60, nil) </s> remove cookie, err := Context.auth.httpCookie(loginJSON{Name: "name", Password: "password"}) </s> add cookie, err := Context.auth.httpCookie(loginJSON{Name: "name", Password: "password"}, "") </s> remove a = InitAuth(fn, users, 60) </s> add a = InitAuth(fn, users, 60, nil) </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove a = InitAuth(fn, users, 60) </s> add a = InitAuth(fn, users, 60, nil)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth_test.go
a = InitAuth(fn, users, 60, nil)
<mask> <mask> a.Close() <mask> <mask> // load saved session <mask> a = InitAuth(fn, users, 60) <mask> <mask> // the session is still alive <mask> assert.Equal(t, checkSessionOK, a.checkSession(sessStr)) <mask> // reset our expiration time because checkSession() has just updated it <mask> s.expire = uint32(time.Now().UTC().Unix() + 2) </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove a = InitAuth(fn, users, 60) </s> add a = InitAuth(fn, users, 60, nil) </s> remove ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client Language string `yaml:"language"` // two-letter ISO 639-1 language code RlimitNoFile uint `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 </s> add // AuthAttempts is the maximum number of failed login attempts a user // can do before being blocked. AuthAttempts uint `yaml:"auth_attempts"` // AuthBlockMin is the duration, in minutes, of the block of new login // attempts after AuthAttempts unsuccessful login attempts. AuthBlockMin uint `yaml:"block_auth_min"` ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client Language string `yaml:"language"` // two-letter ISO 639-1 language code RlimitNoFile uint `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 </s> remove Context.auth = InitAuth(fn, users, 60) </s> add Context.auth = InitAuth(fn, users, 60, nil) </s> remove a := InitAuth(fn, nil, 60) </s> add a := InitAuth(fn, nil, 60, nil) </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth_test.go
a = InitAuth(fn, users, 60, nil)
<mask> <mask> time.Sleep(3 * time.Second) <mask> <mask> // load and remove expired sessions <mask> a = InitAuth(fn, users, 60) <mask> assert.Equal(t, checkSessionNotFound, a.checkSession(sessStr)) <mask> <mask> a.Close() <mask> } <mask> </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove a = InitAuth(fn, users, 60) </s> add a = InitAuth(fn, users, 60, nil) </s> remove Context.auth = InitAuth(fn, users, 60) </s> add Context.auth = InitAuth(fn, users, 60, nil) </s> remove a := InitAuth(fn, nil, 60) </s> add a := InitAuth(fn, nil, 60, nil) </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth_test.go
Context.auth = InitAuth(fn, users, 60, nil)
<mask> <mask> users := []User{ <mask> {Name: "name", PasswordHash: "$2y$05$..vyzAECIhJPfaQiOK17IukcQnqEgKJHy0iETyYqxn3YXJl8yZuo2"}, <mask> } <mask> Context.auth = InitAuth(fn, users, 60) <mask> <mask> handlerCalled := false <mask> handler := func(_ http.ResponseWriter, _ *http.Request) { <mask> handlerCalled = true <mask> } </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove a := InitAuth(fn, nil, 60) </s> add a := InitAuth(fn, nil, 60, nil) </s> remove Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) </s> add var arl *authRateLimiter if config.AuthAttempts > 0 && config.AuthBlockMin > 0 { arl = newAuthRateLimiter( time.Duration(config.AuthBlockMin)*time.Minute, config.AuthAttempts, ) } else { log.Info("authratelimiter is disabled") } Context.auth = InitAuth( sessFilename, config.Users, config.WebSessionTTLHours*60*60, arl, ) </s> remove a = InitAuth(fn, users, 60) </s> add a = InitAuth(fn, users, 60, nil) </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove a = InitAuth(fn, users, 60) </s> add a = InitAuth(fn, users, 60, nil)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth_test.go
cookie, err := Context.auth.httpCookie(loginJSON{Name: "name", Password: "password"}, "")
<mask> handler2(&w, &r) <mask> assert.True(t, handlerCalled) <mask> <mask> // perform login <mask> cookie, err := Context.auth.httpCookie(loginJSON{Name: "name", Password: "password"}) <mask> assert.Nil(t, err) <mask> assert.NotEmpty(t, cookie) <mask> <mask> // get / <mask> handler2 = optionalAuth(handler) </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove Context.auth = InitAuth(fn, users, 60) </s> add Context.auth = InitAuth(fn, users, 60, nil) </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove a := InitAuth(fn, nil, 60) </s> add a := InitAuth(fn, nil, 60, nil)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/auth_test.go
// AuthAttempts is the maximum number of failed login attempts a user // can do before being blocked. AuthAttempts uint `yaml:"auth_attempts"` // AuthBlockMin is the duration, in minutes, of the block of new login // attempts after AuthAttempts unsuccessful login attempts. AuthBlockMin uint `yaml:"block_auth_min"` ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client Language string `yaml:"language"` // two-letter ISO 639-1 language code RlimitNoFile uint `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060
<mask> BindHost net.IP `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to <mask> BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server <mask> BetaBindPort int `yaml:"beta_bind_port"` // BetaBindPort is the port for new client <mask> Users []User `yaml:"users"` // Users that can access HTTP server <mask> ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client <mask> Language string `yaml:"language"` // two-letter ISO 639-1 language code <mask> RlimitNoFile uint `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) <mask> DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 <mask> <mask> // TTL for a web session (in hours) <mask> // An active session is automatically refreshed once a day. <mask> WebSessionTTLHours uint32 `yaml:"web_session_ttl"` <mask> </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove a = InitAuth(fn, users, 60) </s> add a = InitAuth(fn, users, 60, nil) </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) </s> add var arl *authRateLimiter if config.AuthAttempts > 0 && config.AuthBlockMin > 0 { arl = newAuthRateLimiter( time.Duration(config.AuthBlockMin)*time.Minute, config.AuthAttempts, ) } else { log.Info("authratelimiter is disabled") } Context.auth = InitAuth( sessFilename, config.Users, config.WebSessionTTLHours*60*60, arl, )
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/config.go
AuthAttempts: 5, AuthBlockMin: 15,
<mask> var config = configuration{ <mask> BindPort: 3000, <mask> BetaBindPort: 0, <mask> BindHost: net.IP{0, 0, 0, 0}, <mask> DNS: dnsConfig{ <mask> BindHosts: []net.IP{{0, 0, 0, 0}}, <mask> Port: 53, <mask> StatsInterval: 1, <mask> FilteringConfig: dnsforward.FilteringConfig{ <mask> ProtectionEnabled: true, // whether or not use any of dnsfilter features </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client Language string `yaml:"language"` // two-letter ISO 639-1 language code RlimitNoFile uint `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 </s> add // AuthAttempts is the maximum number of failed login attempts a user // can do before being blocked. AuthAttempts uint `yaml:"auth_attempts"` // AuthBlockMin is the duration, in minutes, of the block of new login // attempts after AuthAttempts unsuccessful login attempts. AuthBlockMin uint `yaml:"block_auth_min"` ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client Language string `yaml:"language"` // two-letter ISO 639-1 language code RlimitNoFile uint `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 </s> remove Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) </s> add var arl *authRateLimiter if config.AuthAttempts > 0 && config.AuthBlockMin > 0 { arl = newAuthRateLimiter( time.Duration(config.AuthBlockMin)*time.Minute, config.AuthAttempts, ) } else { log.Info("authratelimiter is disabled") } Context.auth = InitAuth( sessFilename, config.Users, config.WebSessionTTLHours*60*60, arl, ) </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove sess, err := newSessionToken() </s> add if blocker != nil { blocker.remove(addr) } var sess []byte sess, err = newSessionToken()
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/config.go
var arl *authRateLimiter if config.AuthAttempts > 0 && config.AuthBlockMin > 0 { arl = newAuthRateLimiter( time.Duration(config.AuthBlockMin)*time.Minute, config.AuthAttempts, ) } else { log.Info("authratelimiter is disabled") } Context.auth = InitAuth( sessFilename, config.Users, config.WebSessionTTLHours*60*60, arl, )
<mask> } <mask> <mask> sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") <mask> GLMode = args.glinetMode <mask> Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) <mask> if Context.auth == nil { <mask> log.Fatalf("Couldn't initialize Auth module") <mask> } <mask> config.Users = nil <mask> </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove Context.auth = InitAuth(fn, users, 60) </s> add Context.auth = InitAuth(fn, users, 60, nil) </s> remove sess, err := newSessionToken() </s> add if blocker != nil { blocker.remove(addr) } var sess []byte sess, err = newSessionToken() </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove cookie, err := Context.auth.httpCookie(req) </s> add if blocker := Context.auth.blocker; blocker != nil { if left := blocker.check(remoteAddr); left > 0 { w.Header().Set("Retry-After", strconv.Itoa(int(left.Seconds()))) httpError( w, http.StatusTooManyRequests, "auth: blocked for %s", left, ) return } } var cookie string cookie, err = Context.auth.httpCookie(req, remoteAddr) </s> remove return "", nil </s> add if blocker != nil { blocker.inc(addr) } return "", err
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
internal/home/home.go
'400': 'description': > Invalid username or password. '429': 'description': > Out of login attempts.
<mask> '200': <mask> 'description': 'OK.' <mask> '/logout': <mask> 'get': <mask> 'tags': <mask> - 'global' <mask> 'operationId': 'logout' <mask> 'summary': 'Perform administrator log-out' </s> Pull request: 2826 auth block Merge in DNS/adguard-home from 2826-auth-block to master Updates #2826. Squashed commit of the following: commit ae87360379270012869ad2bc4e528e07eb9af91e Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:35:49 2021 +0300 home: fix mistake commit dfa2ab05e9a8e70ac1bec36c4eb8ef3b02283b92 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:31:53 2021 +0300 home: imp code commit ff4220d3c3d92ae604e92a0c5c274d9527350d99 Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 15:14:20 2021 +0300 home: imp authratelimiter commit c73a407d8652d64957e35046dbae7168aa45202f Author: Eugene Burkov <e.burkov@adguard.com> Date: Tue Apr 27 14:20:17 2021 +0300 home: fix authratelimiter commit 724db4380928b055f9995006cf421cbe9c5363e7 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Apr 23 12:15:48 2021 +0300 home: introduce auth blocker </s> remove return &a </s> add return a </s> remove func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth { </s> add func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateLimiter) *Auth { </s> remove a := Auth{} a.sessionTTL = sessionTTL a.sessions = make(map[string]*session) </s> add a := &Auth{ sessionTTL: sessionTTL, blocker: blocker, sessions: make(map[string]*session), users: users, } </s> remove Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) </s> add var arl *authRateLimiter if config.AuthAttempts > 0 && config.AuthBlockMin > 0 { arl = newAuthRateLimiter( time.Duration(config.AuthBlockMin)*time.Minute, config.AuthAttempts, ) } else { log.Info("authratelimiter is disabled") } Context.auth = InitAuth( sessFilename, config.Users, config.WebSessionTTLHours*60*60, arl, )
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f603c21b557c37f4db7afefb3476127ca23d44a9
openapi/openapi.yaml
"bytes"
<mask> package main <mask> <mask> import ( <mask> "encoding/json" <mask> "fmt" <mask> "io/ioutil" <mask> "log" <mask> "net" </s> API /stats_top -- sort top entries by value </s> remove _, err = w.Write(json) </s> add _, err = w.Write(json.Bytes()) </s> remove toMarshal := map[string]interface{}{ "top_queried_domains": produceTop(domains, 50), "top_blocked_domains": produceTop(blocked, 50), "top_clients": produceTop(clients, 50), } json, err := json.Marshal(toMarshal) if err != nil { errortext := fmt.Sprintf("Couldn't marshal into JSON: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusBadGateway) return </s> add // use manual json marshalling because we want maps to be sorted by value json := bytes.Buffer{} json.WriteString("{\n") gen := func(json *bytes.Buffer, name string, top map[string]int, addComma bool) { json.WriteString(" \"") json.WriteString(name) json.WriteString("\": {\n") sorted := sortByValue(top) for i, key := range sorted { fmt.Fprintf(json, " \"%s\": %d", key, top[key])) if i+1 != len(sorted) { json.WriteByte(',') } json.WriteByte('\n') } json.WriteString(" }") if addComma { json.WriteByte(',') } json.WriteByte('\n')
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f623c3d9093d5a953336ee6a2e74507070a7def8
control.go
// use manual json marshalling because we want maps to be sorted by value json := bytes.Buffer{} json.WriteString("{\n") gen := func(json *bytes.Buffer, name string, top map[string]int, addComma bool) { json.WriteString(" \"") json.WriteString(name) json.WriteString("\": {\n") sorted := sortByValue(top) for i, key := range sorted { fmt.Fprintf(json, " \"%s\": %d", key, top[key])) if i+1 != len(sorted) { json.WriteByte(',') } json.WriteByte('\n') } json.WriteString(" }") if addComma { json.WriteByte(',') } json.WriteByte('\n')
<mask> clients[client]++ <mask> } <mask> } <mask> <mask> toMarshal := map[string]interface{}{ <mask> "top_queried_domains": produceTop(domains, 50), <mask> "top_blocked_domains": produceTop(blocked, 50), <mask> "top_clients": produceTop(clients, 50), <mask> } <mask> json, err := json.Marshal(toMarshal) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't marshal into JSON: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadGateway) <mask> return <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(json) <mask> if err != nil { </s> API /stats_top -- sort top entries by value </s> remove _, err = w.Write(json) </s> add _, err = w.Write(json.Bytes())
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f623c3d9093d5a953336ee6a2e74507070a7def8
control.go
gen(&json, "top_queried_domains", domains, true) gen(&json, "top_blocked_domains", blocked, true) gen(&json, "top_clients", clients, false) json.WriteString("}\n")
<mask> json.WriteByte('\n') <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(json.Bytes()) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't write body: %s", err) </s> API /stats_top -- sort top entries by value </s> remove _, err = w.Write(json) </s> add _, err = w.Write(json.Bytes()) </s> remove toMarshal := map[string]interface{}{ "top_queried_domains": produceTop(domains, 50), "top_blocked_domains": produceTop(blocked, 50), "top_clients": produceTop(clients, 50), } json, err := json.Marshal(toMarshal) if err != nil { errortext := fmt.Sprintf("Couldn't marshal into JSON: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusBadGateway) return </s> add // use manual json marshalling because we want maps to be sorted by value json := bytes.Buffer{} json.WriteString("{\n") gen := func(json *bytes.Buffer, name string, top map[string]int, addComma bool) { json.WriteString(" \"") json.WriteString(name) json.WriteString("\": {\n") sorted := sortByValue(top) for i, key := range sorted { fmt.Fprintf(json, " \"%s\": %d", key, top[key])) if i+1 != len(sorted) { json.WriteByte(',') } json.WriteByte('\n') } json.WriteString(" }") if addComma { json.WriteByte(',') } json.WriteByte('\n')
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f623c3d9093d5a953336ee6a2e74507070a7def8
control.go
_, err = w.Write(json.Bytes())
<mask> return <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(json) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't write body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> } </s> API /stats_top -- sort top entries by value </s> remove toMarshal := map[string]interface{}{ "top_queried_domains": produceTop(domains, 50), "top_blocked_domains": produceTop(blocked, 50), "top_clients": produceTop(clients, 50), } json, err := json.Marshal(toMarshal) if err != nil { errortext := fmt.Sprintf("Couldn't marshal into JSON: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusBadGateway) return </s> add // use manual json marshalling because we want maps to be sorted by value json := bytes.Buffer{} json.WriteString("{\n") gen := func(json *bytes.Buffer, name string, top map[string]int, addComma bool) { json.WriteString(" \"") json.WriteString(name) json.WriteString("\": {\n") sorted := sortByValue(top) for i, key := range sorted { fmt.Fprintf(json, " \"%s\": %d", key, top[key])) if i+1 != len(sorted) { json.WriteByte(',') } json.WriteByte('\n') } json.WriteString(" }") if addComma { json.WriteByte(',') } json.WriteByte('\n')
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f623c3d9093d5a953336ee6a2e74507070a7def8
control.go
<mask> func (s *Server) enableDHCP(ifaceName string) (code int, err error) { <mask> var hasStaticIP bool <mask> hasStaticIP, err = sysutil.IfaceHasStaticIP(ifaceName) <mask> if err != nil { <mask> // ErrPermission may happen here on Linux systems where AdGuard <mask> // Home is installed using Snap. That doesn't necessarily mean <mask> // that the machine doesn't have a static IP, so we can assume <mask> // that it has and go on. If the machine doesn't, we'll get an <mask> // error later. <mask> // <mask> // See https://github.com/AdguardTeam/AdGuardHome/issues/2667. <mask> if errors.Is(err, os.ErrPermission) { <mask> log.Info("error while checking static ip: %s; "+ <mask> "assuming machine has static ip and going on", err) <mask> hasStaticIP = true <mask> } else { </s> Pull request: all: fix statip ip ck Merge in DNS/adguard-home from fix-static-ip-check to master Squashed commit of the following: commit af365c106f3d620afc77492a06f5368611328f5f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Feb 15 18:55:35 2021 +0300 all: doc changes commit 922afb262458fc488e03cad232430d90c504f2f3 Merge: 43fec5fb dbcc55f5 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Feb 15 18:53:31 2021 +0300 Merge branch 'master' into fix-static-ip-check commit 43fec5fb79f5c67b375da00aa73d11b3ed9ba3a4 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Feb 15 18:37:16 2021 +0300 all: fix statip ip ck </s> remove return http.StatusInternalServerError, fmt.Errorf("checking static ip: %w", err) </s> add err = fmt.Errorf("checking static ip: %w", err) return http.StatusInternalServerError, err
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/f68f6c9b37cea1f33cb6fa791e6678b9df3a237b
internal/dhcpd/http.go