docstring_tokens
stringlengths 0
76.5k
| code_tokens
stringlengths 75
1.81M
| label_window
sequencelengths 4
2.12k
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|---|
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | <mask> golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
<mask> golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
<mask> golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
<mask> golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
<mask> golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
<mask> golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
<mask> golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
<mask> golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
<mask> golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
<mask> golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
<mask> golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
</s> Pull request 1729: upd-go
Merge in DNS/adguard-home from upd-go to master
Squashed commit of the following:
commit 0e13d6863a3d463289823a27414b427cb76be88c
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:20:14 2023 +0300
scripts: try increasing test timeout
commit 8e7d230e40de8f49a2b74a6d32a7fc78a361edab
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:00:17 2023 +0300
all: upd quic-go; imp atomic values
commit fae2b75b6990f2bd77e5c019a35a72322bac85f7
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 17:36:33 2023 +0300
all: upd go, deps; imp atomic values </s> remove golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
</s> add golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= </s> remove golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
</s> add golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= </s> remove golang.org/x/sys v0.4.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
</s> add golang.org/x/sys v0.5.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1 </s> remove golang.org/x/sys v0.4.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
</s> add golang.org/x/sys v0.5.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect </s> remove golang.org/x/exp v0.0.0-20230131160201-f062dba9d201
</s> add golang.org/x/exp v0.0.0-20230206171751-46f607a40771 | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f | internal/tools/go.sum |
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= | <mask> golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
<mask> golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
<mask> golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
<mask> golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
<mask> golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
<mask> golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
<mask> golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
<mask> golang.org/x/tools v0.0.0-20201007032633-0806396f153e/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
<mask> golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
<mask> golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
</s> Pull request 1729: upd-go
Merge in DNS/adguard-home from upd-go to master
Squashed commit of the following:
commit 0e13d6863a3d463289823a27414b427cb76be88c
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:20:14 2023 +0300
scripts: try increasing test timeout
commit 8e7d230e40de8f49a2b74a6d32a7fc78a361edab
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:00:17 2023 +0300
all: upd quic-go; imp atomic values
commit fae2b75b6990f2bd77e5c019a35a72322bac85f7
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 17:36:33 2023 +0300
all: upd go, deps; imp atomic values </s> remove golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
</s> add golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= </s> remove golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
</s> add golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= </s> remove golang.org/x/vuln v0.0.0-20230130175424-dd534eeddf33 h1:je2aB5nnlseeGvJy5clg6EyC3jjbbCNsRDroC3qQJsA=
golang.org/x/vuln v0.0.0-20230130175424-dd534eeddf33/go.mod h1:cBP4HMKv0X+x96j8IJWCKk0eqpakBmmHjKGSSC0NaYE=
</s> add golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1 h1:HRexnHfiDA2hkPNMDgf3vxabRMeC+XeS8tCKP9olVbs=
golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1/go.mod h1:cBP4HMKv0X+x96j8IJWCKk0eqpakBmmHjKGSSC0NaYE= </s> remove github.com/securego/gosec/v2 v2.14.0
</s> add github.com/securego/gosec/v2 v2.15.0 | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f | internal/tools/go.sum |
golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1 h1:HRexnHfiDA2hkPNMDgf3vxabRMeC+XeS8tCKP9olVbs=
golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1/go.mod h1:cBP4HMKv0X+x96j8IJWCKk0eqpakBmmHjKGSSC0NaYE= | <mask> golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
<mask> golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
<mask> golang.org/x/tools v0.5.1-0.20230117180257-8aba49bb5ea2 h1:v0FhRDmSCNH/0EurAT6T8KRY4aNuUhz6/WwBMxG+gvQ=
<mask> golang.org/x/tools v0.5.1-0.20230117180257-8aba49bb5ea2/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
<mask> golang.org/x/vuln v0.0.0-20230130175424-dd534eeddf33 h1:je2aB5nnlseeGvJy5clg6EyC3jjbbCNsRDroC3qQJsA=
<mask> golang.org/x/vuln v0.0.0-20230130175424-dd534eeddf33/go.mod h1:cBP4HMKv0X+x96j8IJWCKk0eqpakBmmHjKGSSC0NaYE=
<mask> golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
<mask> golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
<mask> golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
<mask> gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
<mask> gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
</s> Pull request 1729: upd-go
Merge in DNS/adguard-home from upd-go to master
Squashed commit of the following:
commit 0e13d6863a3d463289823a27414b427cb76be88c
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:20:14 2023 +0300
scripts: try increasing test timeout
commit 8e7d230e40de8f49a2b74a6d32a7fc78a361edab
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:00:17 2023 +0300
all: upd quic-go; imp atomic values
commit fae2b75b6990f2bd77e5c019a35a72322bac85f7
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 17:36:33 2023 +0300
all: upd go, deps; imp atomic values </s> remove gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
</s> add </s> remove golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
</s> add golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= </s> remove golang.org/x/vuln v0.0.0-20230130175424-dd534eeddf33
honnef.co/go/tools v0.3.3
</s> add golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1
honnef.co/go/tools v0.4.0 </s> remove github.com/securego/gosec/v2 v2.14.0
</s> add github.com/securego/gosec/v2 v2.15.0 </s> remove gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
</s> add gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f | internal/tools/go.sum |
<mask> golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
<mask> golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
<mask> gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
<mask> gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
<mask> gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
<mask> gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
<mask> gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
<mask> gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
<mask> gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
<mask> honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
<mask> honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw=
</s> Pull request 1729: upd-go
Merge in DNS/adguard-home from upd-go to master
Squashed commit of the following:
commit 0e13d6863a3d463289823a27414b427cb76be88c
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:20:14 2023 +0300
scripts: try increasing test timeout
commit 8e7d230e40de8f49a2b74a6d32a7fc78a361edab
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:00:17 2023 +0300
all: upd quic-go; imp atomic values
commit fae2b75b6990f2bd77e5c019a35a72322bac85f7
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 17:36:33 2023 +0300
all: upd go, deps; imp atomic values </s> remove honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw=
</s> add honnef.co/go/tools v0.4.0 h1:lyXVV1c8wUBJRKqI8JgIpT8TW1VDagfYYaxbKa/HoL8=
honnef.co/go/tools v0.4.0/go.mod h1:36ZgoUOrqOk1GxwHhyryEkq8FQWkUO2xGuSMhUCcdvA= </s> remove golang.org/x/vuln v0.0.0-20230130175424-dd534eeddf33 h1:je2aB5nnlseeGvJy5clg6EyC3jjbbCNsRDroC3qQJsA=
golang.org/x/vuln v0.0.0-20230130175424-dd534eeddf33/go.mod h1:cBP4HMKv0X+x96j8IJWCKk0eqpakBmmHjKGSSC0NaYE=
</s> add golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1 h1:HRexnHfiDA2hkPNMDgf3vxabRMeC+XeS8tCKP9olVbs=
golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1/go.mod h1:cBP4HMKv0X+x96j8IJWCKk0eqpakBmmHjKGSSC0NaYE= </s> remove gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
</s> add </s> remove gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
</s> add gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= </s> remove golang.org/x/sys v0.4.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
</s> add golang.org/x/sys v0.5.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f | internal/tools/go.sum |
|
honnef.co/go/tools v0.4.0 h1:lyXVV1c8wUBJRKqI8JgIpT8TW1VDagfYYaxbKa/HoL8=
honnef.co/go/tools v0.4.0/go.mod h1:36ZgoUOrqOk1GxwHhyryEkq8FQWkUO2xGuSMhUCcdvA= | <mask> gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
<mask> gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
<mask> gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
<mask> gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
<mask> honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
<mask> honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw=
<mask> mvdan.cc/gofumpt v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
<mask> mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ=
<mask> mvdan.cc/unparam v0.0.0-20230125043941-70a0ce6e7b95 h1:n/xhncJPSt0YzfOhnyn41XxUdrWQNgmLBG72FE27Fqw=
<mask> mvdan.cc/unparam v0.0.0-20230125043941-70a0ce6e7b95/go.mod h1:2vU506e8nGWodqcci641NLi4im2twWSq4Lod756epHQ=
</s> Pull request 1729: upd-go
Merge in DNS/adguard-home from upd-go to master
Squashed commit of the following:
commit 0e13d6863a3d463289823a27414b427cb76be88c
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:20:14 2023 +0300
scripts: try increasing test timeout
commit 8e7d230e40de8f49a2b74a6d32a7fc78a361edab
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 20:00:17 2023 +0300
all: upd quic-go; imp atomic values
commit fae2b75b6990f2bd77e5c019a35a72322bac85f7
Author: Ainar Garipov <[email protected]>
Date: Tue Feb 7 17:36:33 2023 +0300
all: upd go, deps; imp atomic values </s> remove gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
</s> add </s> remove gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
</s> add </s> remove golang.org/x/vuln v0.0.0-20230130175424-dd534eeddf33
honnef.co/go/tools v0.3.3
</s> add golang.org/x/vuln v0.0.0-20230201222900-4c848edceff1
honnef.co/go/tools v0.4.0 </s> remove github.com/securego/gosec/v2 v2.14.0
</s> add github.com/securego/gosec/v2 v2.15.0 </s> remove gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
</s> add gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/137d280032c8f2f0331f16b00cba83682369a43f | internal/tools/go.sum |
just added and you don't want to wait for automatic refresh to kick in. | <mask> - 'filtering'
<mask> 'operationId': 'filteringRefresh'
<mask> 'summary': >
<mask> Reload filtering rules from URLs. This might be needed if new URL was
<mask> just added and you dont want to wait for automatic refresh to kick in.
<mask> This API request is ratelimited, so you can call it freely as often as
<mask> you like, it wont create unnecessary burden on servers that host the
<mask> URL. This should work as intended, a `force` parameter is offered as
<mask> last-resort attempt to make filter lists fresh. If you ever find
<mask> yourself using `force` to make something work that otherwise wont, this
</s> Pull request: all: fix some typos
Merge in DNS/adguard-home from fix-docs to master
Squashed commit of the following:
commit 1a78c8fccabb90e97008cebe1f2cf5bd1dce9c24
Author: Ainar Garipov <[email protected]>
Date: Tue Aug 31 17:02:52 2021 +0300
all: fix some typos </s> remove # Add the "netrwork-observe" plug to be able to bind to ports below 1024
</s> add # Add the "network-observe" plug to be able to bind to ports below 1024 </s> remove # Add the "netrwork-bind" plug to bind to interfaces.
</s> add # Add the "network-bind" plug to bind to interfaces. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/138718e6eca965a98002a6afd5194de813db76c0 | openapi/openapi.yaml |
# Add the "network-bind" plug to bind to interfaces. | <mask> 'apps':
<mask> 'adguard-home':
<mask> 'command': 'AdGuardHome --no-check-update -w $SNAP_DATA'
<mask> 'plugs':
<mask> # Add the "netrwork-bind" plug to bind to interfaces.
<mask> - 'network-bind'
<mask> # Add the "netrwork-observe" plug to be able to bind to ports below 1024
<mask> # (cap_net_bind_service) and also to bind to a particular interface using
<mask> # SO_BINDTODEVICE (cap_net_raw).
<mask> - 'network-observe'
</s> Pull request: all: fix some typos
Merge in DNS/adguard-home from fix-docs to master
Squashed commit of the following:
commit 1a78c8fccabb90e97008cebe1f2cf5bd1dce9c24
Author: Ainar Garipov <[email protected]>
Date: Tue Aug 31 17:02:52 2021 +0300
all: fix some typos </s> remove # Add the "netrwork-observe" plug to be able to bind to ports below 1024
</s> add # Add the "network-observe" plug to be able to bind to ports below 1024 </s> remove just added and you dont want to wait for automatic refresh to kick in.
</s> add just added and you don't want to wait for automatic refresh to kick in. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/138718e6eca965a98002a6afd5194de813db76c0 | scripts/snap/snap.tmpl.yaml |
# Add the "network-observe" plug to be able to bind to ports below 1024 | <mask> 'command': 'AdGuardHome --no-check-update -w $SNAP_DATA'
<mask> 'plugs':
<mask> # Add the "netrwork-bind" plug to bind to interfaces.
<mask> - 'network-bind'
<mask> # Add the "netrwork-observe" plug to be able to bind to ports below 1024
<mask> # (cap_net_bind_service) and also to bind to a particular interface using
<mask> # SO_BINDTODEVICE (cap_net_raw).
<mask> - 'network-observe'
<mask> 'daemon': 'simple'
<mask> 'restart-condition': 'always'
</s> Pull request: all: fix some typos
Merge in DNS/adguard-home from fix-docs to master
Squashed commit of the following:
commit 1a78c8fccabb90e97008cebe1f2cf5bd1dce9c24
Author: Ainar Garipov <[email protected]>
Date: Tue Aug 31 17:02:52 2021 +0300
all: fix some typos </s> remove # Add the "netrwork-bind" plug to bind to interfaces.
</s> add # Add the "network-bind" plug to bind to interfaces. </s> remove just added and you dont want to wait for automatic refresh to kick in.
</s> add just added and you don't want to wait for automatic refresh to kick in. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/138718e6eca965a98002a6afd5194de813db76c0 | scripts/snap/snap.tmpl.yaml |
// Error is the constant error type.
type Error string
// Error implements the error interface for Error.
func (err Error) Error() (msg string) {
return string(err)
}
| <mask> "strings"
<mask> )
<mask>
<mask> // manyError is an error containing several wrapped errors. It is created to be
<mask> // a simpler version of the API provided by github.com/joomcode/errorx.
<mask> type manyError struct {
<mask> message string
<mask> underlying []error
<mask> }
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove // ErrSeekNotFound is returned from the Seek method
// if we failed to find the desired record
var ErrSeekNotFound = errors.New("Seek not found the record")
</s> add // ErrSeekNotFound is returned from Seek if when it fails to find the requested
// record.
const ErrSeekNotFound agherr.Error = "seek: record not found"
// ErrEndOfLog is returned from Seek when the end of the current log is reached.
const ErrEndOfLog agherr.Error = "seek: end of log" </s> remove if err == nil {
// Our search is finished, we found the element we were looking for
// Update currentFile only, position is already set properly in the QLogFile
</s> add if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. </s> remove return nil
</s> add return err | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/agherr/agherr.go |
<mask> package querylog
<mask>
<mask> import (
<mask> "errors"
<mask> "io"
<mask> "os"
<mask> "sync"
<mask> "time"
<mask>
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove if len(entries) == totalLimit {
// change the "oldest" value here.
// we cannot use the "oldest" we got from "searchFiles" anymore
// because after adding in-memory records and removing extra records
// the situation has changed
</s> add if len(entries) > 0 && len(entries) <= totalLimit {
// Update oldest after merging in the memory buffer. | [
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_file.go |
|
"github.com/AdguardTeam/AdGuardHome/internal/agherr" | <mask> "sync"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // ErrSeekNotFound is returned from Seek if when it fails to find the requested
<mask> // record.
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove // ErrSeekNotFound is returned from the Seek method
// if we failed to find the desired record
var ErrSeekNotFound = errors.New("Seek not found the record")
</s> add // ErrSeekNotFound is returned from Seek if when it fails to find the requested
// record.
const ErrSeekNotFound agherr.Error = "seek: record not found"
// ErrEndOfLog is returned from Seek when the end of the current log is reached.
const ErrEndOfLog agherr.Error = "seek: end of log" </s> remove "errors"
</s> add | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_file.go |
// ErrSeekNotFound is returned from Seek if when it fails to find the requested
// record.
const ErrSeekNotFound agherr.Error = "seek: record not found"
// ErrEndOfLog is returned from Seek when the end of the current log is reached.
const ErrEndOfLog agherr.Error = "seek: end of log" | <mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // ErrSeekNotFound is returned from the Seek method
<mask> // if we failed to find the desired record
<mask> var ErrSeekNotFound = errors.New("Seek not found the record")
<mask>
<mask> // TODO: Find a way to grow buffer instead of relying on this value when reading strings
<mask> const maxEntrySize = 16 * 1024
<mask>
<mask> // buffer should be enough for at least this number of entries
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove return nil
</s> add return err | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_file.go |
f, err := os.OpenFile(path, os.O_RDONLY, 0o644) | <mask> }
<mask>
<mask> // NewQLogFile initializes a new instance of the QLogFile
<mask> func NewQLogFile(path string) (*QLogFile, error) {
<mask> f, err := os.OpenFile(path, os.O_RDONLY, 0644)
<mask>
<mask> if err != nil {
<mask> return nil, err
<mask> }
<mask>
<mask> return &QLogFile{
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove return nil
</s> add return err </s> remove if err == nil {
// Our search is finished, we found the element we were looking for
// Update currentFile only, position is already set properly in the QLogFile
</s> add if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. </s> remove var startLine = int64(0)
</s> add startLine := int64(0) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_file.go |
} else if lineIdx == end && lineEndIdx == end {
return 0, depth, ErrEndOfLog | <mask> // the scope is too narrow and we won't find anything anymore
<mask> log.Error("querylog: didn't find timestamp:%v", timestamp)
<mask> return 0, depth, ErrSeekNotFound
<mask> }
<mask>
<mask> // Save the last found idx
<mask> lastProbeLineIdx = lineIdx
<mask>
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove // ErrSeekNotFound is returned from the Seek method
// if we failed to find the desired record
var ErrSeekNotFound = errors.New("Seek not found the record")
</s> add // ErrSeekNotFound is returned from Seek if when it fails to find the requested
// record.
const ErrSeekNotFound agherr.Error = "seek: record not found"
// ErrEndOfLog is returned from Seek when the end of the current log is reached.
const ErrEndOfLog agherr.Error = "seek: end of log" </s> remove return nil
</s> add return err </s> remove if err == nil {
// Our search is finished, we found the element we were looking for
// Update currentFile only, position is already set properly in the QLogFile
</s> add if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. </s> remove if len(entries) == totalLimit {
// change the "oldest" value here.
// we cannot use the "oldest" we got from "searchFiles" anymore
// because after adding in-memory records and removing extra records
// the situation has changed
</s> add if len(entries) > 0 && len(entries) <= totalLimit {
// Update oldest after merging in the memory buffer. | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_file.go |
startLine := int64(0) | <mask> }
<mask>
<mask> // Look for the end of the prev line
<mask> // This is where we'll read from
<mask> var startLine = int64(0)
<mask> for i := relativePos - 1; i >= 0; i-- {
<mask> if q.buffer[i] == '\n' {
<mask> startLine = i + 1
<mask> break
<mask> }
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove var startLine = int64(0)
</s> add startLine := int64(0) </s> remove var endLine = int64(bufferLen)
</s> add endLine := int64(bufferLen) </s> remove if err == nil {
// Our search is finished, we found the element we were looking for
// Update currentFile only, position is already set properly in the QLogFile
</s> add if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. </s> remove return nil
</s> add return err | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_file.go |
startLine := int64(0) | <mask> }
<mask>
<mask> // Now start looking for the new line character starting
<mask> // from the relativePos and going left
<mask> var startLine = int64(0)
<mask> for i := relativePos - 1; i >= 0; i-- {
<mask> if buffer[i] == '\n' {
<mask> startLine = i + 1
<mask> break
<mask> }
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove var startLine = int64(0)
</s> add startLine := int64(0) </s> remove var endLine = int64(bufferLen)
</s> add endLine := int64(bufferLen) </s> remove if err == nil {
// Our search is finished, we found the element we were looking for
// Update currentFile only, position is already set properly in the QLogFile
</s> add if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. </s> remove return nil
</s> add return err </s> remove if len(entries) == totalLimit {
// change the "oldest" value here.
// we cannot use the "oldest" we got from "searchFiles" anymore
// because after adding in-memory records and removing extra records
// the situation has changed
</s> add if len(entries) > 0 && len(entries) <= totalLimit {
// Update oldest after merging in the memory buffer. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_file.go |
endLine := int64(bufferLen) | <mask> break
<mask> }
<mask> }
<mask> // Looking for the end of line now
<mask> var endLine = int64(bufferLen)
<mask> lineEndIdx := endLine + seekPosition
<mask> for i := relativePos; i < int64(bufferLen); i++ {
<mask> if buffer[i] == '\n' {
<mask> endLine = i
<mask> lineEndIdx = endLine + seekPosition + 1
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove var startLine = int64(0)
</s> add startLine := int64(0) </s> remove var startLine = int64(0)
</s> add startLine := int64(0) </s> remove if err == nil {
// Our search is finished, we found the element we were looking for
// Update currentFile only, position is already set properly in the QLogFile
</s> add if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. </s> remove return nil
</s> add return err | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_file.go |
"errors" | <mask> package querylog
<mask>
<mask> import (
<mask> "io"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr"
<mask> )
<mask>
<mask> // QLogReader allows reading from multiple query log files in the reverse order.
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove "errors"
</s> add </s> remove // ErrSeekNotFound is returned from the Seek method
// if we failed to find the desired record
var ErrSeekNotFound = errors.New("Seek not found the record")
</s> add // ErrSeekNotFound is returned from Seek if when it fails to find the requested
// record.
const ErrSeekNotFound agherr.Error = "seek: record not found"
// ErrEndOfLog is returned from Seek when the end of the current log is reached.
const ErrEndOfLog agherr.Error = "seek: end of log" </s> remove if len(entries) == totalLimit {
// change the "oldest" value here.
// we cannot use the "oldest" we got from "searchFiles" anymore
// because after adding in-memory records and removing extra records
// the situation has changed
</s> add if len(entries) > 0 && len(entries) <= totalLimit {
// Update oldest after merging in the memory buffer. | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_reader.go |
if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. | <mask> func (r *QLogReader) Seek(timestamp int64) error {
<mask> for i := len(r.qFiles) - 1; i >= 0; i-- {
<mask> q := r.qFiles[i]
<mask> _, _, err := q.Seek(timestamp)
<mask> if err == nil {
<mask> // Our search is finished, we found the element we were looking for
<mask> // Update currentFile only, position is already set properly in the QLogFile
<mask> r.currentFile = i
<mask> return nil
<mask> }
<mask> }
<mask>
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove return nil
</s> add return err </s> remove var startLine = int64(0)
</s> add startLine := int64(0) </s> remove var startLine = int64(0)
</s> add startLine := int64(0) </s> remove f, err := os.OpenFile(path, os.O_RDONLY, 0644)
</s> add f, err := os.OpenFile(path, os.O_RDONLY, 0o644) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_reader.go |
return err | <mask> if err == nil {
<mask> // Our search is finished, we found the element we were looking for
<mask> // Update currentFile only, position is already set properly in the QLogFile
<mask> r.currentFile = i
<mask> return nil
<mask> }
<mask> }
<mask>
<mask> return ErrSeekNotFound
<mask> }
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove if err == nil {
// Our search is finished, we found the element we were looking for
// Update currentFile only, position is already set properly in the QLogFile
</s> add if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. </s> remove f, err := os.OpenFile(path, os.O_RDONLY, 0644)
</s> add f, err := os.OpenFile(path, os.O_RDONLY, 0o644) </s> remove if len(entries) == totalLimit {
// change the "oldest" value here.
// we cannot use the "oldest" we got from "searchFiles" anymore
// because after adding in-memory records and removing extra records
// the situation has changed
</s> add if len(entries) > 0 && len(entries) <= totalLimit {
// Update oldest after merging in the memory buffer. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/qlog_reader.go |
"errors" | <mask>
<mask> import (
<mask> "io"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/util"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove "errors"
</s> add </s> remove // ErrSeekNotFound is returned from the Seek method
// if we failed to find the desired record
var ErrSeekNotFound = errors.New("Seek not found the record")
</s> add // ErrSeekNotFound is returned from Seek if when it fails to find the requested
// record.
const ErrSeekNotFound agherr.Error = "seek: record not found"
// ErrEndOfLog is returned from Seek when the end of the current log is reached.
const ErrEndOfLog agherr.Error = "seek: end of log" | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/querylog_search.go |
if len(entries) > 0 && len(entries) <= totalLimit {
// Update oldest after merging in the memory buffer. | <mask> entries = make([]*logEntry, 0)
<mask> oldest = time.Time{}
<mask> }
<mask> }
<mask> if len(entries) == totalLimit {
<mask> // change the "oldest" value here.
<mask> // we cannot use the "oldest" we got from "searchFiles" anymore
<mask> // because after adding in-memory records and removing extra records
<mask> // the situation has changed
<mask> oldest = entries[len(entries)-1].Time
<mask> }
<mask>
<mask> log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s",
<mask> len(entries), total, params.olderThan, time.Since(now))
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove return nil
</s> add return err </s> remove if err == nil {
// Our search is finished, we found the element we were looking for
// Update currentFile only, position is already set properly in the QLogFile
</s> add if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. </s> remove var startLine = int64(0)
</s> add startLine := int64(0) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/querylog_search.go |
} else if errors.Is(err, ErrEndOfLog) {
// We've reached the end of the log.
return entries, time.Time{}, 0 | <mask> // The one that was specified in the "oldest" param is not needed,
<mask> // we need only the one next to it
<mask> _, err = r.ReadNext()
<mask> }
<mask> }
<mask>
<mask> if err != nil {
</s> Pull request: * querylog: fix end of log handling
Merge in DNS/adguard-home from 2229-query-log to master
Closes #2229.
Squashed commit of the following:
commit 32508a3f3b1e098869e1649a2774f1f17d14d41f
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 16:51:25 2020 +0300
* querylog: add test
commit 774159cc313a0284a8bb8327489671e5d7a3e4eb
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:26:26 2020 +0300
* querylog: better errors
commit 27b13a4dcaff9e8f9b08aec81c0c03f62ebd3fa5
Author: Ainar Garipov <[email protected]>
Date: Tue Nov 10 15:18:51 2020 +0300
* querylog: fix end of log handling </s> remove if err == nil {
// Our search is finished, we found the element we were looking for
// Update currentFile only, position is already set properly in the QLogFile
</s> add if err == nil || errors.Is(err, ErrEndOfLog) {
// Our search is finished, and we either found the
// element we were looking for or reached the end of the
// log. Update currentFile only, position is already
// set properly in QLogFile. </s> remove return nil
</s> add return err </s> remove f, err := os.OpenFile(path, os.O_RDONLY, 0644)
</s> add f, err := os.OpenFile(path, os.O_RDONLY, 0o644) </s> remove if len(entries) == totalLimit {
// change the "oldest" value here.
// we cannot use the "oldest" we got from "searchFiles" anymore
// because after adding in-memory records and removing extra records
// the situation has changed
</s> add if len(entries) > 0 && len(entries) <= totalLimit {
// Update oldest after merging in the memory buffer. </s> remove // ErrSeekNotFound is returned from the Seek method
// if we failed to find the desired record
var ErrSeekNotFound = errors.New("Seek not found the record")
</s> add // ErrSeekNotFound is returned from Seek if when it fails to find the requested
// record.
const ErrSeekNotFound agherr.Error = "seek: record not found"
// ErrEndOfLog is returned from Seek when the end of the current log is reached.
const ErrEndOfLog agherr.Error = "seek: end of log" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/13f708b483470b2002df1f2ceb35ef95ff400e86 | internal/querylog/querylog_search.go |
// rule or an empty string if the last doesn't exist. The returned rules are in
// a processed format like:
//
// ip host1 host2 ...
// | <mask> return rm.engine.MatchRequest(req)
<mask> }
<mask>
<mask> // Translate returns the source hosts-syntax rule for the generated dnsrewrite
<mask> // rule or an empty string if the last doesn't exist.
<mask> func (rm *requestMatcher) Translate(rule string) (hostRule string) {
<mask> rm.stateLock.RLock()
<mask> defer rm.stateLock.RUnlock()
<mask>
<mask> return rm.translator[rule]
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
</s> add func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { </s> remove // writeMainHostRule writes the actual rule for the qtype and the PTR for the
</s> add // writeMainRule writes the actual rule for the qtype and the PTR for the </s> remove // writeAliasHostRule writes the CNAME rule for the alias-host pair into
// internal builders.
func (hp *hostsParser) writeAliasHostRule(alias, host string) {
</s> add // writeAliasRule writes the CNAME rule for the alias-host pair into internal
// builders.
func (hp *hostsParser) writeAliasRule(alias, host string) { </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
log.Debug("%s: %s is expected to exist but doesn't", hostsContainerPref, p) | <mask> if !errors.Is(err, fs.ErrNotExist) {
<mask> return nil, fmt.Errorf("adding path: %w", err)
<mask> }
<mask>
<mask> log.Debug("%s: file %q expected to exist but doesn't", hostsContainerPref, p)
<mask> }
<mask> }
<mask>
<mask> go hc.handleEvents()
<mask>
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove log.Debug("%s: no updates detected", hostsContainerPref)
</s> add log.Debug("%s: no changes detected", hostsContainerPref) </s> remove hc.resetEng(rulesStrg, hp.translations)
</s> add hc.resetEng(rulesStrg, hp.translations()) </s> remove // Since the hostAlias couldn't be returned from add before the
// hostMain the mainHost shouldn't appear empty.
hp.writeAliasHostRule(host, mainHost)
</s> add hp.writeAliasRule(host, mainHost) </s> remove if tc.wantErr != nil {
assert.ErrorIs(t, err, tc.wantErr)
return
}
</s> add </s> remove // writeAliasHostRule writes the CNAME rule for the alias-host pair into
// internal builders.
func (hp *hostsParser) writeAliasHostRule(alias, host string) {
</s> add // writeAliasRule writes the CNAME rule for the alias-host pair into internal
// builders.
func (hp *hostsParser) writeAliasRule(alias, host string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// map's values are guaranteed to be of type of *aghnet.Hosts. | <mask> return nil
<mask> }
<mask>
<mask> // Upd returns the channel into which the updates are sent. The receivable
<mask> // map's values are guaranteed to be of type of *stringutil.Set.
<mask> func (hc *HostsContainer) Upd() (updates <-chan *netutil.IPMap) {
<mask> return hc.updates
<mask> }
<mask>
<mask> // pathsToPatterns converts paths into patterns compatible with fs.Glob.
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // handleEvents concurrently handles the events. It closes the update channel
// of HostsContainer when finishes. Used to be called within a goroutine.
</s> add // handleEvents concurrently handles the file system events. It closes the
// update channel of HostsContainer when finishes. It's used to be called
// within a separate goroutine. </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} </s> remove // rule or an empty string if the last doesn't exist.
</s> add // rule or an empty string if the last doesn't exist. The returned rules are in
// a processed format like:
//
// ip host1 host2 ...
// </s> remove func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
</s> add func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// handleEvents concurrently handles the file system events. It closes the
// update channel of HostsContainer when finishes. It's used to be called
// within a separate goroutine. | <mask>
<mask> return patterns, nil
<mask> }
<mask>
<mask> // handleEvents concurrently handles the events. It closes the update channel
<mask> // of HostsContainer when finishes. Used to be called within a goroutine.
<mask> func (hc *HostsContainer) handleEvents() {
<mask> defer log.OnPanic(fmt.Sprintf("%s: handling events", hostsContainerPref))
<mask>
<mask> defer close(hc.updates)
<mask>
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // map's values are guaranteed to be of type of *stringutil.Set.
</s> add // map's values are guaranteed to be of type of *aghnet.Hosts. </s> remove log.Debug("%s: no updates detected", hostsContainerPref)
</s> add log.Debug("%s: no changes detected", hostsContainerPref) </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} </s> remove // rule or an empty string if the last doesn't exist.
</s> add // rule or an empty string if the last doesn't exist. The returned rules are in
// a processed format like:
//
// ip host1 host2 ...
// | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// ipRules is the pair of generated A/AAAA and PTR rules with related IP.
type ipRules struct {
// rule is the A/AAAA $dnsrewrite rule.
rule string
// rulePtr is the PTR $dnsrewrite rule.
rulePtr string
// ip is the IP address related to the rules.
ip net.IP
}
| <mask> }
<mask>
<mask> // hostsParser is a helper type to parse rules from the operating system's hosts
<mask> // file. It exists for only a single refreshing session.
<mask> type hostsParser struct {
<mask> // rulesBuilder builds the resulting rules list content.
<mask> rulesBuilder *strings.Builder
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // rulesBuilder builds the resulting rulesBuilder list content.
</s> add // rulesBuilder builds the resulting rules list content. </s> remove // translations maps generated $dnsrewrite rules to the hosts-translations
// rules.
translations map[string]string
</s> add // rules stores the rules for main hosts to generate translations.
rules []ipRules </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} </s> remove hosts.Add(host)
return hostAlias
</s> add // This is a duplicate. Go on. | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// rulesBuilder builds the resulting rules list content. | <mask>
<mask> // hostsParser is a helper type to parse rules from the operating system's hosts
<mask> // file. It exists for only a single refreshing session.
<mask> type hostsParser struct {
<mask> // rulesBuilder builds the resulting rulesBuilder list content.
<mask> rulesBuilder *strings.Builder
<mask>
<mask> // translations maps generated $dnsrewrite rules to the hosts-translations
<mask> // rules.
<mask> translations map[string]string
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // translations maps generated $dnsrewrite rules to the hosts-translations
// rules.
translations map[string]string
</s> add // rules stores the rules for main hosts to generate translations.
rules []ipRules </s> remove // cnameSet prevents duplicating cname rules.
</s> add // cnameSet prevents duplicating cname rules, e.g. same hostname for
// different IP versions. </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// rules stores the rules for main hosts to generate translations.
rules []ipRules | <mask> type hostsParser struct {
<mask> // rulesBuilder builds the resulting rulesBuilder list content.
<mask> rulesBuilder *strings.Builder
<mask>
<mask> // translations maps generated $dnsrewrite rules to the hosts-translations
<mask> // rules.
<mask> translations map[string]string
<mask>
<mask> // cnameSet prevents duplicating cname rules.
<mask> cnameSet *stringutil.Set
<mask>
<mask> // table stores only the unique IP-hostname pairs. It's also sent to the
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // cnameSet prevents duplicating cname rules.
</s> add // cnameSet prevents duplicating cname rules, e.g. same hostname for
// different IP versions. </s> remove // rulesBuilder builds the resulting rulesBuilder list content.
</s> add // rulesBuilder builds the resulting rules list content. </s> remove // appropriate hosts set isn't equal to the checked one, i.e. the maps
// have at least one discrepancy.
ok = !hasIP || !v.(*stringutil.Set).Equal(val.(*stringutil.Set))
</s> add // appropriate hosts set isn't equal to the checked one, i.e. the main
// hosts differ or the maps have at least one discrepancy.
if a, hasIP := target.Get(ip); !hasIP {
ok = true
} else if hosts, aok := a.(*Hosts); aok {
ok = !hosts.Equal(b.(*Hosts))
} </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// cnameSet prevents duplicating cname rules, e.g. same hostname for
// different IP versions. | <mask> // translations maps generated $dnsrewrite rules to the hosts-translations
<mask> // rules.
<mask> translations map[string]string
<mask>
<mask> // cnameSet prevents duplicating cname rules.
<mask> cnameSet *stringutil.Set
<mask>
<mask> // table stores only the unique IP-hostname pairs. It's also sent to the
<mask> // updates channel afterwards.
<mask> table *netutil.IPMap
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // translations maps generated $dnsrewrite rules to the hosts-translations
// rules.
translations map[string]string
</s> add // rules stores the rules for main hosts to generate translations.
rules []ipRules </s> remove // rulesBuilder builds the resulting rulesBuilder list content.
</s> add // rulesBuilder builds the resulting rules list content. </s> remove // handleEvents concurrently handles the events. It closes the update channel
// of HostsContainer when finishes. Used to be called within a goroutine.
</s> add // handleEvents concurrently handles the file system events. It closes the
// update channel of HostsContainer when finishes. It's used to be called
// within a separate goroutine. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// newHostsParser creates a new *hostsParser with buffers of size taken from the
// previous parse. | <mask> // updates channel afterwards.
<mask> table *netutil.IPMap
<mask> }
<mask>
<mask> func (hc *HostsContainer) newHostsParser() (hp *hostsParser) {
<mask> lastLen := hc.last.Len()
<mask>
<mask> return &hostsParser{
<mask> rulesBuilder: &strings.Builder{},
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // For A/AAAA and PTRs.
translations: make(map[string]string, hc.last.Len()*2),
</s> add rules: make([]ipRules, 0, lastLen), </s> remove // cnameSet prevents duplicating cname rules.
</s> add // cnameSet prevents duplicating cname rules, e.g. same hostname for
// different IP versions. </s> remove // map's values are guaranteed to be of type of *stringutil.Set.
</s> add // map's values are guaranteed to be of type of *aghnet.Hosts. </s> remove // handleEvents concurrently handles the events. It closes the update channel
// of HostsContainer when finishes. Used to be called within a goroutine.
</s> add // handleEvents concurrently handles the file system events. It closes the
// update channel of HostsContainer when finishes. It's used to be called
// within a separate goroutine. | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
lastLen := hc.last.Len()
| <mask> // previous parse.
<mask> func (hc *HostsContainer) newHostsParser() (hp *hostsParser) {
<mask> return &hostsParser{
<mask> rulesBuilder: &strings.Builder{},
<mask> rules: make([]ipRules, 0, lastLen),
<mask> cnameSet: stringutil.NewSet(),
<mask> table: netutil.NewIPMap(lastLen),
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // For A/AAAA and PTRs.
translations: make(map[string]string, hc.last.Len()*2),
</s> add rules: make([]ipRules, 0, lastLen), </s> remove table: netutil.NewIPMap(hc.last.Len()),
</s> add table: netutil.NewIPMap(lastLen), </s> remove func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
</s> add func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { </s> remove // map's values are guaranteed to be of type of *stringutil.Set.
</s> add // map's values are guaranteed to be of type of *aghnet.Hosts. | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
rules: make([]ipRules, 0, lastLen), | <mask>
<mask> func (hc *HostsContainer) newHostsParser() (hp *hostsParser) {
<mask> return &hostsParser{
<mask> rulesBuilder: &strings.Builder{},
<mask> // For A/AAAA and PTRs.
<mask> translations: make(map[string]string, hc.last.Len()*2),
<mask> cnameSet: stringutil.NewSet(),
<mask> table: netutil.NewIPMap(hc.last.Len()),
<mask> }
<mask> }
<mask>
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove table: netutil.NewIPMap(hc.last.Len()),
</s> add table: netutil.NewIPMap(lastLen), </s> remove func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
</s> add func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
table: netutil.NewIPMap(lastLen), | <mask> rulesBuilder: &strings.Builder{},
<mask> // For A/AAAA and PTRs.
<mask> translations: make(map[string]string, hc.last.Len()*2),
<mask> cnameSet: stringutil.NewSet(),
<mask> table: netutil.NewIPMap(hc.last.Len()),
<mask> }
<mask> }
<mask>
<mask> // parseFile is a aghos.FileWalker for parsing the files with hosts syntax. It
<mask> // never signs to stop walking and never returns any additional patterns.
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // For A/AAAA and PTRs.
translations: make(map[string]string, hc.last.Len()*2),
</s> add rules: make([]ipRules, 0, lastLen), </s> remove func (hp *hostsParser) parseFile(
r io.Reader,
) (patterns []string, cont bool, err error) {
</s> add func (hp *hostsParser) parseFile(r io.Reader) (patterns []string, cont bool, err error) { </s> remove hosts.Add(host)
return hostAlias
</s> add // This is a duplicate. Go on. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
func (hp *hostsParser) parseFile(r io.Reader) (patterns []string, cont bool, err error) { | <mask> // parseFile is a aghos.FileWalker for parsing the files with hosts syntax. It
<mask> // never signs to stop walking and never returns any additional patterns.
<mask> //
<mask> // See man hosts(5).
<mask> func (hp *hostsParser) parseFile(
<mask> r io.Reader,
<mask> ) (patterns []string, cont bool, err error) {
<mask> s := bufio.NewScanner(r)
<mask> for s.Scan() {
<mask> ip, hosts := hp.parseLine(s.Text())
<mask> if ip == nil || len(hosts) == 0 {
<mask> continue
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove table: netutil.NewIPMap(hc.last.Len()),
</s> add table: netutil.NewIPMap(lastLen), </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { </s> remove switch hosts, _ := v.(*stringutil.Set); {
case ok && hosts.Has(host):
return 0
case hosts == nil:
hosts = stringutil.NewSet(host)
hp.table.Set(ip, hosts)
return hostMain
</s> add switch h, _ := v.(*Hosts); {
case !ok:
// This is the first host for the ip.
hp.table.Set(ip, &Hosts{Main: host})
return host
case h.Main == host:
// This is a duplicate. Go on.
case h.Aliases == nil:
// This is the first alias.
h.Aliases = stringutil.NewSet(host)
return h.Main
case !h.Aliases.Has(host):
// This is a new alias.
h.Aliases.Add(host)
return h.Main </s> remove func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
</s> add func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} | <mask>
<mask> return ip, hosts
<mask> }
<mask>
<mask> // Simple types of hosts in hosts database. Zero value isn't used to be able
<mask> // quizzaciously emulate nil with 0.
<mask> const (
<mask> _ = iota
<mask> hostAlias
<mask> hostMain
<mask> )
<mask>
<mask> // add tries to add the ip-host pair. It returns:
<mask> //
<mask> // hostAlias if the host is not the first one added for the ip.
<mask> // hostMain if the host is the first one added for the ip.
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // hostAlias if the host is not the first one added for the ip.
// hostMain if the host is the first one added for the ip.
// 0 if the ip-host pair has already been added.
</s> add // main host if the host is not the first one added for the ip.
// host itself if the host is the first one added for the ip.
// "" if the ip-host pair has already been added. </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { </s> remove hosts.Add(host)
return hostAlias
</s> add // This is a duplicate. Go on. </s> remove switch hosts, _ := v.(*stringutil.Set); {
case ok && hosts.Has(host):
return 0
case hosts == nil:
hosts = stringutil.NewSet(host)
hp.table.Set(ip, hosts)
return hostMain
</s> add switch h, _ := v.(*Hosts); {
case !ok:
// This is the first host for the ip.
hp.table.Set(ip, &Hosts{Main: host})
return host
case h.Main == host:
// This is a duplicate. Go on.
case h.Aliases == nil:
// This is the first alias.
h.Aliases = stringutil.NewSet(host)
return h.Main
case !h.Aliases.Has(host):
// This is a new alias.
h.Aliases.Add(host)
return h.Main </s> remove // Since the hostAlias couldn't be returned from add before the
// hostMain the mainHost shouldn't appear empty.
hp.writeAliasHostRule(host, mainHost)
</s> add hp.writeAliasRule(host, mainHost) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// main host if the host is not the first one added for the ip.
// host itself if the host is the first one added for the ip.
// "" if the ip-host pair has already been added. | <mask> )
<mask>
<mask> // add tries to add the ip-host pair. It returns:
<mask> //
<mask> // hostAlias if the host is not the first one added for the ip.
<mask> // hostMain if the host is the first one added for the ip.
<mask> // 0 if the ip-host pair has already been added.
<mask> //
<mask> func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
<mask> v, ok := hp.table.Get(ip)
<mask> switch hosts, _ := v.(*stringutil.Set); {
<mask> case ok && hosts.Has(host):
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { </s> remove switch hosts, _ := v.(*stringutil.Set); {
case ok && hosts.Has(host):
return 0
case hosts == nil:
hosts = stringutil.NewSet(host)
hp.table.Set(ip, hosts)
return hostMain
</s> add switch h, _ := v.(*Hosts); {
case !ok:
// This is the first host for the ip.
hp.table.Set(ip, &Hosts{Main: host})
return host
case h.Main == host:
// This is a duplicate. Go on.
case h.Aliases == nil:
// This is the first alias.
h.Aliases = stringutil.NewSet(host)
return h.Main
case !h.Aliases.Has(host):
// This is a new alias.
h.Aliases.Add(host)
return h.Main </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} </s> remove // Since the hostAlias couldn't be returned from add before the
// hostMain the mainHost shouldn't appear empty.
hp.writeAliasHostRule(host, mainHost)
</s> add hp.writeAliasRule(host, mainHost) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { | <mask> // hostAlias if the host is not the first one added for the ip.
<mask> // hostMain if the host is the first one added for the ip.
<mask> // 0 if the ip-host pair has already been added.
<mask> //
<mask> func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
<mask> v, ok := hp.table.Get(ip)
<mask> switch hosts, _ := v.(*stringutil.Set); {
<mask> case ok && hosts.Has(host):
<mask> return 0
<mask> case hosts == nil:
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // hostAlias if the host is not the first one added for the ip.
// hostMain if the host is the first one added for the ip.
// 0 if the ip-host pair has already been added.
</s> add // main host if the host is not the first one added for the ip.
// host itself if the host is the first one added for the ip.
// "" if the ip-host pair has already been added. </s> remove switch hosts, _ := v.(*stringutil.Set); {
case ok && hosts.Has(host):
return 0
case hosts == nil:
hosts = stringutil.NewSet(host)
hp.table.Set(ip, hosts)
return hostMain
</s> add switch h, _ := v.(*Hosts); {
case !ok:
// This is the first host for the ip.
hp.table.Set(ip, &Hosts{Main: host})
return host
case h.Main == host:
// This is a duplicate. Go on.
case h.Aliases == nil:
// This is the first alias.
h.Aliases = stringutil.NewSet(host)
return h.Main
case !h.Aliases.Has(host):
// This is a new alias.
h.Aliases.Add(host)
return h.Main </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} </s> remove // Put the rule in a processed format like:
//
// ip host1 host2 ...
//
hostsLine := strings.Join(append([]string{ip.String()}, hosts...), " ")
var mainHost string
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
switch h, _ := v.(*Hosts); {
case !ok:
// This is the first host for the ip.
hp.table.Set(ip, &Hosts{Main: host})
return host
case h.Main == host:
// This is a duplicate. Go on.
case h.Aliases == nil:
// This is the first alias.
h.Aliases = stringutil.NewSet(host)
return h.Main
case !h.Aliases.Has(host):
// This is a new alias.
h.Aliases.Add(host)
return h.Main | <mask> // 0 if the ip-host pair has already been added.
<mask> //
<mask> func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
<mask> v, ok := hp.table.Get(ip)
<mask> switch hosts, _ := v.(*stringutil.Set); {
<mask> case ok && hosts.Has(host):
<mask> return 0
<mask> case hosts == nil:
<mask> hosts = stringutil.NewSet(host)
<mask> hp.table.Set(ip, hosts)
<mask>
<mask> return hostMain
<mask> default:
<mask> hosts.Add(host)
<mask>
<mask> return hostAlias
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { </s> remove // hostAlias if the host is not the first one added for the ip.
// hostMain if the host is the first one added for the ip.
// 0 if the ip-host pair has already been added.
</s> add // main host if the host is not the first one added for the ip.
// host itself if the host is the first one added for the ip.
// "" if the ip-host pair has already been added. </s> remove hosts.Add(host)
return hostAlias
</s> add // This is a duplicate. Go on. </s> remove case hostMain:
mainHost = host
added, addedPtr := hp.writeMainHostRule(host, ip)
hp.translations[added], hp.translations[addedPtr] = hostsLine, hostsLine
case hostAlias:
</s> add case host:
// This host is main.
added, addedPtr := hp.writeMainRule(host, ip)
hp.rules = append(hp.rules, ipRules{
rule: added,
rulePtr: addedPtr,
ip: ip,
})
default:
// This host is an alias. </s> remove names, ok := v.(*stringutil.Set)
</s> add hosts, ok := v.(*aghnet.Hosts) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// This is a duplicate. Go on. | <mask> hp.table.Set(ip, hosts)
<mask>
<mask> return hostMain
<mask> default:
<mask> hosts.Add(host)
<mask>
<mask> return hostAlias
<mask> }
<mask> }
<mask>
<mask> // addPair puts the pair of ip and host to the rules builder if needed. For
<mask> // each ip the first member of hosts will become the main one.
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // Put the rule in a processed format like:
//
// ip host1 host2 ...
//
hostsLine := strings.Join(append([]string{ip.String()}, hosts...), " ")
var mainHost string
</s> add </s> remove switch hosts, _ := v.(*stringutil.Set); {
case ok && hosts.Has(host):
return 0
case hosts == nil:
hosts = stringutil.NewSet(host)
hp.table.Set(ip, hosts)
return hostMain
</s> add switch h, _ := v.(*Hosts); {
case !ok:
// This is the first host for the ip.
hp.table.Set(ip, &Hosts{Main: host})
return host
case h.Main == host:
// This is a duplicate. Go on.
case h.Aliases == nil:
// This is the first alias.
h.Aliases = stringutil.NewSet(host)
return h.Main
case !h.Aliases.Has(host):
// This is a new alias.
h.Aliases.Add(host)
return h.Main </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
return "" | <mask> default:
<mask> // This is a duplicate. Go on.
<mask> }
<mask> }
<mask>
<mask> // addPair puts the pair of ip and host to the rules builder if needed. For
<mask> // each ip the first member of hosts will become the main one.
<mask> func (hp *hostsParser) addPairs(ip net.IP, hosts []string) {
<mask> for _, host := range hosts {
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove hosts.Add(host)
return hostAlias
</s> add // This is a duplicate. Go on. </s> remove // Put the rule in a processed format like:
//
// ip host1 host2 ...
//
hostsLine := strings.Join(append([]string{ip.String()}, hosts...), " ")
var mainHost string
</s> add </s> remove switch hosts, _ := v.(*stringutil.Set); {
case ok && hosts.Has(host):
return 0
case hosts == nil:
hosts = stringutil.NewSet(host)
hp.table.Set(ip, hosts)
return hostMain
</s> add switch h, _ := v.(*Hosts); {
case !ok:
// This is the first host for the ip.
hp.table.Set(ip, &Hosts{Main: host})
return host
case h.Main == host:
// This is a duplicate. Go on.
case h.Aliases == nil:
// This is the first alias.
h.Aliases = stringutil.NewSet(host)
return h.Main
case !h.Aliases.Has(host):
// This is a new alias.
h.Aliases.Add(host)
return h.Main </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { </s> remove // hostAlias if the host is not the first one added for the ip.
// hostMain if the host is the first one added for the ip.
// 0 if the ip-host pair has already been added.
</s> add // main host if the host is not the first one added for the ip.
// host itself if the host is the first one added for the ip.
// "" if the ip-host pair has already been added. | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
<mask>
<mask> // addPair puts the pair of ip and host to the rules builder if needed. For
<mask> // each ip the first member of hosts will become the main one.
<mask> func (hp *hostsParser) addPairs(ip net.IP, hosts []string) {
<mask> // Put the rule in a processed format like:
<mask> //
<mask> // ip host1 host2 ...
<mask> //
<mask> hostsLine := strings.Join(append([]string{ip.String()}, hosts...), " ")
<mask> var mainHost string
<mask> for _, host := range hosts {
<mask> switch hp.add(ip, host) {
<mask> case 0:
<mask> continue
<mask> case hostMain:
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove switch hp.add(ip, host) {
case 0:
</s> add switch mainHost := hp.add(ip, host); mainHost {
case "":
// This host is a duplicate. </s> remove hosts.Add(host)
return hostAlias
</s> add // This is a duplicate. Go on. </s> remove case hostMain:
mainHost = host
added, addedPtr := hp.writeMainHostRule(host, ip)
hp.translations[added], hp.translations[addedPtr] = hostsLine, hostsLine
case hostAlias:
</s> add case host:
// This host is main.
added, addedPtr := hp.writeMainRule(host, ip)
hp.rules = append(hp.rules, ipRules{
rule: added,
rulePtr: addedPtr,
ip: ip,
})
default:
// This host is an alias. </s> remove // rule or an empty string if the last doesn't exist.
</s> add // rule or an empty string if the last doesn't exist. The returned rules are in
// a processed format like:
//
// ip host1 host2 ...
// | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
|
switch mainHost := hp.add(ip, host); mainHost {
case "":
// This host is a duplicate. | <mask> //
<mask> hostsLine := strings.Join(append([]string{ip.String()}, hosts...), " ")
<mask> var mainHost string
<mask> for _, host := range hosts {
<mask> switch hp.add(ip, host) {
<mask> case 0:
<mask> continue
<mask> case hostMain:
<mask> mainHost = host
<mask> added, addedPtr := hp.writeMainHostRule(host, ip)
<mask> hp.translations[added], hp.translations[addedPtr] = hostsLine, hostsLine
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove case hostMain:
mainHost = host
added, addedPtr := hp.writeMainHostRule(host, ip)
hp.translations[added], hp.translations[addedPtr] = hostsLine, hostsLine
case hostAlias:
</s> add case host:
// This host is main.
added, addedPtr := hp.writeMainRule(host, ip)
hp.rules = append(hp.rules, ipRules{
rule: added,
rulePtr: addedPtr,
ip: ip,
})
default:
// This host is an alias. </s> remove // Put the rule in a processed format like:
//
// ip host1 host2 ...
//
hostsLine := strings.Join(append([]string{ip.String()}, hosts...), " ")
var mainHost string
</s> add </s> remove switch hosts, _ := v.(*stringutil.Set); {
case ok && hosts.Has(host):
return 0
case hosts == nil:
hosts = stringutil.NewSet(host)
hp.table.Set(ip, hosts)
return hostMain
</s> add switch h, _ := v.(*Hosts); {
case !ok:
// This is the first host for the ip.
hp.table.Set(ip, &Hosts{Main: host})
return host
case h.Main == host:
// This is a duplicate. Go on.
case h.Aliases == nil:
// This is the first alias.
h.Aliases = stringutil.NewSet(host)
return h.Main
case !h.Aliases.Has(host):
// This is a new alias.
h.Aliases.Add(host)
return h.Main </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { </s> remove // Since the hostAlias couldn't be returned from add before the
// hostMain the mainHost shouldn't appear empty.
hp.writeAliasHostRule(host, mainHost)
</s> add hp.writeAliasRule(host, mainHost) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
case host:
// This host is main.
added, addedPtr := hp.writeMainRule(host, ip)
hp.rules = append(hp.rules, ipRules{
rule: added,
rulePtr: addedPtr,
ip: ip,
})
default:
// This host is an alias. | <mask> for _, host := range hosts {
<mask> switch hp.add(ip, host) {
<mask> case 0:
<mask> continue
<mask> case hostMain:
<mask> mainHost = host
<mask> added, addedPtr := hp.writeMainHostRule(host, ip)
<mask> hp.translations[added], hp.translations[addedPtr] = hostsLine, hostsLine
<mask> case hostAlias:
<mask> pair := fmt.Sprint(host, " ", mainHost)
<mask> if hp.cnameSet.Has(pair) {
<mask> continue
<mask> }
<mask> // Since the hostAlias couldn't be returned from add before the
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove switch hp.add(ip, host) {
case 0:
</s> add switch mainHost := hp.add(ip, host); mainHost {
case "":
// This host is a duplicate. </s> remove // Since the hostAlias couldn't be returned from add before the
// hostMain the mainHost shouldn't appear empty.
hp.writeAliasHostRule(host, mainHost)
</s> add hp.writeAliasRule(host, mainHost) </s> remove // Put the rule in a processed format like:
//
// ip host1 host2 ...
//
hostsLine := strings.Join(append([]string{ip.String()}, hosts...), " ")
var mainHost string
</s> add </s> remove switch hosts, _ := v.(*stringutil.Set); {
case ok && hosts.Has(host):
return 0
case hosts == nil:
hosts = stringutil.NewSet(host)
hp.table.Set(ip, hosts)
return hostMain
</s> add switch h, _ := v.(*Hosts); {
case !ok:
// This is the first host for the ip.
hp.table.Set(ip, &Hosts{Main: host})
return host
case h.Main == host:
// This is a duplicate. Go on.
case h.Aliases == nil:
// This is the first alias.
h.Aliases = stringutil.NewSet(host)
return h.Main
case !h.Aliases.Has(host):
// This is a new alias.
h.Aliases.Add(host)
return h.Main </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
hp.writeAliasRule(host, mainHost) | <mask> pair := fmt.Sprint(host, " ", mainHost)
<mask> if hp.cnameSet.Has(pair) {
<mask> continue
<mask> }
<mask> // Since the hostAlias couldn't be returned from add before the
<mask> // hostMain the mainHost shouldn't appear empty.
<mask> hp.writeAliasHostRule(host, mainHost)
<mask> hp.cnameSet.Add(pair)
<mask> }
<mask>
<mask> log.Debug("%s: added ip-host pair %q-%q", hostsContainerPref, ip, host)
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove case hostMain:
mainHost = host
added, addedPtr := hp.writeMainHostRule(host, ip)
hp.translations[added], hp.translations[addedPtr] = hostsLine, hostsLine
case hostAlias:
</s> add case host:
// This host is main.
added, addedPtr := hp.writeMainRule(host, ip)
hp.rules = append(hp.rules, ipRules{
rule: added,
rulePtr: addedPtr,
ip: ip,
})
default:
// This host is an alias. </s> remove // writeAliasHostRule writes the CNAME rule for the alias-host pair into
// internal builders.
func (hp *hostsParser) writeAliasHostRule(alias, host string) {
</s> add // writeAliasRule writes the CNAME rule for the alias-host pair into internal
// builders.
func (hp *hostsParser) writeAliasRule(alias, host string) { </s> remove // hostAlias if the host is not the first one added for the ip.
// hostMain if the host is the first one added for the ip.
// 0 if the ip-host pair has already been added.
</s> add // main host if the host is not the first one added for the ip.
// host itself if the host is the first one added for the ip.
// "" if the ip-host pair has already been added. </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// writeAliasRule writes the CNAME rule for the alias-host pair into internal
// builders.
func (hp *hostsParser) writeAliasRule(alias, host string) { | <mask> log.Debug("%s: added ip-host pair %q-%q", hostsContainerPref, ip, host)
<mask> }
<mask> }
<mask>
<mask> // writeAliasHostRule writes the CNAME rule for the alias-host pair into
<mask> // internal builders.
<mask> func (hp *hostsParser) writeAliasHostRule(alias, host string) {
<mask> const (
<mask> nl = "\n"
<mask> sc = ";"
<mask>
<mask> rwSuccess = rules.MaskSeparator + "$dnsrewrite=NOERROR" + sc + "CNAME" + sc
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // writeMainHostRule writes the actual rule for the qtype and the PTR for the
</s> add // writeMainRule writes the actual rule for the qtype and the PTR for the </s> remove func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
</s> add func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { </s> remove // Since the hostAlias couldn't be returned from add before the
// hostMain the mainHost shouldn't appear empty.
hp.writeAliasHostRule(host, mainHost)
</s> add hp.writeAliasRule(host, mainHost) </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { </s> remove // hostAlias if the host is not the first one added for the ip.
// hostMain if the host is the first one added for the ip.
// 0 if the ip-host pair has already been added.
</s> add // main host if the host is not the first one added for the ip.
// host itself if the host is the first one added for the ip.
// "" if the ip-host pair has already been added. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// writeMainRule writes the actual rule for the qtype and the PTR for the | <mask> hp.rulesBuilder.Grow(constLen + len(host) + len(alias))
<mask> stringutil.WriteToBuilder(hp.rulesBuilder, rules.MaskPipe, alias, rwSuccess, host, nl)
<mask> }
<mask>
<mask> // writeMainHostRule writes the actual rule for the qtype and the PTR for the
<mask> // host-ip pair into internal builders.
<mask> func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
<mask> arpa, err := netutil.IPToReversedAddr(ip)
<mask> if err != nil {
<mask> return
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
</s> add func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { </s> remove // writeAliasHostRule writes the CNAME rule for the alias-host pair into
// internal builders.
func (hp *hostsParser) writeAliasHostRule(alias, host string) {
</s> add // writeAliasRule writes the CNAME rule for the alias-host pair into internal
// builders.
func (hp *hostsParser) writeAliasRule(alias, host string) { </s> remove func (hp *hostsParser) parseFile(
r io.Reader,
) (patterns []string, cont bool, err error) {
</s> add func (hp *hostsParser) parseFile(r io.Reader) (patterns []string, cont bool, err error) { </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { | <mask> }
<mask>
<mask> // writeMainHostRule writes the actual rule for the qtype and the PTR for the
<mask> // host-ip pair into internal builders.
<mask> func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
<mask> arpa, err := netutil.IPToReversedAddr(ip)
<mask> if err != nil {
<mask> return
<mask> }
<mask>
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // writeMainHostRule writes the actual rule for the qtype and the PTR for the
</s> add // writeMainRule writes the actual rule for the qtype and the PTR for the </s> remove // writeAliasHostRule writes the CNAME rule for the alias-host pair into
// internal builders.
func (hp *hostsParser) writeAliasHostRule(alias, host string) {
</s> add // writeAliasRule writes the CNAME rule for the alias-host pair into internal
// builders.
func (hp *hostsParser) writeAliasRule(alias, host string) { </s> remove func (hp *hostsParser) parseFile(
r io.Reader,
) (patterns []string, cont bool, err error) {
</s> add func (hp *hostsParser) parseFile(r io.Reader) (patterns []string, cont bool, err error) { </s> remove hc.resetEng(rulesStrg, hp.translations)
</s> add hc.resetEng(rulesStrg, hp.translations()) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
hp.table.Range(func(ip net.IP, b interface{}) (cont bool) { | <mask> if hp.table.Len() != target.Len() {
<mask> return false
<mask> }
<mask>
<mask> hp.table.Range(func(ip net.IP, val interface{}) (cont bool) {
<mask> v, hasIP := target.Get(ip)
<mask> // ok is set to true if the target doesn't contain ip or if the
<mask> // appropriate hosts set isn't equal to the checked one, i.e. the maps
<mask> // have at least one discrepancy.
<mask> ok = !hasIP || !v.(*stringutil.Set).Equal(val.(*stringutil.Set))
<mask>
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove // appropriate hosts set isn't equal to the checked one, i.e. the maps
// have at least one discrepancy.
ok = !hasIP || !v.(*stringutil.Set).Equal(val.(*stringutil.Set))
</s> add // appropriate hosts set isn't equal to the checked one, i.e. the main
// hosts differ or the maps have at least one discrepancy.
if a, hasIP := target.Get(ip); !hasIP {
ok = true
} else if hosts, aok := a.(*Hosts); aok {
ok = !hosts.Equal(b.(*Hosts))
} </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} </s> remove names, ok := v.(*stringutil.Set)
</s> add hosts, ok := v.(*aghnet.Hosts) </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
// appropriate hosts set isn't equal to the checked one, i.e. the main
// hosts differ or the maps have at least one discrepancy.
if a, hasIP := target.Get(ip); !hasIP {
ok = true
} else if hosts, aok := a.(*Hosts); aok {
ok = !hosts.Equal(b.(*Hosts))
} | <mask>
<mask> hp.table.Range(func(ip net.IP, val interface{}) (cont bool) {
<mask> v, hasIP := target.Get(ip)
<mask> // ok is set to true if the target doesn't contain ip or if the
<mask> // appropriate hosts set isn't equal to the checked one, i.e. the maps
<mask> // have at least one discrepancy.
<mask> ok = !hasIP || !v.(*stringutil.Set).Equal(val.(*stringutil.Set))
<mask>
<mask> // Continue only if maps has no discrepancies.
<mask> return !ok
<mask> })
<mask>
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove hp.table.Range(func(ip net.IP, val interface{}) (cont bool) {
v, hasIP := target.Get(ip)
</s> add hp.table.Range(func(ip net.IP, b interface{}) (cont bool) { </s> remove names, ok := v.(*stringutil.Set)
</s> add hosts, ok := v.(*aghnet.Hosts) </s> remove // hostAlias if the host is not the first one added for the ip.
// hostMain if the host is the first one added for the ip.
// 0 if the ip-host pair has already been added.
</s> add // main host if the host is not the first one added for the ip.
// host itself if the host is the first one added for the ip.
// "" if the ip-host pair has already been added. </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
log.Debug("%s: no changes detected", hostsContainerPref) | <mask> return fmt.Errorf("refreshing : %w", err)
<mask> }
<mask>
<mask> if hp.equalSet(hc.last) {
<mask> log.Debug("%s: no updates detected", hostsContainerPref)
<mask>
<mask> return nil
<mask> }
<mask> defer hp.sendUpd(hc.updates)
<mask>
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove hc.resetEng(rulesStrg, hp.translations)
</s> add hc.resetEng(rulesStrg, hp.translations()) </s> remove log.Debug("%s: file %q expected to exist but doesn't", hostsContainerPref, p)
</s> add log.Debug("%s: %s is expected to exist but doesn't", hostsContainerPref, p) </s> remove if tc.wantErr != nil {
assert.ErrorIs(t, err, tc.wantErr)
return
}
</s> add </s> remove // map's values are guaranteed to be of type of *stringutil.Set.
</s> add // map's values are guaranteed to be of type of *aghnet.Hosts. </s> remove // handleEvents concurrently handles the events. It closes the update channel
// of HostsContainer when finishes. Used to be called within a goroutine.
</s> add // handleEvents concurrently handles the file system events. It closes the
// update channel of HostsContainer when finishes. It's used to be called
// within a separate goroutine. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
hc.resetEng(rulesStrg, hp.translations()) | <mask> if rulesStrg, err = hp.newStrg(hc.listID); err != nil {
<mask> return fmt.Errorf("initializing rules storage: %w", err)
<mask> }
<mask>
<mask> hc.resetEng(rulesStrg, hp.translations)
<mask>
<mask> return nil
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove if tc.wantErr != nil {
assert.ErrorIs(t, err, tc.wantErr)
return
}
</s> add </s> remove log.Debug("%s: no updates detected", hostsContainerPref)
</s> add log.Debug("%s: no changes detected", hostsContainerPref) </s> remove func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
</s> add func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { </s> remove // writeMainHostRule writes the actual rule for the qtype and the PTR for the
</s> add // writeMainRule writes the actual rule for the qtype and the PTR for the </s> remove log.Debug("%s: file %q expected to exist but doesn't", hostsContainerPref, p)
</s> add log.Debug("%s: %s is expected to exist but doesn't", hostsContainerPref, p) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer.go |
"time" | <mask> "strings"
<mask> "sync/atomic"
<mask> "testing"
<mask> "testing/fstest"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/stringutil"
<mask> "github.com/AdguardTeam/urlfilter"
<mask> "github.com/AdguardTeam/urlfilter/rules"
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove names.Range(func(name string) (cont bool) {
</s> add if clients.addHostLocked(ip, hosts.Main, ClientSourceHostsFile) {
n++
}
hosts.Aliases.Range(func(name string) (cont bool) { </s> remove func (hp *hostsParser) writeMainHostRule(host string, ip net.IP) (added, addedPtr string) {
</s> add func (hp *hostsParser) writeMainRule(host string, ip net.IP) (added, addedPtr string) { </s> remove // Put the rule in a processed format like:
//
// ip host1 host2 ...
//
hostsLine := strings.Join(append([]string{ip.String()}, hosts...), " ")
var mainHost string
</s> add </s> remove switch hp.add(ip, host) {
case 0:
</s> add switch mainHost := hp.add(ip, host); mainHost {
case "":
// This host is a duplicate. </s> remove case hostMain:
mainHost = host
added, addedPtr := hp.writeMainHostRule(host, ip)
hp.translations[added], hp.translations[addedPtr] = hostsLine, hostsLine
case hostAlias:
</s> add case host:
// This host is main.
added, addedPtr := hp.writeMainRule(host, ip)
hp.rules = append(hp.rules, ipRules{
rule: added,
rulePtr: addedPtr,
ip: ip,
})
default:
// This host is an alias. | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
func TestHostsContainer_refresh(t *testing.T) {
// TODO(e.burkov): Test the case with no actual updates. | <mask> assert.Nil(t, hc)
<mask> })
<mask> }
<mask>
<mask> func TestHostsContainer_Refresh(t *testing.T) {
<mask> knownIP := net.IP{127, 0, 0, 1}
<mask>
<mask> const knownHost = "localhost"
<mask> const knownAlias = "hocallost"
<mask>
<mask> const dirname = "dir"
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove const knownHost = "localhost"
const knownAlias = "hocallost"
</s> add ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() </s> remove const (
hostname = "localhost"
alias = "hocallost"
)
knownIP := net.IP{127, 0, 0, 1}
</s> add ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() </s> remove const dirname = "dir"
const filename1 = "file1"
const filename2 = "file2"
p1 := path.Join(dirname, filename1)
p2 := path.Join(dirname, filename2)
testFS := fstest.MapFS{
p1: &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownHost}, sp) + nl),
},
}
</s> add testFS := fstest.MapFS{"dir/file1": &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}} </s> remove const (
dir0 = "dir"
dir1 = "dir_1"
fn1 = "file_1"
fn2 = "file_2"
fn3 = "file_3"
fn4 = "file_4"
)
fp1 := path.Join(dir0, fn1)
fp2 := path.Join(dir0, fn2)
fp3 := path.Join(dir0, dir1, fn3)
</s> add </s> remove t.Run("no_changes_refresh", func(t *testing.T) {
assert.Empty(t, hc.Upd())
</s> add return !ok && res.DNSRewrites() == nil
}, 5*time.Second, time.Second/2)
// Make a change again.
testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
})
return !ok && res.DNSRewrites() != nil
}, 5*time.Second, time.Second/2)
assert.Len(t, hc.Upd(), 1) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() | <mask>
<mask> func TestHostsContainer_Refresh(t *testing.T) {
<mask> knownIP := net.IP{127, 0, 0, 1}
<mask>
<mask> const knownHost = "localhost"
<mask> const knownAlias = "hocallost"
<mask>
<mask> const dirname = "dir"
<mask> const filename1 = "file1"
<mask> const filename2 = "file2"
<mask>
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove func TestHostsContainer_Refresh(t *testing.T) {
knownIP := net.IP{127, 0, 0, 1}
</s> add func TestHostsContainer_refresh(t *testing.T) {
// TODO(e.burkov): Test the case with no actual updates. </s> remove const dirname = "dir"
const filename1 = "file1"
const filename2 = "file2"
p1 := path.Join(dirname, filename1)
p2 := path.Join(dirname, filename2)
testFS := fstest.MapFS{
p1: &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownHost}, sp) + nl),
},
}
</s> add testFS := fstest.MapFS{"dir/file1": &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}} </s> remove const (
hostname = "localhost"
alias = "hocallost"
)
knownIP := net.IP{127, 0, 0, 1}
</s> add ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() </s> remove const (
dir0 = "dir"
dir1 = "dir_1"
fn1 = "file_1"
fn2 = "file_2"
fn3 = "file_3"
fn4 = "file_4"
)
fp1 := path.Join(dir0, fn1)
fp2 := path.Join(dir0, fn2)
fp3 := path.Join(dir0, dir1, fn3)
</s> add </s> remove // writeAliasHostRule writes the CNAME rule for the alias-host pair into
// internal builders.
func (hp *hostsParser) writeAliasHostRule(alias, host string) {
</s> add // writeAliasRule writes the CNAME rule for the alias-host pair into internal
// builders.
func (hp *hostsParser) writeAliasRule(alias, host string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
testFS := fstest.MapFS{"dir/file1": &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}} | <mask>
<mask> const knownHost = "localhost"
<mask> const knownAlias = "hocallost"
<mask>
<mask> const dirname = "dir"
<mask> const filename1 = "file1"
<mask> const filename2 = "file2"
<mask>
<mask> p1 := path.Join(dirname, filename1)
<mask> p2 := path.Join(dirname, filename2)
<mask>
<mask> testFS := fstest.MapFS{
<mask> p1: &fstest.MapFile{
<mask> Data: []byte(strings.Join([]string{knownIP.String(), knownHost}, sp) + nl),
<mask> },
<mask> }
<mask>
<mask> // event is a convenient alias for an empty struct{} to emit test events.
<mask> type event = struct{}
<mask>
<mask> eventsCh := make(chan event, 1)
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove const knownHost = "localhost"
const knownAlias = "hocallost"
</s> add ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() </s> remove func TestHostsContainer_Refresh(t *testing.T) {
knownIP := net.IP{127, 0, 0, 1}
</s> add func TestHostsContainer_refresh(t *testing.T) {
// TODO(e.burkov): Test the case with no actual updates. </s> remove const (
hostname = "localhost"
alias = "hocallost"
)
knownIP := net.IP{127, 0, 0, 1}
</s> add ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() </s> remove const (
dir0 = "dir"
dir1 = "dir_1"
fn1 = "file_1"
fn2 = "file_2"
fn3 = "file_3"
fn4 = "file_4"
)
fp1 := path.Join(dir0, fn1)
fp2 := path.Join(dir0, fn2)
fp3 := path.Join(dir0, dir1, fn3)
</s> add </s> remove testFS[p2] = &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) + nl),
}
eventsCh <- event{}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
assert.Equal(t, "dir", name) | <mask>
<mask> w := &aghtest.FSWatcher{
<mask> OnEvents: func() (e <-chan event) { return eventsCh },
<mask> OnAdd: func(name string) (err error) {
<mask> assert.Equal(t, dirname, name)
<mask>
<mask> return nil
<mask> },
<mask> OnClose: func() (err error) { panic("not implemented") },
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove hc, err := NewHostsContainer(0, testFS, w, dirname)
</s> add hc, err := NewHostsContainer(0, testFS, w, "dir") </s> remove t.Run("no_changes_refresh", func(t *testing.T) {
assert.Empty(t, hc.Upd())
</s> add return !ok && res.DNSRewrites() == nil
}, 5*time.Second, time.Second/2)
// Make a change again.
testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
})
return !ok && res.DNSRewrites() != nil
}, 5*time.Second, time.Second/2)
assert.Len(t, hc.Upd(), 1) </s> remove eventsCh <- event{}
</s> add t.Run("double_refresh", func(t *testing.T) {
// Make a change once.
testFS["dir/file1"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
}) </s> remove func (hp *hostsParser) parseFile(
r io.Reader,
) (patterns []string, cont bool, err error) {
</s> add func (hp *hostsParser) parseFile(r io.Reader) (patterns []string, cont bool, err error) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
hc, err := NewHostsContainer(0, testFS, w, "dir") | <mask> },
<mask> OnClose: func() (err error) { panic("not implemented") },
<mask> }
<mask>
<mask> hc, err := NewHostsContainer(0, testFS, w, dirname)
<mask> require.NoError(t, err)
<mask>
<mask> checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) {
<mask> upd, ok := <-hc.Upd()
<mask> require.True(t, ok)
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) {
</s> add checkRefresh := func(t *testing.T, wantHosts Hosts) { </s> remove assert.Equal(t, dirname, name)
</s> add assert.Equal(t, "dir", name) </s> remove if tc.wantErr != nil {
assert.ErrorIs(t, err, tc.wantErr)
return
}
</s> add </s> remove v, ok := upd.Get(knownIP)
</s> add v, ok := upd.Get(ip) </s> remove var hosts *stringutil.Set
hosts, ok = v.(*stringutil.Set)
</s> add var hosts *Hosts
hosts, ok = v.(*Hosts) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
checkRefresh := func(t *testing.T, wantHosts Hosts) { | <mask>
<mask> hc, err := NewHostsContainer(0, testFS, w, dirname)
<mask> require.NoError(t, err)
<mask>
<mask> checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) {
<mask> upd, ok := <-hc.Upd()
<mask> require.True(t, ok)
<mask> require.NotNil(t, upd)
<mask>
<mask> assert.Equal(t, 1, upd.Len())
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove hc, err := NewHostsContainer(0, testFS, w, dirname)
</s> add hc, err := NewHostsContainer(0, testFS, w, "dir") </s> remove v, ok := upd.Get(knownIP)
</s> add v, ok := upd.Get(ip) </s> remove if tc.wantErr != nil {
assert.ErrorIs(t, err, tc.wantErr)
return
}
</s> add </s> remove var hosts *stringutil.Set
hosts, ok = v.(*stringutil.Set)
</s> add var hosts *Hosts
hosts, ok = v.(*Hosts) </s> remove assert.True(t, hosts.Equal(wantHosts))
</s> add assert.Equal(t, wantHosts.Main, hosts.Main)
assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
v, ok := upd.Get(ip) | <mask> require.NotNil(t, upd)
<mask>
<mask> assert.Equal(t, 1, upd.Len())
<mask>
<mask> v, ok := upd.Get(knownIP)
<mask> require.True(t, ok)
<mask>
<mask> var hosts *stringutil.Set
<mask> hosts, ok = v.(*stringutil.Set)
<mask> require.True(t, ok)
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove var hosts *stringutil.Set
hosts, ok = v.(*stringutil.Set)
</s> add var hosts *Hosts
hosts, ok = v.(*Hosts) </s> remove checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) {
</s> add checkRefresh := func(t *testing.T, wantHosts Hosts) { </s> remove assert.True(t, hosts.Equal(wantHosts))
</s> add assert.Equal(t, wantHosts.Main, hosts.Main)
assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases)) </s> remove hc, err := NewHostsContainer(0, testFS, w, dirname)
</s> add hc, err := NewHostsContainer(0, testFS, w, "dir") </s> remove names, ok := v.(*stringutil.Set)
</s> add hosts, ok := v.(*aghnet.Hosts) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
var hosts *Hosts
hosts, ok = v.(*Hosts) | <mask>
<mask> v, ok := upd.Get(knownIP)
<mask> require.True(t, ok)
<mask>
<mask> var hosts *stringutil.Set
<mask> hosts, ok = v.(*stringutil.Set)
<mask> require.True(t, ok)
<mask>
<mask> assert.True(t, hosts.Equal(wantHosts))
<mask> }
<mask>
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove v, ok := upd.Get(knownIP)
</s> add v, ok := upd.Get(ip) </s> remove assert.True(t, hosts.Equal(wantHosts))
</s> add assert.Equal(t, wantHosts.Main, hosts.Main)
assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases)) </s> remove hc, err := NewHostsContainer(0, testFS, w, dirname)
</s> add hc, err := NewHostsContainer(0, testFS, w, "dir") </s> remove checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) {
</s> add checkRefresh := func(t *testing.T, wantHosts Hosts) { </s> remove names, ok := v.(*stringutil.Set)
</s> add hosts, ok := v.(*aghnet.Hosts) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
assert.Equal(t, wantHosts.Main, hosts.Main)
assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases)) | <mask> var hosts *stringutil.Set
<mask> hosts, ok = v.(*stringutil.Set)
<mask> require.True(t, ok)
<mask>
<mask> assert.True(t, hosts.Equal(wantHosts))
<mask> }
<mask>
<mask> t.Run("initial_refresh", func(t *testing.T) {
<mask> checkRefresh(t, stringutil.NewSet(knownHost))
<mask> })
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove var hosts *stringutil.Set
hosts, ok = v.(*stringutil.Set)
</s> add var hosts *Hosts
hosts, ok = v.(*Hosts) </s> remove checkRefresh(t, stringutil.NewSet(knownHost))
</s> add checkRefresh(t, Hosts{Main: "hostname"}) </s> remove v, ok := upd.Get(knownIP)
</s> add v, ok := upd.Get(ip) </s> remove testFS[p2] = &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) + nl),
}
eventsCh <- event{}
</s> add </s> remove ip, hosts := hp.parseLine(tc.line)
assert.True(t, tc.wantIP.Equal(ip))
</s> add got, hosts := hp.parseLine(tc.line)
assert.True(t, tc.wantIP.Equal(got)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
checkRefresh(t, Hosts{Main: "hostname"}) | <mask> assert.True(t, hosts.Equal(wantHosts))
<mask> }
<mask>
<mask> t.Run("initial_refresh", func(t *testing.T) {
<mask> checkRefresh(t, stringutil.NewSet(knownHost))
<mask> })
<mask>
<mask> testFS[p2] = &fstest.MapFile{
<mask> Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) + nl),
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove testFS[p2] = &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) + nl),
}
eventsCh <- event{}
</s> add </s> remove assert.True(t, hosts.Equal(wantHosts))
</s> add assert.Equal(t, wantHosts.Main, hosts.Main)
assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases)) </s> remove const dirname = "dir"
const filename1 = "file1"
const filename2 = "file2"
p1 := path.Join(dirname, filename1)
p2 := path.Join(dirname, filename2)
testFS := fstest.MapFS{
p1: &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownHost}, sp) + nl),
},
}
</s> add testFS := fstest.MapFS{"dir/file1": &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}} </s> remove checkRefresh(t, stringutil.NewSet(knownHost, knownAlias))
</s> add testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
checkRefresh(t, Hosts{Main: "hostname", Aliases: stringutil.NewSet("alias")}) </s> remove eventsCh <- event{}
</s> add t.Run("double_refresh", func(t *testing.T) {
// Make a change once.
testFS["dir/file1"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
}) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
<mask> t.Run("initial_refresh", func(t *testing.T) {
<mask> checkRefresh(t, stringutil.NewSet(knownHost))
<mask> })
<mask>
<mask> testFS[p2] = &fstest.MapFile{
<mask> Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) + nl),
<mask> }
<mask> eventsCh <- event{}
<mask>
<mask> t.Run("second_refresh", func(t *testing.T) {
<mask> checkRefresh(t, stringutil.NewSet(knownHost, knownAlias))
<mask> })
<mask>
<mask> eventsCh <- event{}
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove checkRefresh(t, stringutil.NewSet(knownHost, knownAlias))
</s> add testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
checkRefresh(t, Hosts{Main: "hostname", Aliases: stringutil.NewSet("alias")}) </s> remove checkRefresh(t, stringutil.NewSet(knownHost))
</s> add checkRefresh(t, Hosts{Main: "hostname"}) </s> remove eventsCh <- event{}
</s> add t.Run("double_refresh", func(t *testing.T) {
// Make a change once.
testFS["dir/file1"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
}) </s> remove t.Run("no_changes_refresh", func(t *testing.T) {
assert.Empty(t, hc.Upd())
</s> add return !ok && res.DNSRewrites() == nil
}, 5*time.Second, time.Second/2)
// Make a change again.
testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
})
return !ok && res.DNSRewrites() != nil
}, 5*time.Second, time.Second/2)
assert.Len(t, hc.Upd(), 1) </s> remove assert.True(t, hosts.Equal(wantHosts))
</s> add assert.Equal(t, wantHosts.Main, hosts.Main)
assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
|
testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
checkRefresh(t, Hosts{Main: "hostname", Aliases: stringutil.NewSet("alias")}) | <mask> }
<mask> eventsCh <- event{}
<mask>
<mask> t.Run("second_refresh", func(t *testing.T) {
<mask> checkRefresh(t, stringutil.NewSet(knownHost, knownAlias))
<mask> })
<mask>
<mask> eventsCh <- event{}
<mask>
<mask> t.Run("no_changes_refresh", func(t *testing.T) {
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove testFS[p2] = &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) + nl),
}
eventsCh <- event{}
</s> add </s> remove eventsCh <- event{}
</s> add t.Run("double_refresh", func(t *testing.T) {
// Make a change once.
testFS["dir/file1"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
}) </s> remove t.Run("no_changes_refresh", func(t *testing.T) {
assert.Empty(t, hc.Upd())
</s> add return !ok && res.DNSRewrites() == nil
}, 5*time.Second, time.Second/2)
// Make a change again.
testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
})
return !ok && res.DNSRewrites() != nil
}, 5*time.Second, time.Second/2)
assert.Len(t, hc.Upd(), 1) </s> remove checkRefresh(t, stringutil.NewSet(knownHost))
</s> add checkRefresh(t, Hosts{Main: "hostname"}) </s> remove assert.True(t, hosts.Equal(wantHosts))
</s> add assert.Equal(t, wantHosts.Main, hosts.Main)
assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
t.Run("double_refresh", func(t *testing.T) {
// Make a change once.
testFS["dir/file1"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
}) | <mask> t.Run("second_refresh", func(t *testing.T) {
<mask> checkRefresh(t, stringutil.NewSet(knownHost, knownAlias))
<mask> })
<mask>
<mask> eventsCh <- event{}
<mask>
<mask> t.Run("no_changes_refresh", func(t *testing.T) {
<mask> assert.Empty(t, hc.Upd())
<mask> })
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove checkRefresh(t, stringutil.NewSet(knownHost, knownAlias))
</s> add testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
checkRefresh(t, Hosts{Main: "hostname", Aliases: stringutil.NewSet("alias")}) </s> remove testFS[p2] = &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) + nl),
}
eventsCh <- event{}
</s> add </s> remove t.Run("no_changes_refresh", func(t *testing.T) {
assert.Empty(t, hc.Upd())
</s> add return !ok && res.DNSRewrites() == nil
}, 5*time.Second, time.Second/2)
// Make a change again.
testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
})
return !ok && res.DNSRewrites() != nil
}, 5*time.Second, time.Second/2)
assert.Len(t, hc.Upd(), 1) </s> remove checkRefresh(t, stringutil.NewSet(knownHost))
</s> add checkRefresh(t, Hosts{Main: "hostname"}) </s> remove assert.True(t, hosts.Equal(wantHosts))
</s> add assert.Equal(t, wantHosts.Main, hosts.Main)
assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
return !ok && res.DNSRewrites() == nil
}, 5*time.Second, time.Second/2)
// Make a change again.
testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
})
return !ok && res.DNSRewrites() != nil
}, 5*time.Second, time.Second/2)
assert.Len(t, hc.Upd(), 1) | <mask> })
<mask>
<mask> eventsCh <- event{}
<mask>
<mask> t.Run("no_changes_refresh", func(t *testing.T) {
<mask> assert.Empty(t, hc.Upd())
<mask> })
<mask> }
<mask>
<mask> func TestHostsContainer_PathsToPatterns(t *testing.T) {
<mask> const (
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove eventsCh <- event{}
</s> add t.Run("double_refresh", func(t *testing.T) {
// Make a change once.
testFS["dir/file1"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
}) </s> remove checkRefresh(t, stringutil.NewSet(knownHost, knownAlias))
</s> add testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
checkRefresh(t, Hosts{Main: "hostname", Aliases: stringutil.NewSet("alias")}) </s> remove testFS[p2] = &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownAlias}, sp) + nl),
}
eventsCh <- event{}
</s> add </s> remove const (
dir0 = "dir"
dir1 = "dir_1"
fn1 = "file_1"
fn2 = "file_2"
fn3 = "file_3"
fn4 = "file_4"
)
fp1 := path.Join(dir0, fn1)
fp2 := path.Join(dir0, fn2)
fp3 := path.Join(dir0, dir1, fn3)
</s> add </s> remove func TestHostsContainer_Refresh(t *testing.T) {
knownIP := net.IP{127, 0, 0, 1}
</s> add func TestHostsContainer_refresh(t *testing.T) {
// TODO(e.burkov): Test the case with no actual updates. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
<mask> })
<mask> }
<mask>
<mask> func TestHostsContainer_PathsToPatterns(t *testing.T) {
<mask> const (
<mask> dir0 = "dir"
<mask> dir1 = "dir_1"
<mask> fn1 = "file_1"
<mask> fn2 = "file_2"
<mask> fn3 = "file_3"
<mask> fn4 = "file_4"
<mask> )
<mask>
<mask> fp1 := path.Join(dir0, fn1)
<mask> fp2 := path.Join(dir0, fn2)
<mask> fp3 := path.Join(dir0, dir1, fn3)
<mask>
<mask> gsfs := fstest.MapFS{
<mask> fp1: &fstest.MapFile{Data: []byte{1}},
<mask> fp2: &fstest.MapFile{Data: []byte{2}},
<mask> fp3: &fstest.MapFile{Data: []byte{3}},
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove fp1: &fstest.MapFile{Data: []byte{1}},
fp2: &fstest.MapFile{Data: []byte{2}},
fp3: &fstest.MapFile{Data: []byte{3}},
</s> add "dir_0/file_1": &fstest.MapFile{Data: []byte{1}},
"dir_0/file_2": &fstest.MapFile{Data: []byte{2}},
"dir_0/dir_1/file_3": &fstest.MapFile{Data: []byte{3}}, </s> remove const dirname = "dir"
const filename1 = "file1"
const filename2 = "file2"
p1 := path.Join(dirname, filename1)
p2 := path.Join(dirname, filename2)
testFS := fstest.MapFS{
p1: &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownHost}, sp) + nl),
},
}
</s> add testFS := fstest.MapFS{"dir/file1": &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}} </s> remove const (
hostname = "localhost"
alias = "hocallost"
)
knownIP := net.IP{127, 0, 0, 1}
</s> add ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() </s> remove func TestHostsContainer_Refresh(t *testing.T) {
knownIP := net.IP{127, 0, 0, 1}
</s> add func TestHostsContainer_refresh(t *testing.T) {
// TODO(e.burkov): Test the case with no actual updates. </s> remove const knownHost = "localhost"
const knownAlias = "hocallost"
</s> add ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
|
"dir_0/file_1": &fstest.MapFile{Data: []byte{1}},
"dir_0/file_2": &fstest.MapFile{Data: []byte{2}},
"dir_0/dir_1/file_3": &fstest.MapFile{Data: []byte{3}}, | <mask> fp2 := path.Join(dir0, fn2)
<mask> fp3 := path.Join(dir0, dir1, fn3)
<mask>
<mask> gsfs := fstest.MapFS{
<mask> fp1: &fstest.MapFile{Data: []byte{1}},
<mask> fp2: &fstest.MapFile{Data: []byte{2}},
<mask> fp3: &fstest.MapFile{Data: []byte{3}},
<mask> }
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> wantErr error
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove const (
dir0 = "dir"
dir1 = "dir_1"
fn1 = "file_1"
fn2 = "file_2"
fn3 = "file_3"
fn4 = "file_4"
)
fp1 := path.Join(dir0, fn1)
fp2 := path.Join(dir0, fn2)
fp3 := path.Join(dir0, dir1, fn3)
</s> add </s> remove name string
wantErr error
want []string
paths []string
</s> add name string
paths []string
want []string </s> remove const (
hostname = "localhost"
alias = "hocallost"
)
knownIP := net.IP{127, 0, 0, 1}
</s> add ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, </s> remove const dirname = "dir"
const filename1 = "file1"
const filename2 = "file2"
p1 := path.Join(dirname, filename1)
p2 := path.Join(dirname, filename2)
testFS := fstest.MapFS{
p1: &fstest.MapFile{
Data: []byte(strings.Join([]string{knownIP.String(), knownHost}, sp) + nl),
},
}
</s> add testFS := fstest.MapFS{"dir/file1": &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
name string
paths []string
want []string | <mask> fp3: &fstest.MapFile{Data: []byte{3}},
<mask> }
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> wantErr error
<mask> want []string
<mask> paths []string
<mask> }{{
<mask> name: "no_paths",
<mask> wantErr: nil,
<mask> want: nil,
<mask> paths: nil,
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove name: "no_paths",
wantErr: nil,
want: nil,
paths: nil,
</s> add name: "no_paths",
paths: nil,
want: nil, </s> remove fp1: &fstest.MapFile{Data: []byte{1}},
fp2: &fstest.MapFile{Data: []byte{2}},
fp3: &fstest.MapFile{Data: []byte{3}},
</s> add "dir_0/file_1": &fstest.MapFile{Data: []byte{1}},
"dir_0/file_2": &fstest.MapFile{Data: []byte{2}},
"dir_0/dir_1/file_3": &fstest.MapFile{Data: []byte{3}}, </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, </s> remove name: "single_file",
wantErr: nil,
want: []string{fp1},
paths: []string{fp1},
</s> add name: "single_file",
paths: []string{"dir_0/file_1"},
want: []string{"dir_0/file_1"}, </s> remove name: "file_and_dir",
wantErr: nil,
want: []string{fp1, path.Join(dir0, dir1, "*")},
paths: []string{fp1, path.Join(dir0, dir1)},
</s> add name: "file_and_dir",
paths: []string{"dir_0/file_1", "dir_0/dir_1"},
want: []string{"dir_0/file_1", "dir_0/dir_1/*"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
name: "no_paths",
paths: nil,
want: nil, | <mask> wantErr error
<mask> want []string
<mask> paths []string
<mask> }{{
<mask> name: "no_paths",
<mask> wantErr: nil,
<mask> want: nil,
<mask> paths: nil,
<mask> }, {
<mask> name: "single_file",
<mask> wantErr: nil,
<mask> want: []string{fp1},
<mask> paths: []string{fp1},
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove name string
wantErr error
want []string
paths []string
</s> add name string
paths []string
want []string </s> remove name: "single_file",
wantErr: nil,
want: []string{fp1},
paths: []string{fp1},
</s> add name: "single_file",
paths: []string{"dir_0/file_1"},
want: []string{"dir_0/file_1"}, </s> remove name: "several_files",
wantErr: nil,
want: []string{fp1, fp2},
paths: []string{fp1, fp2},
</s> add name: "several_files",
paths: []string{"dir_0/file_1", "dir_0/file_2"},
want: []string{"dir_0/file_1", "dir_0/file_2"}, </s> remove name: "file_and_dir",
wantErr: nil,
want: []string{fp1, path.Join(dir0, dir1, "*")},
paths: []string{fp1, path.Join(dir0, dir1)},
</s> add name: "file_and_dir",
paths: []string{"dir_0/file_1", "dir_0/dir_1"},
want: []string{"dir_0/file_1", "dir_0/dir_1/*"}, </s> remove name: "whole_dir",
wantErr: nil,
want: []string{path.Join(dir0, "*")},
paths: []string{dir0},
</s> add name: "whole_dir",
paths: []string{"dir_0"},
want: []string{"dir_0/*"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
name: "single_file",
paths: []string{"dir_0/file_1"},
want: []string{"dir_0/file_1"}, | <mask> wantErr: nil,
<mask> want: nil,
<mask> paths: nil,
<mask> }, {
<mask> name: "single_file",
<mask> wantErr: nil,
<mask> want: []string{fp1},
<mask> paths: []string{fp1},
<mask> }, {
<mask> name: "several_files",
<mask> wantErr: nil,
<mask> want: []string{fp1, fp2},
<mask> paths: []string{fp1, fp2},
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove name: "several_files",
wantErr: nil,
want: []string{fp1, fp2},
paths: []string{fp1, fp2},
</s> add name: "several_files",
paths: []string{"dir_0/file_1", "dir_0/file_2"},
want: []string{"dir_0/file_1", "dir_0/file_2"}, </s> remove name: "whole_dir",
wantErr: nil,
want: []string{path.Join(dir0, "*")},
paths: []string{dir0},
</s> add name: "whole_dir",
paths: []string{"dir_0"},
want: []string{"dir_0/*"}, </s> remove name: "no_paths",
wantErr: nil,
want: nil,
paths: nil,
</s> add name: "no_paths",
paths: nil,
want: nil, </s> remove name: "file_and_dir",
wantErr: nil,
want: []string{fp1, path.Join(dir0, dir1, "*")},
paths: []string{fp1, path.Join(dir0, dir1)},
</s> add name: "file_and_dir",
paths: []string{"dir_0/file_1", "dir_0/dir_1"},
want: []string{"dir_0/file_1", "dir_0/dir_1/*"}, </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
name: "several_files",
paths: []string{"dir_0/file_1", "dir_0/file_2"},
want: []string{"dir_0/file_1", "dir_0/file_2"}, | <mask> wantErr: nil,
<mask> want: []string{fp1},
<mask> paths: []string{fp1},
<mask> }, {
<mask> name: "several_files",
<mask> wantErr: nil,
<mask> want: []string{fp1, fp2},
<mask> paths: []string{fp1, fp2},
<mask> }, {
<mask> name: "whole_dir",
<mask> wantErr: nil,
<mask> want: []string{path.Join(dir0, "*")},
<mask> paths: []string{dir0},
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove name: "whole_dir",
wantErr: nil,
want: []string{path.Join(dir0, "*")},
paths: []string{dir0},
</s> add name: "whole_dir",
paths: []string{"dir_0"},
want: []string{"dir_0/*"}, </s> remove name: "single_file",
wantErr: nil,
want: []string{fp1},
paths: []string{fp1},
</s> add name: "single_file",
paths: []string{"dir_0/file_1"},
want: []string{"dir_0/file_1"}, </s> remove name: "file_and_dir",
wantErr: nil,
want: []string{fp1, path.Join(dir0, dir1, "*")},
paths: []string{fp1, path.Join(dir0, dir1)},
</s> add name: "file_and_dir",
paths: []string{"dir_0/file_1", "dir_0/dir_1"},
want: []string{"dir_0/file_1", "dir_0/dir_1/*"}, </s> remove name: "no_paths",
wantErr: nil,
want: nil,
paths: nil,
</s> add name: "no_paths",
paths: nil,
want: nil, </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
name: "whole_dir",
paths: []string{"dir_0"},
want: []string{"dir_0/*"}, | <mask> wantErr: nil,
<mask> want: []string{fp1, fp2},
<mask> paths: []string{fp1, fp2},
<mask> }, {
<mask> name: "whole_dir",
<mask> wantErr: nil,
<mask> want: []string{path.Join(dir0, "*")},
<mask> paths: []string{dir0},
<mask> }, {
<mask> name: "file_and_dir",
<mask> wantErr: nil,
<mask> want: []string{fp1, path.Join(dir0, dir1, "*")},
<mask> paths: []string{fp1, path.Join(dir0, dir1)},
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove name: "file_and_dir",
wantErr: nil,
want: []string{fp1, path.Join(dir0, dir1, "*")},
paths: []string{fp1, path.Join(dir0, dir1)},
</s> add name: "file_and_dir",
paths: []string{"dir_0/file_1", "dir_0/dir_1"},
want: []string{"dir_0/file_1", "dir_0/dir_1/*"}, </s> remove name: "several_files",
wantErr: nil,
want: []string{fp1, fp2},
paths: []string{fp1, fp2},
</s> add name: "several_files",
paths: []string{"dir_0/file_1", "dir_0/file_2"},
want: []string{"dir_0/file_1", "dir_0/file_2"}, </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, </s> remove name: "single_file",
wantErr: nil,
want: []string{fp1},
paths: []string{fp1},
</s> add name: "single_file",
paths: []string{"dir_0/file_1"},
want: []string{"dir_0/file_1"}, </s> remove name: "no_paths",
wantErr: nil,
want: nil,
paths: nil,
</s> add name: "no_paths",
paths: nil,
want: nil, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
name: "file_and_dir",
paths: []string{"dir_0/file_1", "dir_0/dir_1"},
want: []string{"dir_0/file_1", "dir_0/dir_1/*"}, | <mask> wantErr: nil,
<mask> want: []string{path.Join(dir0, "*")},
<mask> paths: []string{dir0},
<mask> }, {
<mask> name: "file_and_dir",
<mask> wantErr: nil,
<mask> want: []string{fp1, path.Join(dir0, dir1, "*")},
<mask> paths: []string{fp1, path.Join(dir0, dir1)},
<mask> }, {
<mask> name: "non-existing",
<mask> wantErr: nil,
<mask> want: nil,
<mask> paths: []string{path.Join(dir0, "file_3")},
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove name: "whole_dir",
wantErr: nil,
want: []string{path.Join(dir0, "*")},
paths: []string{dir0},
</s> add name: "whole_dir",
paths: []string{"dir_0"},
want: []string{"dir_0/*"}, </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, </s> remove name: "several_files",
wantErr: nil,
want: []string{fp1, fp2},
paths: []string{fp1, fp2},
</s> add name: "several_files",
paths: []string{"dir_0/file_1", "dir_0/file_2"},
want: []string{"dir_0/file_1", "dir_0/file_2"}, </s> remove name: "single_file",
wantErr: nil,
want: []string{fp1},
paths: []string{fp1},
</s> add name: "single_file",
paths: []string{"dir_0/file_1"},
want: []string{"dir_0/file_1"}, </s> remove name: "no_paths",
wantErr: nil,
want: nil,
paths: nil,
</s> add name: "no_paths",
paths: nil,
want: nil, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, | <mask> wantErr: nil,
<mask> want: []string{fp1, path.Join(dir0, dir1, "*")},
<mask> paths: []string{fp1, path.Join(dir0, dir1)},
<mask> }, {
<mask> name: "non-existing",
<mask> wantErr: nil,
<mask> want: nil,
<mask> paths: []string{path.Join(dir0, "file_3")},
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> patterns, err := pathsToPatterns(gsfs, tc.paths)
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove name: "file_and_dir",
wantErr: nil,
want: []string{fp1, path.Join(dir0, dir1, "*")},
paths: []string{fp1, path.Join(dir0, dir1)},
</s> add name: "file_and_dir",
paths: []string{"dir_0/file_1", "dir_0/dir_1"},
want: []string{"dir_0/file_1", "dir_0/dir_1/*"}, </s> remove name: "whole_dir",
wantErr: nil,
want: []string{path.Join(dir0, "*")},
paths: []string{dir0},
</s> add name: "whole_dir",
paths: []string{"dir_0"},
want: []string{"dir_0/*"}, </s> remove name: "several_files",
wantErr: nil,
want: []string{fp1, fp2},
paths: []string{fp1, fp2},
</s> add name: "several_files",
paths: []string{"dir_0/file_1", "dir_0/file_2"},
want: []string{"dir_0/file_1", "dir_0/file_2"}, </s> remove name: "single_file",
wantErr: nil,
want: []string{fp1},
paths: []string{fp1},
</s> add name: "single_file",
paths: []string{"dir_0/file_1"},
want: []string{"dir_0/file_1"}, </s> remove if tc.wantErr != nil {
assert.ErrorIs(t, err, tc.wantErr)
return
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
<mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> patterns, err := pathsToPatterns(gsfs, tc.paths)
<mask> if tc.wantErr != nil {
<mask> assert.ErrorIs(t, err, tc.wantErr)
<mask>
<mask> return
<mask> }
<mask>
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, tc.want, patterns)
<mask> })
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, </s> remove ip, hosts := hp.parseLine(tc.line)
assert.True(t, tc.wantIP.Equal(ip))
</s> add got, hosts := hp.parseLine(tc.line)
assert.True(t, tc.wantIP.Equal(got)) </s> remove hc.resetEng(rulesStrg, hp.translations)
</s> add hc.resetEng(rulesStrg, hp.translations()) </s> remove checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) {
</s> add checkRefresh := func(t *testing.T, wantHosts Hosts) { </s> remove hc, err := NewHostsContainer(0, testFS, w, dirname)
</s> add hc, err := NewHostsContainer(0, testFS, w, "dir") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
|
<mask>
<mask> testdata := os.DirFS("./testdata")
<mask>
<mask> nRewrites := func(t *testing.T, res *urlfilter.DNSResult, n int) (rws []*rules.DNSRewrite) {
<mask> t.Helper()
<mask>
<mask> rewrites := res.DNSRewrites()
<mask> assert.Len(t, rewrites, n)
<mask>
<mask> for _, rewrite := range rewrites {
<mask> require.Equal(t, listID, rewrite.FilterListID)
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove assert.Len(t, rewrites, n)
</s> add require.Len(t, rewrites, n) </s> remove ip, hosts := hp.parseLine(tc.line)
assert.True(t, tc.wantIP.Equal(ip))
</s> add got, hosts := hp.parseLine(tc.line)
assert.True(t, tc.wantIP.Equal(got)) </s> remove checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) {
</s> add checkRefresh := func(t *testing.T, wantHosts Hosts) { </s> remove if tc.wantErr != nil {
assert.ErrorIs(t, err, tc.wantErr)
return
}
</s> add </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
|
require.Len(t, rewrites, n) | <mask> nRewrites := func(t *testing.T, res *urlfilter.DNSResult, n int) (rws []*rules.DNSRewrite) {
<mask> t.Helper()
<mask>
<mask> rewrites := res.DNSRewrites()
<mask> assert.Len(t, rewrites, n)
<mask>
<mask> for _, rewrite := range rewrites {
<mask> require.Equal(t, listID, rewrite.FilterListID)
<mask>
<mask> rw := rewrite.DNSRewrite
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove t.Helper()
</s> add </s> remove ip, hosts := hp.parseLine(tc.line)
assert.True(t, tc.wantIP.Equal(ip))
</s> add got, hosts := hp.parseLine(tc.line)
assert.True(t, tc.wantIP.Equal(got)) </s> remove checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) {
</s> add checkRefresh := func(t *testing.T, wantHosts Hosts) { </s> remove if tc.wantErr != nil {
assert.ErrorIs(t, err, tc.wantErr)
return
}
</s> add </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
}, {
name: "other_line_alias",
req: urlfilter.DNSRequest{
Hostname: "hello.world.again",
DNSType: dns.TypeA,
},
testTail: func(t *testing.T, res *urlfilter.DNSResult) {
assert.Equal(t, "hello", nRewrites(t, res, 1)[0].NewCNAME)
}, | <mask> testTail: func(t *testing.T, res *urlfilter.DNSResult) {
<mask> assert.Equal(t, "hello", nRewrites(t, res, 1)[0].NewCNAME)
<mask> },
<mask> }, {
<mask> name: "hello_subdomain",
<mask> req: urlfilter.DNSRequest{
<mask> Hostname: "say.hello",
<mask> DNSType: dns.TypeA,
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove eventsCh <- event{}
</s> add t.Run("double_refresh", func(t *testing.T) {
// Make a change once.
testFS["dir/file1"] = &fstest.MapFile{Data: []byte(ipStr + ` alias` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
}) </s> remove t.Run("no_changes_refresh", func(t *testing.T) {
assert.Empty(t, hc.Upd())
</s> add return !ok && res.DNSRewrites() == nil
}, 5*time.Second, time.Second/2)
// Make a change again.
testFS["dir/file2"] = &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}
eventsCh <- event{}
// Require the changes are written.
require.Eventually(t, func() bool {
res, ok := hc.MatchRequest(urlfilter.DNSRequest{
Hostname: "hostname",
DNSType: dns.TypeA,
})
return !ok && res.DNSRewrites() != nil
}, 5*time.Second, time.Second/2)
assert.Len(t, hc.Upd(), 1) </s> remove checkRefresh := func(t *testing.T, wantHosts *stringutil.Set) {
</s> add checkRefresh := func(t *testing.T, wantHosts Hosts) { </s> remove t.Helper()
</s> add </s> remove assert.Len(t, rewrites, n)
</s> add require.Len(t, rewrites, n) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() | <mask> }
<mask> }
<mask>
<mask> func TestUniqueRules_ParseLine(t *testing.T) {
<mask> const (
<mask> hostname = "localhost"
<mask> alias = "hocallost"
<mask> )
<mask>
<mask> knownIP := net.IP{127, 0, 0, 1}
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> line string
<mask> wantIP net.IP
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove const knownHost = "localhost"
const knownAlias = "hocallost"
</s> add ip := net.IP{127, 0, 0, 1}
ipStr := ip.String() </s> remove func TestHostsContainer_Refresh(t *testing.T) {
knownIP := net.IP{127, 0, 0, 1}
</s> add func TestHostsContainer_refresh(t *testing.T) {
// TODO(e.burkov): Test the case with no actual updates. </s> remove name string
wantErr error
want []string
paths []string
</s> add name string
paths []string
want []string </s> remove fp1: &fstest.MapFile{Data: []byte{1}},
fp2: &fstest.MapFile{Data: []byte{2}},
fp3: &fstest.MapFile{Data: []byte{3}},
</s> add "dir_0/file_1": &fstest.MapFile{Data: []byte{1}},
"dir_0/file_2": &fstest.MapFile{Data: []byte{2}},
"dir_0/dir_1/file_3": &fstest.MapFile{Data: []byte{3}}, </s> remove const (
dir0 = "dir"
dir1 = "dir_1"
fn1 = "file_1"
fn2 = "file_2"
fn3 = "file_3"
fn4 = "file_4"
)
fp1 := path.Join(dir0, fn1)
fp2 := path.Join(dir0, fn2)
fp3 := path.Join(dir0, dir1, fn3)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
line: ipStr + ` hostname`,
wantIP: ip,
wantHosts: []string{"hostname"}, | <mask> wantIP net.IP
<mask> wantHosts []string
<mask> }{{
<mask> name: "simple",
<mask> line: strings.Join([]string{knownIP.String(), hostname}, sp),
<mask> wantIP: knownIP,
<mask> wantHosts: []string{"localhost"},
<mask> }, {
<mask> name: "aliases",
<mask> line: strings.Join([]string{knownIP.String(), hostname, alias}, sp),
<mask> wantIP: knownIP,
<mask> wantHosts: []string{"localhost", "hocallost"},
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove line: strings.Join([]string{knownIP.String(), hostname, alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost", "hocallost"},
</s> add line: ipStr + ` hostname alias`,
wantIP: ip,
wantHosts: []string{"hostname", "alias"}, </s> remove line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname # alias`,
wantIP: ip,
wantHosts: []string{"hostname"}, </s> remove line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp),
wantIP: knownIP,
</s> add line: ipStr + ` # hostname`,
wantIP: ip, </s> remove line: knownIP.String(),
</s> add line: ipStr, </s> remove line: strings.Join([]string{"#", knownIP.String(), hostname}, sp),
</s> add line: `# ` + ipStr + ` hostname`, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
line: ipStr + ` hostname alias`,
wantIP: ip,
wantHosts: []string{"hostname", "alias"}, | <mask> wantIP: knownIP,
<mask> wantHosts: []string{"localhost"},
<mask> }, {
<mask> name: "aliases",
<mask> line: strings.Join([]string{knownIP.String(), hostname, alias}, sp),
<mask> wantIP: knownIP,
<mask> wantHosts: []string{"localhost", "hocallost"},
<mask> }, {
<mask> name: "invalid_line",
<mask> line: knownIP.String(),
<mask> wantIP: nil,
<mask> wantHosts: nil,
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove line: strings.Join([]string{knownIP.String(), hostname}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname`,
wantIP: ip,
wantHosts: []string{"hostname"}, </s> remove line: knownIP.String(),
</s> add line: ipStr, </s> remove line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname # alias`,
wantIP: ip,
wantHosts: []string{"hostname"}, </s> remove line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp),
wantIP: knownIP,
</s> add line: ipStr + ` # hostname`,
wantIP: ip, </s> remove line: strings.Join([]string{"#", knownIP.String(), hostname}, sp),
</s> add line: `# ` + ipStr + ` hostname`, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
line: ipStr, | <mask> wantIP: knownIP,
<mask> wantHosts: []string{"localhost", "hocallost"},
<mask> }, {
<mask> name: "invalid_line",
<mask> line: knownIP.String(),
<mask> wantIP: nil,
<mask> wantHosts: nil,
<mask> }, {
<mask> name: "invalid_line_hostname",
<mask> line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp),
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove line: strings.Join([]string{knownIP.String(), hostname, alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost", "hocallost"},
</s> add line: ipStr + ` hostname alias`,
wantIP: ip,
wantHosts: []string{"hostname", "alias"}, </s> remove line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp),
wantIP: knownIP,
</s> add line: ipStr + ` # hostname`,
wantIP: ip, </s> remove line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname # alias`,
wantIP: ip,
wantHosts: []string{"hostname"}, </s> remove line: strings.Join([]string{"#", knownIP.String(), hostname}, sp),
</s> add line: `# ` + ipStr + ` hostname`, </s> remove line: strings.Join([]string{knownIP.String(), hostname}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname`,
wantIP: ip,
wantHosts: []string{"hostname"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
line: ipStr + ` # hostname`,
wantIP: ip, | <mask> wantIP: nil,
<mask> wantHosts: nil,
<mask> }, {
<mask> name: "invalid_line_hostname",
<mask> line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp),
<mask> wantIP: knownIP,
<mask> wantHosts: nil,
<mask> }, {
<mask> name: "commented_aliases",
<mask> line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp),
<mask> wantIP: knownIP,
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname # alias`,
wantIP: ip,
wantHosts: []string{"hostname"}, </s> remove line: knownIP.String(),
</s> add line: ipStr, </s> remove line: strings.Join([]string{"#", knownIP.String(), hostname}, sp),
</s> add line: `# ` + ipStr + ` hostname`, </s> remove line: strings.Join([]string{knownIP.String(), hostname[:4] + "#" + hostname[4:]}, sp),
wantIP: knownIP,
wantHosts: []string{hostname[:4]},
</s> add line: ipStr + ` host#name`,
wantIP: ip,
wantHosts: []string{"host"}, </s> remove line: strings.Join([]string{knownIP.String(), hostname, alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost", "hocallost"},
</s> add line: ipStr + ` hostname alias`,
wantIP: ip,
wantHosts: []string{"hostname", "alias"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
line: ipStr + ` hostname # alias`,
wantIP: ip,
wantHosts: []string{"hostname"}, | <mask> wantIP: knownIP,
<mask> wantHosts: nil,
<mask> }, {
<mask> name: "commented_aliases",
<mask> line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp),
<mask> wantIP: knownIP,
<mask> wantHosts: []string{"localhost"},
<mask> }, {
<mask> name: "whole_comment",
<mask> line: strings.Join([]string{"#", knownIP.String(), hostname}, sp),
<mask> wantIP: nil,
<mask> wantHosts: nil,
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp),
wantIP: knownIP,
</s> add line: ipStr + ` # hostname`,
wantIP: ip, </s> remove line: strings.Join([]string{"#", knownIP.String(), hostname}, sp),
</s> add line: `# ` + ipStr + ` hostname`, </s> remove line: strings.Join([]string{knownIP.String(), hostname, alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost", "hocallost"},
</s> add line: ipStr + ` hostname alias`,
wantIP: ip,
wantHosts: []string{"hostname", "alias"}, </s> remove line: knownIP.String(),
</s> add line: ipStr, </s> remove line: strings.Join([]string{knownIP.String(), hostname}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname`,
wantIP: ip,
wantHosts: []string{"hostname"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
line: `# ` + ipStr + ` hostname`, | <mask> wantIP: knownIP,
<mask> wantHosts: []string{"localhost"},
<mask> }, {
<mask> name: "whole_comment",
<mask> line: strings.Join([]string{"#", knownIP.String(), hostname}, sp),
<mask> wantIP: nil,
<mask> wantHosts: nil,
<mask> }, {
<mask> name: "partial_comment",
<mask> line: strings.Join([]string{knownIP.String(), hostname[:4] + "#" + hostname[4:]}, sp),
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname # alias`,
wantIP: ip,
wantHosts: []string{"hostname"}, </s> remove line: strings.Join([]string{knownIP.String(), hostname[:4] + "#" + hostname[4:]}, sp),
wantIP: knownIP,
wantHosts: []string{hostname[:4]},
</s> add line: ipStr + ` host#name`,
wantIP: ip,
wantHosts: []string{"host"}, </s> remove line: knownIP.String(),
</s> add line: ipStr, </s> remove line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp),
wantIP: knownIP,
</s> add line: ipStr + ` # hostname`,
wantIP: ip, </s> remove line: strings.Join([]string{knownIP.String(), hostname, alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost", "hocallost"},
</s> add line: ipStr + ` hostname alias`,
wantIP: ip,
wantHosts: []string{"hostname", "alias"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
line: ipStr + ` host#name`,
wantIP: ip,
wantHosts: []string{"host"}, | <mask> wantIP: nil,
<mask> wantHosts: nil,
<mask> }, {
<mask> name: "partial_comment",
<mask> line: strings.Join([]string{knownIP.String(), hostname[:4] + "#" + hostname[4:]}, sp),
<mask> wantIP: knownIP,
<mask> wantHosts: []string{hostname[:4]},
<mask> }, {
<mask> name: "empty",
<mask> line: ``,
<mask> wantIP: nil,
<mask> wantHosts: nil,
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove line: strings.Join([]string{"#", knownIP.String(), hostname}, sp),
</s> add line: `# ` + ipStr + ` hostname`, </s> remove line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp),
wantIP: knownIP,
</s> add line: ipStr + ` # hostname`,
wantIP: ip, </s> remove line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname # alias`,
wantIP: ip,
wantHosts: []string{"hostname"}, </s> remove line: knownIP.String(),
</s> add line: ipStr, </s> remove line: strings.Join([]string{knownIP.String(), hostname, alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost", "hocallost"},
</s> add line: ipStr + ` hostname alias`,
wantIP: ip,
wantHosts: []string{"hostname", "alias"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
got, hosts := hp.parseLine(tc.line)
assert.True(t, tc.wantIP.Equal(got)) | <mask>
<mask> for _, tc := range testCases {
<mask> hp := hostsParser{}
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> ip, hosts := hp.parseLine(tc.line)
<mask> assert.True(t, tc.wantIP.Equal(ip))
<mask> assert.Equal(t, tc.wantHosts, hosts)
<mask> })
<mask> }
<mask> }
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove if tc.wantErr != nil {
assert.ErrorIs(t, err, tc.wantErr)
return
}
</s> add </s> remove name: "non-existing",
wantErr: nil,
want: nil,
paths: []string{path.Join(dir0, "file_3")},
</s> add name: "non-existing",
paths: []string{path.Join("dir_0", "file_3")},
want: nil, </s> remove assert.True(t, hosts.Equal(wantHosts))
</s> add assert.Equal(t, wantHosts.Main, hosts.Main)
assert.True(t, hosts.Aliases.Equal(wantHosts.Aliases)) </s> remove checkRefresh(t, stringutil.NewSet(knownHost))
</s> add checkRefresh(t, Hosts{Main: "hostname"}) </s> remove t.Helper()
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/hostscontainer_test.go |
# See https://github.com/AdguardTeam/AdGuardHome/issues/4079.
1.0.0.0 hello.world.again
# Duplicates of a main host and an alias.
1.0.0.1 simplehost
1.0.0.0 hello.world
| <mask> 1.0.0.3 *
<mask> 1.0.0.4 *.com
<mask>
<mask> # Same for IPv6.
<mask> ::1 simplehost
<mask> :: hello hello.world
<mask> ::2 a.whole lot.of aliases for.testing
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove line: strings.Join([]string{knownIP.String(), "#" + hostname}, sp),
wantIP: knownIP,
</s> add line: ipStr + ` # hostname`,
wantIP: ip, </s> remove line: strings.Join([]string{knownIP.String(), hostname, "#" + alias}, sp),
wantIP: knownIP,
wantHosts: []string{"localhost"},
</s> add line: ipStr + ` hostname # alias`,
wantIP: ip,
wantHosts: []string{"hostname"}, </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} </s> remove // writeMainHostRule writes the actual rule for the qtype and the PTR for the
</s> add // writeMainRule writes the actual rule for the qtype and the PTR for the </s> remove // hostAlias if the host is not the first one added for the ip.
// hostMain if the host is the first one added for the ip.
// 0 if the ip-host pair has already been added.
</s> add // main host if the host is not the first one added for the ip.
// host itself if the host is the first one added for the ip.
// "" if the ip-host pair has already been added. | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/aghnet/testdata/etc_hosts |
hosts, ok := v.(*aghnet.Hosts) | <mask> clients.rmHostsBySrc(ClientSourceHostsFile)
<mask>
<mask> n := 0
<mask> hosts.Range(func(ip net.IP, v interface{}) (cont bool) {
<mask> names, ok := v.(*stringutil.Set)
<mask> if !ok {
<mask> log.Error("dns: bad type %T in ipToRC for %s", v, ip)
<mask> }
<mask>
<mask> names.Range(func(name string) (cont bool) {
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove names.Range(func(name string) (cont bool) {
</s> add if clients.addHostLocked(ip, hosts.Main, ClientSourceHostsFile) {
n++
}
hosts.Aliases.Range(func(name string) (cont bool) { </s> remove hp.table.Range(func(ip net.IP, val interface{}) (cont bool) {
v, hasIP := target.Get(ip)
</s> add hp.table.Range(func(ip net.IP, b interface{}) (cont bool) { </s> remove // appropriate hosts set isn't equal to the checked one, i.e. the maps
// have at least one discrepancy.
ok = !hasIP || !v.(*stringutil.Set).Equal(val.(*stringutil.Set))
</s> add // appropriate hosts set isn't equal to the checked one, i.e. the main
// hosts differ or the maps have at least one discrepancy.
if a, hasIP := target.Get(ip); !hasIP {
ok = true
} else if hosts, aok := a.(*Hosts); aok {
ok = !hosts.Equal(b.(*Hosts))
} </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/home/clients.go |
return true | <mask> hosts.Range(func(ip net.IP, v interface{}) (cont bool) {
<mask> hosts, ok := v.(*aghnet.Hosts)
<mask> if !ok {
<mask> log.Error("dns: bad type %T in ipToRC for %s", v, ip)
<mask> }
<mask>
<mask> if clients.addHostLocked(ip, hosts.Main, ClientSourceHostsFile) {
<mask> n++
<mask> }
<mask> hosts.Aliases.Range(func(name string) (cont bool) {
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove names.Range(func(name string) (cont bool) {
</s> add if clients.addHostLocked(ip, hosts.Main, ClientSourceHostsFile) {
n++
}
hosts.Aliases.Range(func(name string) (cont bool) { </s> remove names, ok := v.(*stringutil.Set)
</s> add hosts, ok := v.(*aghnet.Hosts) </s> remove hp.table.Range(func(ip net.IP, val interface{}) (cont bool) {
v, hasIP := target.Get(ip)
</s> add hp.table.Range(func(ip net.IP, b interface{}) (cont bool) { </s> remove // appropriate hosts set isn't equal to the checked one, i.e. the maps
// have at least one discrepancy.
ok = !hasIP || !v.(*stringutil.Set).Equal(val.(*stringutil.Set))
</s> add // appropriate hosts set isn't equal to the checked one, i.e. the main
// hosts differ or the maps have at least one discrepancy.
if a, hasIP := target.Get(ip); !hasIP {
ok = true
} else if hosts, aok := a.(*Hosts); aok {
ok = !hosts.Equal(b.(*Hosts))
} </s> remove func (hp *hostsParser) add(ip net.IP, host string) (hostType int) {
</s> add func (hp *hostsParser) add(ip net.IP, host string) (mainHost string) { | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/home/clients.go |
if clients.addHostLocked(ip, hosts.Main, ClientSourceHostsFile) {
n++
}
hosts.Aliases.Range(func(name string) (cont bool) { | <mask> if !ok {
<mask> log.Error("dns: bad type %T in ipToRC for %s", v, ip)
<mask> }
<mask>
<mask> names.Range(func(name string) (cont bool) {
<mask> if clients.addHostLocked(ip, name, ClientSourceHostsFile) {
<mask> n++
<mask> }
<mask>
<mask> return true
</s> Pull request: 4079 fix hosts container aliases
Merge in DNS/adguard-home from 4079-hosts-again to master
Updates #4079.
Squashed commit of the following:
commit 6aa8cbf32e8e47ba46bf5fba7681a10b68b4bc01
Merge: 19dba371 34c95f99
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:30 2022 +0500
Merge branch 'master' into 4079-hosts-again
commit 19dba371cc30ab8b75b0116833f4ecf0ef0f182f
Author: Eugene Burkov <[email protected]>
Date: Wed Jan 12 14:05:20 2022 +0500
aghnet: imp docs
commit 9f341eb8ee4ba8468240bc3eeeb4951a3f7f5e6d
Author: Eugene Burkov <[email protected]>
Date: Mon Jan 10 18:44:17 2022 +0500
aghnet: fix races
commit fd66191c7637c8584711e5bb8186494327ce0f87
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 6 17:21:14 2022 +0500
aghnet: fix hosts container aliases </s> remove names, ok := v.(*stringutil.Set)
</s> add hosts, ok := v.(*aghnet.Hosts) </s> remove hp.table.Range(func(ip net.IP, val interface{}) (cont bool) {
v, hasIP := target.Get(ip)
</s> add hp.table.Range(func(ip net.IP, b interface{}) (cont bool) { </s> remove // appropriate hosts set isn't equal to the checked one, i.e. the maps
// have at least one discrepancy.
ok = !hasIP || !v.(*stringutil.Set).Equal(val.(*stringutil.Set))
</s> add // appropriate hosts set isn't equal to the checked one, i.e. the main
// hosts differ or the maps have at least one discrepancy.
if a, hasIP := target.Get(ip); !hasIP {
ok = true
} else if hosts, aok := a.(*Hosts); aok {
ok = !hosts.Equal(b.(*Hosts))
} </s> remove // Simple types of hosts in hosts database. Zero value isn't used to be able
// quizzaciously emulate nil with 0.
const (
_ = iota
hostAlias
hostMain
)
</s> add // Hosts is used to contain the main host and all it's aliases.
type Hosts struct {
// Aliases contains all the aliases for Main.
Aliases *stringutil.Set
// Main is the host itself.
Main string
}
// Equal returns true if h equals hh.
func (h *Hosts) Equal(hh *Hosts) (ok bool) {
if h == nil || hh == nil {
return h == hh
}
return h.Main == hh.Main && h.Aliases.Equal(hh.Aliases)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/1458600c37dba16003518685729c7212598fe8ad | internal/home/clients.go |
// Create - create object
func Create(config ServerConfig) *Server {
s := Server{}
s.conf = config
return &s
}
| <mask> }
<mask>
<mask> // Init checks the configuration and initializes the server
<mask> func (s *Server) Init(config ServerConfig) error {
<mask> err := s.setConfig(config)
<mask> if err != nil {
<mask> return err
</s> * dhcp,clients: DHCP server module is passed to Clients module during initialization. </s> remove dhcpServer dhcpd.Server
</s> add dhcpServer *dhcpd.Server </s> remove func (clients *clientsContainer) Init(objects []clientObject) {
</s> add func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) { </s> remove macFound := config.dhcpServer.FindMACbyIP(ipAddr)
</s> add if clients.dhcpServer == nil {
return Client{}, false
}
macFound := clients.dhcpServer.FindMACbyIP(ipAddr) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273 | dhcpd/dhcpd.go |
// WriteDiskConfig - write configuration
func (s *Server) WriteDiskConfig(c *ServerConfig) {
*c = s.conf
}
| <mask> }
<mask>
<mask> func (s *Server) setConfig(config ServerConfig) error {
<mask> s.conf = config
<mask> s.conf.DBFilePath = filepath.Join(config.WorkDir, dbFilename)
<mask>
</s> * dhcp,clients: DHCP server module is passed to Clients module during initialization. </s> remove func (clients *clientsContainer) Init(objects []clientObject) {
</s> add func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) { </s> remove config.clients.Init(config.Clients)
</s> add config.dhcpServer = dhcpd.Create(config.DHCP)
config.clients.Init(config.Clients, config.dhcpServer) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273 | dhcpd/dhcpd.go |
"github.com/AdguardTeam/AdGuardHome/dhcpd" | <mask> "strings"
<mask> "sync"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/utils"
<mask> )
<mask>
<mask> const (
</s> * dhcp,clients: DHCP server module is passed to Clients module during initialization. </s> remove config.clients.Init(config.Clients)
</s> add config.dhcpServer = dhcpd.Create(config.DHCP)
config.clients.Init(config.Clients, config.dhcpServer) </s> remove dhcpServer dhcpd.Server
</s> add dhcpServer *dhcpd.Server </s> remove clients.Init(nil)
</s> add clients.Init(nil, nil) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273 | home/clients.go |
dhcpServer *dhcpd.Server | <mask> idIndex map[string]*Client // IP -> client
<mask> ipHost map[string]*ClientHost // IP -> Hostname
<mask> lock sync.Mutex
<mask> }
<mask>
<mask> // Init initializes clients container
<mask> // Note: this function must be called only once
<mask> func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) {
</s> * dhcp,clients: DHCP server module is passed to Clients module during initialization. </s> remove func (clients *clientsContainer) Init(objects []clientObject) {
</s> add func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) { </s> remove leases := config.dhcpServer.Leases()
</s> add if clients.dhcpServer == nil {
return
}
leases := clients.dhcpServer.Leases() </s> remove dhcpServer dhcpd.Server
</s> add dhcpServer *dhcpd.Server </s> remove clients.Init(nil)
</s> add clients.Init(nil, nil) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273 | home/clients.go |
func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) { | <mask> }
<mask>
<mask> // Init initializes clients container
<mask> // Note: this function must be called only once
<mask> func (clients *clientsContainer) Init(objects []clientObject) {
<mask> if clients.list != nil {
<mask> log.Fatal("clients.list != nil")
<mask> }
<mask> clients.list = make(map[string]*Client)
<mask> clients.idIndex = make(map[string]*Client)
</s> * dhcp,clients: DHCP server module is passed to Clients module during initialization. </s> remove leases := config.dhcpServer.Leases()
</s> add if clients.dhcpServer == nil {
return
}
leases := clients.dhcpServer.Leases() </s> remove macFound := config.dhcpServer.FindMACbyIP(ipAddr)
</s> add if clients.dhcpServer == nil {
return Client{}, false
}
macFound := clients.dhcpServer.FindMACbyIP(ipAddr) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273 | home/clients.go |
clients.dhcpServer = dhcpServer | <mask> clients.list = make(map[string]*Client)
<mask> clients.idIndex = make(map[string]*Client)
<mask> clients.ipHost = make(map[string]*ClientHost)
<mask> clients.addFromConfig(objects)
<mask>
<mask> go clients.periodicUpdate()
<mask> }
<mask>
</s> * dhcp,clients: DHCP server module is passed to Clients module during initialization. </s> remove func (clients *clientsContainer) Init(objects []clientObject) {
</s> add func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.Server) { </s> remove macFound := config.dhcpServer.FindMACbyIP(ipAddr)
</s> add if clients.dhcpServer == nil {
return Client{}, false
}
macFound := clients.dhcpServer.FindMACbyIP(ipAddr) </s> remove config.clients.Init(config.Clients)
</s> add config.dhcpServer = dhcpd.Create(config.DHCP)
config.clients.Init(config.Clients, config.dhcpServer) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/149fcc0f2dccbe0018122f1efa5b8977cf6ff273 | home/clients.go |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.