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
|
---|---|---|---|---|
'format': 'uint16' | <mask> 'format': 'int32'
<mask> 'example': 53
<mask> 'web_port':
<mask> 'type': 'integer'
<mask> 'format': 'int32'
<mask> 'example': 80
<mask> 'interfaces':
<mask> 'type': 'object'
<mask> 'description': >
<mask> Network interfaces dictionary, keys are interface names.
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'format': 'int32'
</s> add 'format': 'uint16' </s> remove 'format': 'int32'
</s> add 'format': 'uint16' </s> remove 'format': 'int32'
</s> add 'format': 'uint16' </s> remove 'format': 'int32'
</s> add 'format': 'uint16' </s> remove 'format': 'int32'
</s> add 'format': 'uint16' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'additionalProperties':
'$ref': '#/components/schemas/ClientFindSubEntry'
'example':
'1.2.3.4': 'test' | <mask> 'items':
<mask> '$ref': '#/components/schemas/ClientsFindEntry'
<mask> 'ClientsFindEntry':
<mask> 'type': 'object'
<mask> 'properties':
<mask> '1.2.3.4':
<mask> 'items':
<mask> '$ref': '#/components/schemas/ClientFindSubEntry'
<mask>
<mask> 'ClientFindSubEntry':
<mask> 'type': 'object'
<mask> 'properties':
<mask> 'name':
<mask> 'type': 'string'
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'ipv6_addresses':
</s> add 'mtu':
'type': 'integer'
'AddressInfoBeta':
'type': 'object'
'description': 'Port information'
'required':
- 'ip'
- 'port'
'properties':
'ip': </s> remove 'ipv4_addresses':
</s> add 'ip_addresses': </s> remove 'gateway_ip':
'type': 'string'
</s> add 'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53 | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'CheckConfigRequestBeta':
'type': 'object'
'description': 'Configuration to be checked'
'properties':
'dns':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'web':
'$ref': '#/components/schemas/CheckConfigRequestInfoBeta'
'set_static_ip':
'type': 'boolean'
'example': false | <mask> 'items':
<mask> 'type': 'string'
<mask> 'CheckConfigRequest':
<mask> 'type': 'object'
<mask> 'description': 'Configuration to be checked'
<mask> 'properties':
<mask> 'dns':
<mask> '$ref': '#/components/schemas/CheckConfigRequestInfo'
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'properties':
'1.2.3.4':
'items':
'$ref': '#/components/schemas/ClientFindSubEntry'
</s> add 'additionalProperties':
'$ref': '#/components/schemas/ClientFindSubEntry'
'example':
'1.2.3.4': 'test' </s> remove 'ipv6_addresses':
</s> add 'mtu':
'type': 'integer'
'AddressInfoBeta':
'type': 'object'
'description': 'Port information'
'required':
- 'ip'
- 'port'
'properties':
'ip': </s> remove 'gateway_ip':
'type': 'string'
</s> add 'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53 | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'format': 'uint16' | <mask> 'type': 'string'
<mask> 'example': '127.0.0.1'
<mask> 'port':
<mask> 'type': 'integer'
<mask> 'format': 'int32'
<mask> 'example': 53
<mask> 'autofix':
<mask> 'type': 'boolean'
<mask> 'example': false
<mask> 'CheckConfigResponse':
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'format': 'int32'
</s> add 'format': 'uint16' </s> remove 'format': 'int32'
</s> add 'format': 'uint16' </s> remove 'gateway_ip':
'type': 'string'
</s> add 'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53 </s> remove 'format': 'int32'
</s> add 'format': 'uint16' </s> remove 'format': 'int32'
</s> add 'format': 'uint16' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'required':
- 'dns'
- 'web'
- 'static_ip' | <mask> 'type': 'boolean'
<mask> 'example': false
<mask> 'CheckConfigResponse':
<mask> 'type': 'object'
<mask> 'properties':
<mask> 'dns':
<mask> '$ref': '#/components/schemas/CheckConfigResponseInfo'
<mask> 'web':
<mask> '$ref': '#/components/schemas/CheckConfigResponseInfo'
<mask> 'static_ip':
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'properties':
'1.2.3.4':
'items':
'$ref': '#/components/schemas/ClientFindSubEntry'
</s> add 'additionalProperties':
'$ref': '#/components/schemas/ClientFindSubEntry'
'example':
'1.2.3.4': 'test' </s> remove 'format': 'int32'
</s> add 'format': 'uint16' | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'required':
- 'status'
- 'can_autofix' | <mask> '$ref': '#/components/schemas/CheckConfigStaticIpInfo'
<mask> 'CheckConfigResponseInfo':
<mask> 'type': 'object'
<mask> 'properties':
<mask> 'status':
<mask> 'type': 'string'
<mask> 'default': ''
<mask> 'example': ''
<mask> 'can_autofix':
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'properties':
'1.2.3.4':
'items':
'$ref': '#/components/schemas/ClientFindSubEntry'
</s> add 'additionalProperties':
'$ref': '#/components/schemas/ClientFindSubEntry'
'example':
'1.2.3.4': 'test' | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'default': '' | <mask> 'status':
<mask> 'type': 'string'
<mask> 'example': ''
<mask> 'can_autofix':
<mask> 'type': 'boolean'
<mask> 'example': false
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'format': 'int32'
</s> add 'format': 'uint16' | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'CheckConfigStaticIpInfoStatic':
'type': 'string'
'example': 'no'
'enum':
- 'yes'
- 'no'
- 'error'
'description': 'Can be: yes, no, error' | <mask> 'can_autofix':
<mask> 'type': 'boolean'
<mask> 'example': false
<mask> 'CheckConfigStaticIpInfo':
<mask> 'type': 'object'
<mask> 'properties':
<mask> 'static':
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'type': 'string'
'example': 'no'
'description': 'Can be: yes, no, error'
</s> add '$ref': '#/components/schemas/CheckConfigStaticIpInfoStatic' | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'$ref': '#/components/schemas/CheckConfigStaticIpInfoStatic' | <mask> 'CheckConfigStaticIpInfo':
<mask> 'type': 'object'
<mask> 'properties':
<mask> 'static':
<mask> 'type': 'string'
<mask> 'example': 'no'
<mask> 'description': 'Can be: yes, no, error'
<mask> 'ip':
<mask> 'type': 'string'
<mask> 'example': '192.168.1.1'
<mask> 'description': 'Current dynamic IP address. Set if static=no'
<mask> 'error':
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'gateway_ip':
'type': 'string'
</s> add 'minItems': 1
'example':
- '127.0.0.1'
'port':
'type': 'integer'
'format': 'uint16'
'example': 53 | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'default': '' | <mask> 'static':
<mask> '$ref': '#/components/schemas/CheckConfigStaticIpInfoStatic'
<mask> 'ip':
<mask> 'type': 'string'
<mask> 'example': '192.168.1.1'
<mask> 'description': 'Current dynamic IP address. Set if static=no'
<mask> 'error':
<mask> 'type': 'string'
<mask> 'default': ''
<mask> 'example': ''
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'type': 'string'
'example': 'no'
'description': 'Can be: yes, no, error'
</s> add '$ref': '#/components/schemas/CheckConfigStaticIpInfoStatic' | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'default': '' | <mask> 'example': '192.168.1.1'
<mask> 'description': 'Current dynamic IP address. Set if static=no'
<mask> 'error':
<mask> 'type': 'string'
<mask> 'example': ''
<mask> 'description': 'Error text. Set if static=error'
<mask> 'InitialConfigurationBeta':
<mask> 'type': 'object'
<mask> 'description': >
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'type': 'string'
'example': 'no'
'description': 'Can be: yes, no, error'
</s> add '$ref': '#/components/schemas/CheckConfigStaticIpInfoStatic' </s> remove 'format': 'int32'
</s> add 'format': 'uint16' | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
'required':
- 'dns'
- 'web'
- 'username'
- 'password' | <mask> 'InitialConfiguration':
<mask> 'type': 'object'
<mask> 'description': >
<mask> AdGuard Home initial configuration for the first-install wizard.
<mask> 'properties':
<mask> 'dns':
<mask> '$ref': '#/components/schemas/AddressInfo'
<mask> 'web':
</s> Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <[email protected]>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <[email protected]>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed </s> remove 'properties':
'1.2.3.4':
'items':
'$ref': '#/components/schemas/ClientFindSubEntry'
</s> add 'additionalProperties':
'$ref': '#/components/schemas/ClientFindSubEntry'
'example':
'1.2.3.4': 'test' </s> remove 'format': 'int32'
</s> add 'format': 'uint16' | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e20ac7ed5de861ea5c945d1775f75312d62b69f | openapi/openapi.yaml |
httpServer *http.Server | <mask> versionCheckLastTime time.Time
<mask>
<mask> httpsServer HTTPSServer
<mask>
<mask> BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
<mask> BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
</s> * move "httpServer" to "config" </s> remove err := httpServer.ListenAndServe()
</s> add err := config.httpServer.ListenAndServe() </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) </s> remove httpServer = &http.Server{
</s> add config.httpServer = &http.Server{ </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) </s> remove var httpServer *http.Server
</s> add | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e309a7b3a5d29323a6e08189ceb5c101fc38035 | home/config.go |
config.httpServer.Shutdown(context.TODO()) | <mask> // this needs to be done in a goroutine because Shutdown() is a blocking call, and it will block
<mask> // until all requests are finished, and _we_ are inside a request right now, so it will block indefinitely
<mask> if restartHTTP {
<mask> go func() {
<mask> httpServer.Shutdown(context.TODO())
<mask> }()
<mask> }
<mask>
<mask> returnOK(w)
<mask> }
</s> * move "httpServer" to "config" </s> remove err := httpServer.ListenAndServe()
</s> add err := config.httpServer.ListenAndServe() </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) </s> remove httpServer = &http.Server{
</s> add config.httpServer = &http.Server{ </s> remove var httpServer *http.Server
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e309a7b3a5d29323a6e08189ceb5c101fc38035 | home/control_install.go |
<mask> "github.com/NYTimes/gziphandler"
<mask> "github.com/gobuffalo/packr"
<mask> )
<mask>
<mask> var httpServer *http.Server
<mask>
<mask> const (
<mask> // Used in config to indicate that syslog or eventlog (win) should be used for logger output
<mask> configSyslog = "syslog"
<mask> )
<mask>
</s> * move "httpServer" to "config" </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) </s> remove err := httpServer.ListenAndServe()
</s> add err := config.httpServer.ListenAndServe() </s> remove httpServer = &http.Server{
</s> add config.httpServer = &http.Server{ </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e309a7b3a5d29323a6e08189ceb5c101fc38035 | home/home.go |
|
config.httpServer = &http.Server{ | <mask> printHTTPAddresses("http")
<mask>
<mask> // we need to have new instance, because after Shutdown() the Server is not usable
<mask> address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort))
<mask> httpServer = &http.Server{
<mask> Addr: address,
<mask> }
<mask> err := httpServer.ListenAndServe()
<mask> if err != http.ErrServerClosed {
<mask> cleanupAlways()
</s> * move "httpServer" to "config" </s> remove err := httpServer.ListenAndServe()
</s> add err := config.httpServer.ListenAndServe() </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) </s> remove var httpServer *http.Server
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e309a7b3a5d29323a6e08189ceb5c101fc38035 | home/home.go |
err := config.httpServer.ListenAndServe() | <mask> address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort))
<mask> httpServer = &http.Server{
<mask> Addr: address,
<mask> }
<mask> err := httpServer.ListenAndServe()
<mask> if err != http.ErrServerClosed {
<mask> cleanupAlways()
<mask> log.Fatal(err)
<mask> }
<mask> // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop
</s> * move "httpServer" to "config" </s> remove httpServer = &http.Server{
</s> add config.httpServer = &http.Server{ </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) </s> remove var httpServer *http.Server
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e309a7b3a5d29323a6e08189ceb5c101fc38035 | home/home.go |
config.httpServer.Shutdown(context.TODO()) | <mask> config.httpsServer.shutdown = true
<mask> if config.httpsServer.server != nil {
<mask> config.httpsServer.server.Shutdown(context.TODO())
<mask> }
<mask> httpServer.Shutdown(context.TODO())
<mask> }
<mask>
<mask> // This function is called before application exits
<mask> func cleanupAlways() {
<mask> if len(config.pidFileName) != 0 {
</s> * move "httpServer" to "config" </s> remove httpServer.Shutdown(context.TODO())
</s> add config.httpServer.Shutdown(context.TODO()) </s> remove httpServer = &http.Server{
</s> add config.httpServer = &http.Server{ </s> remove err := httpServer.ListenAndServe()
</s> add err := config.httpServer.ListenAndServe() </s> remove var httpServer *http.Server
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e309a7b3a5d29323a6e08189ceb5c101fc38035 | home/home.go |
"bytes" | <mask> import (
<mask> "bufio"
<mask> "fmt"
<mask> "net"
<mask> "sync"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/netutil"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add </s> remove "io"
</s> add </s> remove "io"
</s> add </s> remove "io"
</s> add | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
<mask>
<mask> import (
<mask> "bufio"
<mask> "fmt"
<mask> "io"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "io"
</s> add </s> remove "strings"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
|
<mask> "bufio"
<mask> "fmt"
<mask> "io"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/netutil"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "io"
</s> add </s> remove "io"
</s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghos"
</s> add </s> remove "os/exec"
"strings"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
|
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/netutil"
<mask> )
<mask>
<mask> // ARPDB: The Network Neighborhood Database
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
|
<mask> // ARP-related command. lenHint is a hint for the size of the allocated slice
<mask> // of Neighbors.
<mask> type parseNeighsFunc func(sc *bufio.Scanner, lenHint int) (ns []Neighbor)
<mask>
<mask> // runCmdFunc is the function that runs some command and returns its output
<mask> // wrapped to be a io.Reader.
<mask> type runCmdFunc func() (r io.Reader, err error)
<mask>
<mask> // cmdARPDB is the implementation of the ARPDB that uses command line to
<mask> // retrieve data.
<mask> type cmdARPDB struct {
<mask> parse parseNeighsFunc
<mask> runcmd runCmdFunc
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove parse parseNeighsFunc
runcmd runCmdFunc
ns *neighs
</s> add parse parseNeighsFunc
ns *neighs
cmd string
args []string </s> remove // last is the last succeeded ARPDB index.
last int
</s> add neighs </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
|
parse parseNeighsFunc
ns *neighs
cmd string
args []string | <mask>
<mask> // cmdARPDB is the implementation of the ARPDB that uses command line to
<mask> // retrieve data.
<mask> type cmdARPDB struct {
<mask> parse parseNeighsFunc
<mask> runcmd runCmdFunc
<mask> ns *neighs
<mask> }
<mask>
<mask> // type check
<mask> var _ ARPDB = (*cmdARPDB)(nil)
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // runCmdFunc is the function that runs some command and returns its output
// wrapped to be a io.Reader.
type runCmdFunc func() (r io.Reader, err error)
</s> add </s> remove last: 0,
</s> add neighs: neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
}, </s> remove // last is the last succeeded ARPDB index.
last int
</s> add neighs </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add </s> remove require.NotPanics(t, func() {
a = NewARPDB()
})
</s> add require.NotPanics(t, func() { a = NewARPDB() }) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
<mask>
<mask> // type check
<mask> var _ ARPDB = (*cmdARPDB)(nil)
<mask>
<mask> // runCmd runs the cmd with it's args and returns the result wrapped to be an
<mask> // io.Reader. The error is returned either if the exit code retured by command
<mask> // not equals 0 or the execution itself failed.
<mask> func runCmd(cmd string, args ...string) (r io.Reader, err error) {
<mask> var code int
<mask> var out string
<mask> code, out, err = aghos.RunCommand(cmd, args...)
<mask> if err != nil {
<mask> return nil, err
<mask> } else if code != 0 {
<mask> return nil, fmt.Errorf("unexpected exit code %d", code)
<mask> }
<mask>
<mask> return strings.NewReader(out), nil
<mask> }
<mask>
<mask> // Refresh implements the ARPDB interface for *cmdARPDB.
<mask> func (arp *cmdARPDB) Refresh() (err error) {
<mask> defer func() { err = errors.Annotate(err, "cmd arpdb: %w") }()
<mask>
<mask> var r io.Reader
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) </s> remove parse parseNeighsFunc
runcmd runCmdFunc
ns *neighs
</s> add parse parseNeighsFunc
ns *neighs
cmd string
args []string </s> remove func GatewayIP(ifaceName string) net.IP {
cmd := exec.Command("ip", "route", "show", "dev", ifaceName)
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
d, err := cmd.Output()
if err != nil || cmd.ProcessState.ExitCode() != 0 {
</s> add //
// TODO(e.burkov): Investigate if the gateway address may be fetched in another
// way since not every machine has the software installed.
func GatewayIP(ifaceName string) (ip net.IP) {
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
if err != nil {
log.Debug("%s", err)
return nil
} else if code != 0 {
log.Debug("fetching gateway ip: unexpected exit code: %d", code)
</s> remove }
if code != 0 {
</s> add } else if code != 0 { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
|
code, out, err := aghosRunCommand(arp.cmd, arp.args...) | <mask> // Refresh implements the ARPDB interface for *cmdARPDB.
<mask> func (arp *cmdARPDB) Refresh() (err error) {
<mask> defer func() { err = errors.Annotate(err, "cmd arpdb: %w") }()
<mask>
<mask> var r io.Reader
<mask> r, err = arp.runcmd()
<mask> if err != nil {
<mask> return fmt.Errorf("running command: %w", err)
<mask> }
<mask>
<mask> sc := bufio.NewScanner(r)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add </s> remove sc := bufio.NewScanner(r)
</s> add sc := bufio.NewScanner(bytes.NewReader(out)) </s> remove l := len(arp.arps)
// Start from the last succeeded implementation.
for i := 0; i < l; i++ {
cur := (arp.last + i) % l
err = arp.arps[cur].Refresh()
if err == nil {
// The succeeded implementation found so update the last succeeded
// index.
arp.last = cur
return nil
</s> add for _, a := range arp.arps {
err = a.Refresh()
if err != nil {
errs = append(errs, err)
continue </s> remove return out, err
</s> add return string(outData), err | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
} else if code != 0 {
return fmt.Errorf("running command: unexpected exit code %d", code) | <mask>
<mask> code, out, err := aghosRunCommand(arp.cmd, arp.args...)
<mask> if err != nil {
<mask> return fmt.Errorf("running command: %w", err)
<mask> }
<mask>
<mask> sc := bufio.NewScanner(bytes.NewReader(out))
<mask> ns := arp.parse(sc, arp.ns.len())
<mask> if err = sc.Err(); err != nil {
<mask> // TODO(e.burkov): This error seems unreachable. Investigate.
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove sc := bufio.NewScanner(r)
</s> add sc := bufio.NewScanner(bytes.NewReader(out)) </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) </s> remove func getNetworkSetupHardwareReports() map[string]string {
_, out, err := aghos.RunCommand("networksetup", "-listallhardwareports")
if err != nil {
return nil
}
re, err := regexp.Compile("Hardware Port: (.*?)\nDevice: (.*?)\n")
</s> add func getNetworkSetupHardwareReports() (reports map[string]string) {
_, out, err := aghosRunCommand("networksetup", "-listallhardwareports") </s> remove func GatewayIP(ifaceName string) net.IP {
cmd := exec.Command("ip", "route", "show", "dev", ifaceName)
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
d, err := cmd.Output()
if err != nil || cmd.ProcessState.ExitCode() != 0 {
</s> add //
// TODO(e.burkov): Investigate if the gateway address may be fetched in another
// way since not every machine has the software installed.
func GatewayIP(ifaceName string) (ip net.IP) {
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
if err != nil {
log.Debug("%s", err)
return nil
} else if code != 0 {
log.Debug("fetching gateway ip: unexpected exit code: %d", code)
| [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
sc := bufio.NewScanner(bytes.NewReader(out)) | <mask> if err != nil {
<mask> return fmt.Errorf("running command: %w", err)
<mask> }
<mask>
<mask> sc := bufio.NewScanner(r)
<mask> ns := arp.parse(sc, arp.ns.len())
<mask> if err = sc.Err(); err != nil {
<mask> return fmt.Errorf("scanning the output: %w", err)
<mask> }
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) </s> remove err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644)
</s> add err = maybe.WriteFile(filename, body, 0o644) </s> remove var netInterfaces []*NetInterface
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
// TODO(e.burkov): This error seems unreachable. Investigate. | <mask> ns := arp.parse(sc, arp.ns.len())
<mask> if err = sc.Err(); err != nil {
<mask> return fmt.Errorf("scanning the output: %w", err)
<mask> }
<mask>
<mask> arp.ns.reset(ns)
<mask>
<mask> return nil
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove sc := bufio.NewScanner(r)
</s> add sc := bufio.NewScanner(bytes.NewReader(out)) </s> remove err = maybe.WriteFile("/etc/dhcpcd.conf", body, 0o644)
</s> add err = maybe.WriteFile(filename, body, 0o644) </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
neighs | <mask> // consequently switches between those.
<mask> type arpdbs struct {
<mask> // arps is the set of ARPDB implementations to range through.
<mask> arps []ARPDB
<mask> // last is the last succeeded ARPDB index.
<mask> last int
<mask> }
<mask>
<mask> // newARPDBs returns a properly initialized *arpdbs. It begins refreshing from
<mask> // the first of arps.
<mask> func newARPDBs(arps ...ARPDB) (arp *arpdbs) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove last: 0,
</s> add neighs: neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
}, </s> remove l := len(arp.arps)
// Start from the last succeeded implementation.
for i := 0; i < l; i++ {
cur := (arp.last + i) % l
err = arp.arps[cur].Refresh()
if err == nil {
// The succeeded implementation found so update the last succeeded
// index.
arp.last = cur
return nil
</s> add for _, a := range arp.arps {
err = a.Refresh()
if err != nil {
errs = append(errs, err)
continue </s> remove // runCmdFunc is the function that runs some command and returns its output
// wrapped to be a io.Reader.
type runCmdFunc func() (r io.Reader, err error)
</s> add </s> remove parse parseNeighsFunc
runcmd runCmdFunc
ns *neighs
</s> add parse parseNeighsFunc
ns *neighs
cmd string
args []string | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
neighs: neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
}, | <mask> // the first of arps.
<mask> func newARPDBs(arps ...ARPDB) (arp *arpdbs) {
<mask> return &arpdbs{
<mask> arps: arps,
<mask> last: 0,
<mask> }
<mask> }
<mask>
<mask> // type check
<mask> var _ ARPDB = (*arpdbs)(nil)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // last is the last succeeded ARPDB index.
last int
</s> add neighs </s> remove parse parseNeighsFunc
runcmd runCmdFunc
ns *neighs
</s> add parse parseNeighsFunc
ns *neighs
cmd string
args []string </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add </s> remove if l := len(arp.arps); l > 0 && arp.last < l {
return arp.arps[arp.last].Neighbors()
}
return nil
</s> add return arp.clone() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
for _, a := range arp.arps {
err = a.Refresh()
if err != nil {
errs = append(errs, err)
continue | <mask>
<mask> // Refresh implements the ARPDB interface for *arpdbs.
<mask> func (arp *arpdbs) Refresh() (err error) {
<mask> var errs []error
<mask> l := len(arp.arps)
<mask> // Start from the last succeeded implementation.
<mask> for i := 0; i < l; i++ {
<mask> cur := (arp.last + i) % l
<mask> err = arp.arps[cur].Refresh()
<mask> if err == nil {
<mask> // The succeeded implementation found so update the last succeeded
<mask> // index.
<mask> arp.last = cur
<mask>
<mask> return nil
<mask> }
<mask>
<mask> errs = append(errs, err)
<mask> }
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove if l := len(arp.arps); l > 0 && arp.last < l {
return arp.arps[arp.last].Neighbors()
}
return nil
</s> add return arp.clone() </s> remove // last is the last succeeded ARPDB index.
last int
</s> add neighs </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) </s> remove assert.Equal(t, 2, succRefrCount)
</s> add assert.Equal(t, 1, succRefrCount) </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
arp.reset(a.Neighbors())
return nil | <mask>
<mask> return nil
<mask> }
<mask>
<mask> errs = append(errs, err)
<mask> }
<mask>
<mask> if len(errs) > 0 {
<mask> err = errors.List("each arpdb failed", errs...)
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove l := len(arp.arps)
// Start from the last succeeded implementation.
for i := 0; i < l; i++ {
cur := (arp.last + i) % l
err = arp.arps[cur].Refresh()
if err == nil {
// The succeeded implementation found so update the last succeeded
// index.
arp.last = cur
return nil
</s> add for _, a := range arp.arps {
err = a.Refresh()
if err != nil {
errs = append(errs, err)
continue </s> remove if l := len(arp.arps); l > 0 && arp.last < l {
return arp.arps[arp.last].Neighbors()
}
return nil
</s> add return arp.clone() </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove if errors.As(err, new(*exec.ExitError)) {
return cmd.ProcessState.ExitCode(), string(out), nil
} else if err != nil {
return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out)
</s> add if err != nil {
if eerr := new(exec.ExitError); errors.As(err, &eerr) {
return eerr.ExitCode(), eerr.Stderr, nil
}
return 1, nil, fmt.Errorf("command %q failed: %w: %s", command, err, out) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
//
// TODO(e.burkov): Think of a way to avoid cloning the slice twice. | <mask>
<mask> // Neighbors implements the ARPDB interface for *arpdbs.
<mask> func (arp *arpdbs) Neighbors() (ns []Neighbor) {
<mask> return arp.clone()
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove if l := len(arp.arps); l > 0 && arp.last < l {
return arp.arps[arp.last].Neighbors()
}
return nil
</s> add return arp.clone() </s> remove l := len(arp.arps)
// Start from the last succeeded implementation.
for i := 0; i < l; i++ {
cur := (arp.last + i) % l
err = arp.arps[cur].Refresh()
if err == nil {
// The succeeded implementation found so update the last succeeded
// index.
arp.last = cur
return nil
</s> add for _, a := range arp.arps {
err = a.Refresh()
if err != nil {
errs = append(errs, err)
continue </s> remove // last is the last succeeded ARPDB index.
last int
</s> add neighs </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) </s> remove last: 0,
</s> add neighs: neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
}, | [
"keep",
"add",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
return arp.clone() | <mask> }
<mask>
<mask> // Neighbors implements the ARPDB interface for *arpdbs.
<mask> func (arp *arpdbs) Neighbors() (ns []Neighbor) {
<mask> if l := len(arp.arps); l > 0 && arp.last < l {
<mask> return arp.arps[arp.last].Neighbors()
<mask> }
<mask>
<mask> return nil
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove l := len(arp.arps)
// Start from the last succeeded implementation.
for i := 0; i < l; i++ {
cur := (arp.last + i) % l
err = arp.arps[cur].Refresh()
if err == nil {
// The succeeded implementation found so update the last succeeded
// index.
arp.last = cur
return nil
</s> add for _, a := range arp.arps {
err = a.Refresh()
if err != nil {
errs = append(errs, err)
continue </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add </s> remove // last is the last succeeded ARPDB index.
last int
</s> add neighs | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb.go |
parse: parseArpA, | <mask> )
<mask>
<mask> func newARPDB() *cmdARPDB {
<mask> return &cmdARPDB{
<mask> parse: parseArpA,
<mask> runcmd: rcArpA,
<mask> ns: &neighs{
<mask> mu: &sync.RWMutex{},
<mask> ns: make([]Neighbor, 0),
<mask> },
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove runcmd: rcArpA,
parse: parseArpA,
</s> add parse: parseArpA, </s> remove runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove parse: parseArpA,
</s> add cmd: "arp",
args: []string{"/a"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_bsd.go |
cmd: "arp",
args: []string{"-a"}, | <mask> ns: make([]Neighbor, 0),
<mask> },
<mask> }
<mask> }
<mask>
<mask> // parseArpA parses the output of the "arp -a" command on macOS and FreeBSD.
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // rcArpA runs "arp /a".
func rcArpA() (r io.Reader, err error) {
return runCmd("arp", "/a")
}
</s> add </s> remove // rcIPNeigh runs "ip neigh".
func rcIPNeigh() (r io.Reader, err error) {
return runCmd("ip", "neigh")
}
</s> add </s> remove parse: parseArpA,
</s> add cmd: "arp",
args: []string{"/a"}, | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_bsd.go |
<mask>
<mask> import (
<mask> "bufio"
<mask> "fmt"
<mask> "io"
<mask> "io/fs"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "io"
</s> add </s> remove "io"
</s> add </s> remove "strings"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux.go |
|
&fsysARPDB{
ns: ns,
fsys: rootDirFS,
filename: "proc/net/arp",
},
// Then, try "arp -a".
&cmdARPDB{
parse: parseF,
ns: ns,
cmd: "arp",
args: []string{"-a"},
},
// Finally, try "ip neigh".
&cmdARPDB{
parse: parseIPNeigh,
ns: ns,
cmd: "ip",
args: []string{"neigh"},
}, | <mask> }
<mask>
<mask> return newARPDBs(
<mask> // Try /proc/net/arp first.
<mask> &fsysARPDB{ns: ns, fsys: aghos.RootDirFS(), filename: "proc/net/arp"},
<mask> // Try "arp -a" then.
<mask> &cmdARPDB{parse: parseF, runcmd: rcArpA, ns: ns},
<mask> // Try "ip neigh" finally.
<mask> &cmdARPDB{parse: parseIPNeigh, runcmd: rcIPNeigh, ns: ns},
<mask> )
<mask> }
<mask>
<mask> // fsysARPDB accesses the ARP cache file to update the database.
<mask> type fsysARPDB struct {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove parse: parseArpA,
runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove runcmd: rcArpA,
parse: parseArpA,
</s> add parse: parseArpA, </s> remove runcmd: rcArpA,
</s> add parse: parseArpA, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux.go |
<mask>
<mask> return ns
<mask> }
<mask>
<mask> // rcIPNeigh runs "ip neigh".
<mask> func rcIPNeigh() (r io.Reader, err error) {
<mask> return runCmd("ip", "neigh")
<mask> }
<mask>
<mask> // parseIPNeigh parses the output of the "ip neigh" command on Linux. The
<mask> // expected input format:
<mask> //
<mask> // 192.168.1.1 dev enp0s3 lladdr ab:cd:ef:ab:cd:ef REACHABLE
<mask> //
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // rcArpA runs "arp /a".
func rcArpA() (r io.Reader, err error) {
return runCmd("arp", "/a")
}
</s> add </s> remove // runCmdFunc is the function that runs some command and returns its output
// wrapped to be a io.Reader.
type runCmdFunc func() (r io.Reader, err error)
</s> add </s> remove if len(fields) < 3 || fields[0] != "default" {
</s> add if len(fields) < 3 || string(fields[0]) != "default" { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux.go |
|
<mask>
<mask> package aghnet
<mask>
<mask> import (
<mask> "io"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask> "testing"
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "io"
</s> add </s> remove "io"
</s> add </s> remove "strings"
</s> add </s> remove "strings"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
|
<mask>
<mask> import (
<mask> "io"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask> "testing"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add </s> remove "io"
</s> add </s> remove "io"
</s> add </s> remove "testing/iotest"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
|
"testing/fstest" | <mask> "net"
<mask> "sync"
<mask> "testing"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
<mask> const arpAOutputWrt = `
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "github.com/stretchr/testify/require"
</s> add </s> remove "strings"
</s> add </s> remove "testing/iotest"
</s> add </s> remove "bytes"
</s> add "io/fs" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
require.NoError(t, fstest.TestFS(testdata, "proc_net_arp"))
| <mask> }}
<mask>
<mask> func TestFSysARPDB(t *testing.T) {
<mask> a := &fsysARPDB{
<mask> ns: &neighs{
<mask> mu: &sync.RWMutex{},
<mask> ns: make([]Neighbor, 0),
<mask> },
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove err := a.Refresh()
require.NoError(t, err)
</s> add t.Run("wrt", func(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
cmd: "arp",
args: []string{"-a"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
} </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove parse: parseArpA,
runcmd: rcArpA,
</s> add parse: parseArpA, | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
func TestCmdARPDB_linux(t *testing.T) {
sh := mapShell{
"arp -a": {err: nil, out: arpAOutputWrt, code: 0},
"ip neigh": {err: nil, out: ipNeighOutput, code: 0}, | <mask> ns := a.Neighbors()
<mask> assert.Equal(t, wantNeighs, ns)
<mask> }
<mask>
<mask> func TestCmdARPDB_arpawrt(t *testing.T) {
<mask> a := &cmdARPDB{
<mask> parse: parseArpAWrt,
<mask> runcmd: func() (r io.Reader, err error) { return strings.NewReader(arpAOutputWrt), nil },
<mask> ns: &neighs{
<mask> mu: &sync.RWMutex{},
<mask> ns: make([]Neighbor, 0),
<mask> },
<mask> }
<mask>
<mask> err := a.Refresh()
<mask> require.NoError(t, err)
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove err := a.Refresh()
require.NoError(t, err)
</s> add t.Run("wrt", func(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
cmd: "arp",
args: []string{"-a"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
} </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) </s> remove
a := &cmdARPDB{
runcmd: badReaderRunCmd,
parse: parseArpA,
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
const wantErrMsg string = "cmd arpdb: scanning the output: " + string(errRead)
testutil.AssertErrorMsg(t, wantErrMsg, a.Refresh())
</s> add </s> remove parse: parseArpA,
runcmd: rcArpA,
</s> add parse: parseArpA, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
substShell(t, sh.RunCmd) | <mask> "ip neigh": {err: nil, out: ipNeighOutput, code: 0},
<mask> }
<mask>
<mask> t.Run("wrt", func(t *testing.T) {
<mask> a := &cmdARPDB{
<mask> parse: parseArpAWrt,
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func TestCmdARPDB_arpawrt(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(arpAOutputWrt), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
</s> add func TestCmdARPDB_linux(t *testing.T) {
sh := mapShell{
"arp -a": {err: nil, out: arpAOutputWrt, code: 0},
"ip neigh": {err: nil, out: ipNeighOutput, code: 0}, </s> remove err := a.Refresh()
require.NoError(t, err)
</s> add t.Run("wrt", func(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
cmd: "arp",
args: []string{"-a"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
} </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
t.Run("wrt", func(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
cmd: "arp",
args: []string{"-a"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
} | <mask> ns: make([]Neighbor, 0),
<mask> },
<mask> }
<mask>
<mask> err := a.Refresh()
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, wantNeighs, a.Neighbors())
<mask> }
<mask>
<mask> func TestCmdARPDB_ipneigh(t *testing.T) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
}) </s> remove func TestCmdARPDB_arpawrt(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(arpAOutputWrt), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
</s> add func TestCmdARPDB_linux(t *testing.T) {
sh := mapShell{
"arp -a": {err: nil, out: arpAOutputWrt, code: 0},
"ip neigh": {err: nil, out: ipNeighOutput, code: 0}, </s> remove a.runcmd = func() (r io.Reader, err error) { return strings.NewReader(arpAOutput), nil }
</s> add sh := theOnlyCmd("cmd", 0, arpAOutput, nil)
substShell(t, sh.RunCmd) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
err := a.Refresh()
require.NoError(t, err) | <mask>
<mask> err := a.Refresh()
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, wantNeighs, a.Neighbors())
<mask> }
<mask>
<mask> func TestCmdARPDB_ipneigh(t *testing.T) {
<mask> a := &cmdARPDB{
<mask> parse: parseIPNeigh,
<mask> runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove err := a.Refresh()
require.NoError(t, err)
</s> add t.Run("wrt", func(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
cmd: "arp",
args: []string{"-a"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
} </s> remove a.runcmd = func() (r io.Reader, err error) { return strings.NewReader(arpAOutput), nil }
</s> add sh := theOnlyCmd("cmd", 0, arpAOutput, nil)
substShell(t, sh.RunCmd) </s> remove func TestCmdARPDB_arpawrt(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(arpAOutputWrt), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
</s> add func TestCmdARPDB_linux(t *testing.T) {
sh := mapShell{
"arp -a": {err: nil, out: arpAOutputWrt, code: 0},
"ip neigh": {err: nil, out: ipNeighOutput, code: 0}, </s> remove a.runcmd = func() (r io.Reader, err error) { return nil, errors.Error("can't run") }
</s> add sh := theOnlyCmd("cmd", 0, "", errors.Error("can't run"))
substShell(t, sh.RunCmd) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) | <mask>
<mask> assert.Equal(t, wantNeighs, a.Neighbors())
<mask> }
<mask>
<mask> func TestCmdARPDB_ipneigh(t *testing.T) {
<mask> a := &cmdARPDB{
<mask> parse: parseIPNeigh,
<mask> runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
<mask> ns: &neighs{
<mask> mu: &sync.RWMutex{},
<mask> ns: make([]Neighbor, 0),
<mask> },
<mask> }
<mask> err := a.Refresh()
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, wantNeighs, a.Neighbors())
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) </s> remove err := a.Refresh()
require.NoError(t, err)
</s> add t.Run("wrt", func(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
cmd: "arp",
args: []string{"-a"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
} </s> remove func TestCmdARPDB_arpawrt(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(arpAOutputWrt), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
</s> add func TestCmdARPDB_linux(t *testing.T) {
sh := mapShell{
"arp -a": {err: nil, out: arpAOutputWrt, code: 0},
"ip neigh": {err: nil, out: ipNeighOutput, code: 0}, </s> remove a.runcmd = func() (r io.Reader, err error) { return strings.NewReader(arpAOutput), nil }
</s> add sh := theOnlyCmd("cmd", 0, arpAOutput, nil)
substShell(t, sh.RunCmd) </s> remove
a := &cmdARPDB{
runcmd: badReaderRunCmd,
parse: parseArpA,
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
const wantErrMsg string = "cmd arpdb: scanning the output: " + string(errRead)
testutil.AssertErrorMsg(t, wantErrMsg, a.Refresh())
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
assert.Equal(t, wantNeighs, a.Neighbors())
}) | <mask> }
<mask> err := a.Refresh()
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, wantNeighs, a.Neighbors())
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) </s> remove a.runcmd = func() (r io.Reader, err error) { return strings.NewReader(arpAOutput), nil }
</s> add sh := theOnlyCmd("cmd", 0, arpAOutput, nil)
substShell(t, sh.RunCmd) </s> remove err := a.Refresh()
require.NoError(t, err)
</s> add t.Run("wrt", func(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
cmd: "arp",
args: []string{"-a"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
} </s> remove a.runcmd = func() (r io.Reader, err error) { return nil, errors.Error("can't run") }
</s> add sh := theOnlyCmd("cmd", 0, "", errors.Error("can't run"))
substShell(t, sh.RunCmd) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_linux_test.go |
parse: parseArpA, | <mask> )
<mask>
<mask> func newARPDB() *cmdARPDB {
<mask> return &cmdARPDB{
<mask> runcmd: rcArpA,
<mask> parse: parseArpA,
<mask> ns: &neighs{
<mask> mu: &sync.RWMutex{},
<mask> ns: make([]Neighbor, 0),
<mask> },
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove parse: parseArpA,
runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove parse: parseArpA,
</s> add cmd: "arp",
args: []string{"/a"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_openbsd.go |
cmd: "arp",
args: []string{"-a"}, | <mask> ns: make([]Neighbor, 0),
<mask> },
<mask> }
<mask> }
<mask>
<mask> // parseArpA parses the output of the "arp -a" command on OpenBSD. The expected
<mask> // input format:
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // rcArpA runs "arp /a".
func rcArpA() (r io.Reader, err error) {
return runCmd("arp", "/a")
}
</s> add </s> remove // rcIPNeigh runs "ip neigh".
func rcIPNeigh() (r io.Reader, err error) {
return runCmd("ip", "neigh")
}
</s> add </s> remove parse: parseArpA,
</s> add cmd: "arp",
args: []string{"/a"}, | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_openbsd.go |
<mask> package aghnet
<mask>
<mask> import (
<mask> "io"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask> "testing"
<mask> "testing/iotest"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "io"
</s> add </s> remove "strings"
</s> add </s> remove "io"
</s> add </s> remove "strings"
</s> add | [
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
|
<mask>
<mask> import (
<mask> "io"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask> "testing"
<mask> "testing/iotest"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "io"
</s> add </s> remove "testing/iotest"
</s> add </s> remove "strings"
</s> add </s> remove "io"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
|
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask> "testing"
<mask> "testing/iotest"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/testutil"
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add </s> remove "strings"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
|
require.NotPanics(t, func() { a = NewARPDB() }) | <mask> )
<mask>
<mask> func TestNewARPDB(t *testing.T) {
<mask> var a ARPDB
<mask> require.NotPanics(t, func() {
<mask> a = NewARPDB()
<mask> })
<mask>
<mask> assert.NotNil(t, a)
<mask> }
<mask>
<mask> // TestARPDB is the mock implementation of ARPDB to use in tests.
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove parse parseNeighsFunc
runcmd runCmdFunc
ns *neighs
</s> add parse parseNeighsFunc
ns *neighs
cmd string
args []string </s> remove // runCmdFunc is the function that runs some command and returns its output
// wrapped to be a io.Reader.
type runCmdFunc func() (r io.Reader, err error)
</s> add </s> remove // last is the last succeeded ARPDB index.
last int
</s> add neighs | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
// Unstable ARPDB should refresh successfully again. | <mask>
<mask> assert.Equal(t, 1, succRefrCount)
<mask> assert.NotEmpty(t, a.Neighbors())
<mask>
<mask> // Only the last succeeded ARPDB should be used.
<mask> err = a.Refresh()
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, 2, succRefrCount)
<mask> assert.NotEmpty(t, a.Neighbors())
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove assert.Equal(t, 2, succRefrCount)
</s> add assert.Equal(t, 1, succRefrCount) </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
}) </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) </s> remove a.runcmd = func() (r io.Reader, err error) { return strings.NewReader(arpAOutput), nil }
</s> add sh := theOnlyCmd("cmd", 0, arpAOutput, nil)
substShell(t, sh.RunCmd) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
assert.Equal(t, 1, succRefrCount) | <mask> // Only the last succeeded ARPDB should be used.
<mask> err = a.Refresh()
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, 2, succRefrCount)
<mask> assert.NotEmpty(t, a.Neighbors())
<mask> })
<mask>
<mask> t.Run("empty", func(t *testing.T) {
<mask> a := newARPDBs()
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // Only the last succeeded ARPDB should be used.
</s> add // Unstable ARPDB should refresh successfully again. </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
}) </s> remove l := len(arp.arps)
// Start from the last succeeded implementation.
for i := 0; i < l; i++ {
cur := (arp.last + i) % l
err = arp.arps[cur].Refresh()
if err == nil {
// The succeeded implementation found so update the last succeeded
// index.
arp.last = cur
return nil
</s> add for _, a := range arp.arps {
err = a.Refresh()
if err != nil {
errs = append(errs, err)
continue </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
cmd: "cmd", | <mask>
<mask> func TestCmdARPDB_arpa(t *testing.T) {
<mask> a := &cmdARPDB{
<mask> parse: parseArpA,
<mask> ns: &neighs{
<mask> mu: &sync.RWMutex{},
<mask> ns: make([]Neighbor, 0),
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove runcmd: rcArpA,
parse: parseArpA,
</s> add parse: parseArpA, </s> remove parse: parseArpA,
runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove err := a.Refresh()
require.NoError(t, err)
</s> add t.Run("wrt", func(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
cmd: "arp",
args: []string{"-a"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
} </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
sh := theOnlyCmd("cmd", 0, arpAOutput, nil)
substShell(t, sh.RunCmd) | <mask> },
<mask> }
<mask>
<mask> t.Run("arp_a", func(t *testing.T) {
<mask> a.runcmd = func() (r io.Reader, err error) { return strings.NewReader(arpAOutput), nil }
<mask>
<mask> err := a.Refresh()
<mask> require.NoError(t, err)
<mask>
<mask> assert.Equal(t, wantNeighs, a.Neighbors())
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove a.runcmd = func() (r io.Reader, err error) { return nil, errors.Error("can't run") }
</s> add sh := theOnlyCmd("cmd", 0, "", errors.Error("can't run"))
substShell(t, sh.RunCmd) </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
}) </s> remove err := a.Refresh()
require.NoError(t, err)
</s> add t.Run("wrt", func(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
cmd: "arp",
args: []string{"-a"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
sh := theOnlyCmd("cmd", 0, "", errors.Error("can't run"))
substShell(t, sh.RunCmd) | <mask> assert.Equal(t, wantNeighs, a.Neighbors())
<mask> })
<mask>
<mask> t.Run("runcmd_error", func(t *testing.T) {
<mask> a.runcmd = func() (r io.Reader, err error) { return nil, errors.Error("can't run") }
<mask>
<mask> err := a.Refresh()
<mask> testutil.AssertErrorMsg(t, "cmd arpdb: running command: can't run", err)
<mask> })
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove }
</s> add </s> remove func TestCmdARPDB_errors(t *testing.T) {
const errRead errors.Error = "can't read"
</s> add t.Run("bad_code", func(t *testing.T) {
sh := theOnlyCmd("cmd", 1, "", nil)
substShell(t, sh.RunCmd) </s> remove a.runcmd = func() (r io.Reader, err error) { return strings.NewReader(arpAOutput), nil }
</s> add sh := theOnlyCmd("cmd", 0, arpAOutput, nil)
substShell(t, sh.RunCmd) </s> remove badReaderRunCmd := runCmdFunc(func() (r io.Reader, err error) {
return iotest.ErrReader(errRead), nil
</s> add err := a.Refresh()
testutil.AssertErrorMsg(t, "cmd arpdb: running command: unexpected exit code 1", err) </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
<mask>
<mask> err := a.Refresh()
<mask> testutil.AssertErrorMsg(t, "cmd arpdb: running command: can't run", err)
<mask> })
<mask> }
<mask>
<mask> func TestCmdARPDB_errors(t *testing.T) {
<mask> const errRead errors.Error = "can't read"
<mask>
<mask> badReaderRunCmd := runCmdFunc(func() (r io.Reader, err error) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func TestCmdARPDB_errors(t *testing.T) {
const errRead errors.Error = "can't read"
</s> add t.Run("bad_code", func(t *testing.T) {
sh := theOnlyCmd("cmd", 1, "", nil)
substShell(t, sh.RunCmd) </s> remove badReaderRunCmd := runCmdFunc(func() (r io.Reader, err error) {
return iotest.ErrReader(errRead), nil
</s> add err := a.Refresh()
testutil.AssertErrorMsg(t, "cmd arpdb: running command: unexpected exit code 1", err) </s> remove a.runcmd = func() (r io.Reader, err error) { return nil, errors.Error("can't run") }
</s> add sh := theOnlyCmd("cmd", 0, "", errors.Error("can't run"))
substShell(t, sh.RunCmd) </s> remove
a := &cmdARPDB{
runcmd: badReaderRunCmd,
parse: parseArpA,
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
const wantErrMsg string = "cmd arpdb: scanning the output: " + string(errRead)
testutil.AssertErrorMsg(t, wantErrMsg, a.Refresh())
</s> add </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
|
t.Run("bad_code", func(t *testing.T) {
sh := theOnlyCmd("cmd", 1, "", nil)
substShell(t, sh.RunCmd) | <mask> testutil.AssertErrorMsg(t, "cmd arpdb: running command: can't run", err)
<mask> })
<mask> }
<mask>
<mask> func TestCmdARPDB_errors(t *testing.T) {
<mask> const errRead errors.Error = "can't read"
<mask>
<mask> badReaderRunCmd := runCmdFunc(func() (r io.Reader, err error) {
<mask> return iotest.ErrReader(errRead), nil
<mask> })
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove }
</s> add </s> remove badReaderRunCmd := runCmdFunc(func() (r io.Reader, err error) {
return iotest.ErrReader(errRead), nil
</s> add err := a.Refresh()
testutil.AssertErrorMsg(t, "cmd arpdb: running command: unexpected exit code 1", err) </s> remove a.runcmd = func() (r io.Reader, err error) { return nil, errors.Error("can't run") }
</s> add sh := theOnlyCmd("cmd", 0, "", errors.Error("can't run"))
substShell(t, sh.RunCmd) </s> remove
a := &cmdARPDB{
runcmd: badReaderRunCmd,
parse: parseArpA,
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
const wantErrMsg string = "cmd arpdb: scanning the output: " + string(errRead)
testutil.AssertErrorMsg(t, wantErrMsg, a.Refresh())
</s> add </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
err := a.Refresh()
testutil.AssertErrorMsg(t, "cmd arpdb: running command: unexpected exit code 1", err) | <mask>
<mask> func TestCmdARPDB_errors(t *testing.T) {
<mask> const errRead errors.Error = "can't read"
<mask>
<mask> badReaderRunCmd := runCmdFunc(func() (r io.Reader, err error) {
<mask> return iotest.ErrReader(errRead), nil
<mask> })
<mask>
<mask> a := &cmdARPDB{
<mask> runcmd: badReaderRunCmd,
<mask> parse: parseArpA,
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func TestCmdARPDB_errors(t *testing.T) {
const errRead errors.Error = "can't read"
</s> add t.Run("bad_code", func(t *testing.T) {
sh := theOnlyCmd("cmd", 1, "", nil)
substShell(t, sh.RunCmd) </s> remove }
</s> add </s> remove
a := &cmdARPDB{
runcmd: badReaderRunCmd,
parse: parseArpA,
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
const wantErrMsg string = "cmd arpdb: scanning the output: " + string(errRead)
testutil.AssertErrorMsg(t, wantErrMsg, a.Refresh())
</s> add </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
<mask>
<mask> badReaderRunCmd := runCmdFunc(func() (r io.Reader, err error) {
<mask> return iotest.ErrReader(errRead), nil
<mask> })
<mask>
<mask> a := &cmdARPDB{
<mask> runcmd: badReaderRunCmd,
<mask> parse: parseArpA,
<mask> ns: &neighs{
<mask> mu: &sync.RWMutex{},
<mask> ns: make([]Neighbor, 0),
<mask> },
<mask> }
<mask>
<mask> const wantErrMsg string = "cmd arpdb: scanning the output: " + string(errRead)
<mask>
<mask> testutil.AssertErrorMsg(t, wantErrMsg, a.Refresh())
<mask> }
<mask>
<mask> func TestEmptyARPDB(t *testing.T) {
<mask> a := EmptyARPDB{}
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove badReaderRunCmd := runCmdFunc(func() (r io.Reader, err error) {
return iotest.ErrReader(errRead), nil
</s> add err := a.Refresh()
testutil.AssertErrorMsg(t, "cmd arpdb: running command: unexpected exit code 1", err) </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove parse: parseArpA,
runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove runcmd: rcArpA,
parse: parseArpA,
</s> add parse: parseArpA, | [
"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/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_test.go |
|
<mask> package aghnet
<mask>
<mask> import (
<mask> "bufio"
<mask> "io"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask> )
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "io"
</s> add </s> remove "io"
</s> add </s> remove "io"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_windows.go |
|
parse: parseArpA, | <mask> )
<mask>
<mask> func newARPDB() *cmdARPDB {
<mask> return &cmdARPDB{
<mask> runcmd: rcArpA,
<mask> ns: &neighs{
<mask> mu: &sync.RWMutex{},
<mask> ns: make([]Neighbor, 0),
<mask> },
<mask> parse: parseArpA,
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove runcmd: rcArpA,
parse: parseArpA,
</s> add parse: parseArpA, </s> remove parse: parseArpA,
runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove parse: parseArpA,
</s> add cmd: "arp",
args: []string{"/a"}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_windows.go |
cmd: "arp",
args: []string{"/a"}, | <mask> ns: &neighs{
<mask> mu: &sync.RWMutex{},
<mask> ns: make([]Neighbor, 0),
<mask> },
<mask> parse: parseArpA,
<mask> }
<mask> }
<mask>
<mask> // rcArpA runs "arp /a".
<mask> func rcArpA() (r io.Reader, err error) {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove parse: parseArpA,
runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove runcmd: rcArpA,
parse: parseArpA,
</s> add parse: parseArpA, </s> remove runcmd: rcArpA,
</s> add parse: parseArpA, </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove // rcArpA runs "arp /a".
func rcArpA() (r io.Reader, err error) {
return runCmd("arp", "/a")
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_windows.go |
<mask> parse: parseArpA,
<mask> }
<mask> }
<mask>
<mask> // rcArpA runs "arp /a".
<mask> func rcArpA() (r io.Reader, err error) {
<mask> return runCmd("arp", "/a")
<mask> }
<mask>
<mask> // parseArpA parses the output of the "arp /a" command on Windows. The expected
<mask> // input format (the first line is empty):
<mask> //
<mask> //
<mask> // Interface: 192.168.56.16 --- 0x7
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove parse: parseArpA,
</s> add cmd: "arp",
args: []string{"/a"}, </s> remove // rcIPNeigh runs "ip neigh".
func rcIPNeigh() (r io.Reader, err error) {
return runCmd("ip", "neigh")
}
</s> add </s> remove // runCmdFunc is the function that runs some command and returns its output
// wrapped to be a io.Reader.
type runCmdFunc func() (r io.Reader, err error)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/arpdb_windows.go |
|
require.NoError(t, fstest.TestFS(testdata, "etc_hosts"))
| <mask> OnClose: func() (err error) { panic("not implemented") },
<mask> }
<mask>
<mask> hc, err := NewHostsContainer(0, testdata, &stubWatcher, "etc_hosts")
<mask> require.NoError(t, err)
<mask> testutil.CleanupAndRequireSuccess(t, hc.Close)
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove assert.Equal(t, wantNeighs, a.Neighbors())
}
</s> add err := a.Refresh()
require.NoError(t, err) </s> remove a.runcmd = func() (r io.Reader, err error) { return strings.NewReader(arpAOutput), nil }
</s> add sh := theOnlyCmd("cmd", 0, arpAOutput, nil)
substShell(t, sh.RunCmd) </s> remove func TestCmdARPDB_ipneigh(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(ipNeighOutput), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err)
</s> add assert.Equal(t, wantNeighs, a.Neighbors())
})
t.Run("ip_neigh", func(t *testing.T) {
a := &cmdARPDB{
parse: parseIPNeigh,
cmd: "ip",
args: []string{"neigh"},
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
}
err := a.Refresh()
require.NoError(t, err) </s> remove var r io.Reader
r, err = arp.runcmd()
</s> add code, out, err := aghosRunCommand(arp.cmd, arp.args...) </s> remove func TestCmdARPDB_arpawrt(t *testing.T) {
a := &cmdARPDB{
parse: parseArpAWrt,
runcmd: func() (r io.Reader, err error) { return strings.NewReader(arpAOutputWrt), nil },
ns: &neighs{
mu: &sync.RWMutex{},
ns: make([]Neighbor, 0),
},
</s> add func TestCmdARPDB_linux(t *testing.T) {
sh := mapShell{
"arp -a": {err: nil, out: arpAOutputWrt, code: 0},
"ip neigh": {err: nil, out: ipNeighOutput, code: 0}, | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/hostscontainer_test.go |
require.NoError(t, fstest.TestFS(testdata, "etc_hosts"))
| <mask> func TestHostsContainer(t *testing.T) {
<mask> const listID = 1234
<mask>
<mask> testCases := []struct {
<mask> want []*rules.DNSRewrite
<mask> name string
<mask> req urlfilter.DNSRequest
<mask> }{{
<mask> want: []*rules.DNSRewrite{{
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove name string
rcconfData string
wantHas bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove func TestSetStaticIPdhcpcdConf(t *testing.T) {
</s> add func TestSetStaticIP_dhcpcdConfIface(t *testing.T) { </s> remove name string
rcconfData string
wantCont bool
</s> add name string
rootFsys fs.FS
wantHas assert.BoolAssertionFunc </s> remove func TestHostnameIfStaticConfig(t *testing.T) {
const nl = "\n"
</s> add func TestIfaceHasStaticIP(t *testing.T) {
const ifaceName = "em0"
confFile := fmt.Sprintf("etc/hostname.%s", ifaceName) </s> remove func TestDHCPCDStaticConfig(t *testing.T) {
const iface interfaceName = `wlan0`
</s> add func TestHasStaticIP(t *testing.T) {
const ifaceName = "wlan0" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/hostscontainer_test.go |
"bytes" | <mask> package aghnet
<mask>
<mask> import (
<mask> "encoding/json"
<mask> "fmt"
<mask> "io"
<mask> "net"
<mask> "syscall"
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "os/exec"
"strings"
</s> add </s> remove "os"
</s> add "io" </s> remove "io"
</s> add | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
<mask> "encoding/json"
<mask> "fmt"
<mask> "io"
<mask> "net"
<mask> "os/exec"
<mask> "strings"
<mask> "syscall"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/netutil"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
|
"github.com/AdguardTeam/AdGuardHome/internal/aghos" | <mask> "io"
<mask> "net"
<mask> "syscall"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/netutil"
<mask> )
<mask>
<mask> // aghosRunCommand is the function to run shell commands. It's an unexported
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "os/exec"
"strings"
</s> add </s> remove "strings"
</s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/aghos"
</s> add | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
// aghosRunCommand is the function to run shell commands. It's an unexported
// variable instead of a direct call to make it substitutable in tests.
var aghosRunCommand = aghos.RunCommand
// rootDirFS is the filesystem pointing to the root directory. It's an
// unexported variable instead to make it substitutable in tests.
var rootDirFS = aghos.RootDirFS()
| <mask> "github.com/AdguardTeam/golibs/netutil"
<mask> )
<mask>
<mask> // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
<mask> // the IP being static is available.
<mask> const ErrNoStaticIPInfo errors.Error = "no information about static ip"
<mask>
<mask> // IfaceHasStaticIP checks if interface is configured to have static IP address.
<mask> // If it can't give a definitive answer, it returns false and an error for which
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // TODO(a.garipov): Currently, this function returns the first
// definitive result. So if /etc/dhcpcd.conf has a static IP while
// /etc/network/interfaces doesn't, it will return true. Perhaps this
// is not the most desirable behavior.
</s> add // TODO(a.garipov): Currently, this function returns the first definitive
// result. So if /etc/dhcpcd.conf has and /etc/network/interfaces has no
// static IP configuration, it will return true. Perhaps this is not the
// most desirable behavior. </s> remove return walker.Walk(aghos.RootDirFS(), rcConfFilename)
</s> add return walker.Walk(rootDirFS, rcConfFilename) </s> remove return aghos.FileWalker(hostnameIfStaticConfig).Walk(aghos.RootDirFS(), filename)
</s> add return aghos.FileWalker(hostnameIfStaticConfig).Walk(rootDirFS, filename) </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove ifaceFound := findIfaceLine(s, string(n))
if !ifaceFound {
</s> add if !findIfaceLine(s, string(n)) { | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
//
// TODO(e.burkov): Investigate if the gateway address may be fetched in another
// way since not every machine has the software installed.
func GatewayIP(ifaceName string) (ip net.IP) {
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
if err != nil {
log.Debug("%s", err)
return nil
} else if code != 0 {
log.Debug("fetching gateway ip: unexpected exit code: %d", code)
| <mask> return ifaceSetStaticIP(ifaceName)
<mask> }
<mask>
<mask> // GatewayIP returns IP address of interface's gateway.
<mask> func GatewayIP(ifaceName string) net.IP {
<mask> cmd := exec.Command("ip", "route", "show", "dev", ifaceName)
<mask> log.Tracef("executing %s %v", cmd.Path, cmd.Args)
<mask> d, err := cmd.Output()
<mask> if err != nil || cmd.ProcessState.ExitCode() != 0 {
<mask> return nil
<mask> }
<mask>
<mask> fields := strings.Fields(string(d))
<mask> // The meaningful "ip route" command output should contain the word
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove fields := strings.Fields(string(d))
</s> add fields := bytes.Fields(out) </s> remove if len(fields) < 3 || fields[0] != "default" {
</s> add if len(fields) < 3 || string(fields[0]) != "default" { </s> remove func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
h := hardwarePortInfo{}
</s> add // hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") </s> remove func getNetworkSetupHardwareReports() map[string]string {
_, out, err := aghos.RunCommand("networksetup", "-listallhardwareports")
if err != nil {
return nil
}
re, err := regexp.Compile("Hardware Port: (.*?)\nDevice: (.*?)\n")
</s> add func getNetworkSetupHardwareReports() (reports map[string]string) {
_, out, err := aghosRunCommand("networksetup", "-listallhardwareports") </s> remove // First of all we should find hardware port name
</s> add // First of all we should find hardware port name. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
fields := bytes.Fields(out) | <mask> if err != nil || cmd.ProcessState.ExitCode() != 0 {
<mask> return nil
<mask> }
<mask>
<mask> fields := strings.Fields(string(d))
<mask> // The meaningful "ip route" command output should contain the word
<mask> // "default" at first field and default gateway IP address at third field.
<mask> if len(fields) < 3 || fields[0] != "default" {
<mask> return nil
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove if len(fields) < 3 || fields[0] != "default" {
</s> add if len(fields) < 3 || string(fields[0]) != "default" { </s> remove func GatewayIP(ifaceName string) net.IP {
cmd := exec.Command("ip", "route", "show", "dev", ifaceName)
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
d, err := cmd.Output()
if err != nil || cmd.ProcessState.ExitCode() != 0 {
</s> add //
// TODO(e.burkov): Investigate if the gateway address may be fetched in another
// way since not every machine has the software installed.
func GatewayIP(ifaceName string) (ip net.IP) {
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
if err != nil {
log.Debug("%s", err)
return nil
} else if code != 0 {
log.Debug("fetching gateway ip: unexpected exit code: %d", code)
</s> remove return net.ParseIP(fields[2])
</s> add return net.ParseIP(string(fields[2])) </s> remove // Man page interfaces(5) declares that interface definition
// should consist of the key word "iface" followed by interface
// name, and method at fourth field.
</s> add // Man page interfaces(5) declares that interface definition should
// consist of the key word "iface" followed by interface name, and
// method at fourth field. </s> remove }
if code != 0 {
</s> add } else if code != 0 { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
if len(fields) < 3 || string(fields[0]) != "default" { | <mask>
<mask> fields := strings.Fields(string(d))
<mask> // The meaningful "ip route" command output should contain the word
<mask> // "default" at first field and default gateway IP address at third field.
<mask> if len(fields) < 3 || fields[0] != "default" {
<mask> return nil
<mask> }
<mask>
<mask> return net.ParseIP(fields[2])
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove fields := strings.Fields(string(d))
</s> add fields := bytes.Fields(out) </s> remove return net.ParseIP(fields[2])
</s> add return net.ParseIP(string(fields[2])) </s> remove func GatewayIP(ifaceName string) net.IP {
cmd := exec.Command("ip", "route", "show", "dev", ifaceName)
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
d, err := cmd.Output()
if err != nil || cmd.ProcessState.ExitCode() != 0 {
</s> add //
// TODO(e.burkov): Investigate if the gateway address may be fetched in another
// way since not every machine has the software installed.
func GatewayIP(ifaceName string) (ip net.IP) {
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
if err != nil {
log.Debug("%s", err)
return nil
} else if code != 0 {
log.Debug("fetching gateway ip: unexpected exit code: %d", code)
</s> remove // Man page interfaces(5) declares that interface definition
// should consist of the key word "iface" followed by interface
// name, and method at fourth field.
</s> add // Man page interfaces(5) declares that interface definition should
// consist of the key word "iface" followed by interface name, and
// method at fourth field. </s> remove // rcIPNeigh runs "ip neigh".
func rcIPNeigh() (r io.Reader, err error) {
return runCmd("ip", "neigh")
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
return net.ParseIP(string(fields[2])) | <mask> if len(fields) < 3 || fields[0] != "default" {
<mask> return nil
<mask> }
<mask>
<mask> return net.ParseIP(fields[2])
<mask> }
<mask>
<mask> // CanBindPort checks if we can bind to the given port.
<mask> func CanBindPort(port int) (can bool, err error) {
<mask> var addr *net.TCPAddr
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove if len(fields) < 3 || fields[0] != "default" {
</s> add if len(fields) < 3 || string(fields[0]) != "default" { </s> remove fields := strings.Fields(string(d))
</s> add fields := bytes.Fields(out) </s> remove func ifaceHasStaticIP(ifaceName string) (bool, error) {
</s> add func ifaceHasStaticIP(ifaceName string) (ok bool, err error) { </s> remove return aghos.FileWalker(hostnameIfStaticConfig).Walk(aghos.RootDirFS(), filename)
</s> add return aghos.FileWalker(hostnameIfStaticConfig).Walk(rootDirFS, filename) </s> remove return walker.Walk(aghos.RootDirFS(), rcConfFilename)
</s> add return walker.Walk(rootDirFS, rcConfFilename) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
func GetValidNetInterfacesForWeb() (netInterfaces []*NetInterface, err error) { | <mask> }
<mask>
<mask> // GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and WEB only
<mask> // we do not return link-local addresses here
<mask> func GetValidNetInterfacesForWeb() ([]*NetInterface, error) {
<mask> ifaces, err := net.Interfaces()
<mask> if err != nil {
<mask> return nil, fmt.Errorf("couldn't get interfaces: %w", err)
<mask> } else if len(ifaces) == 0 {
<mask> return nil, errors.Error("couldn't find any legible interface")
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove var netInterfaces []*NetInterface
</s> add </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove return nil, fmt.Errorf("got iface.Addrs() element %s that is not net.IPNet, it is %T", addr, addr)
</s> add return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr) </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
<mask> } else if len(ifaces) == 0 {
<mask> return nil, errors.Error("couldn't find any legible interface")
<mask> }
<mask>
<mask> var netInterfaces []*NetInterface
<mask>
<mask> for _, iface := range ifaces {
<mask> var addrs []net.Addr
<mask> addrs, err = iface.Addrs()
<mask> if err != nil {
<mask> return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func GetValidNetInterfacesForWeb() ([]*NetInterface, error) {
</s> add func GetValidNetInterfacesForWeb() (netInterfaces []*NetInterface, err error) { </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove return nil, fmt.Errorf("got iface.Addrs() element %s that is not net.IPNet, it is %T", addr, addr)
</s> add return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr) </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
|
return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr) | <mask> for _, addr := range addrs {
<mask> ipNet, ok := addr.(*net.IPNet)
<mask> if !ok {
<mask> // Should be net.IPNet, this is weird.
<mask> return nil, fmt.Errorf("got iface.Addrs() element %s that is not net.IPNet, it is %T", addr, addr)
<mask> }
<mask> // Ignore link-local.
<mask> if ipNet.IP.IsLinkLocalUnicast() {
<mask> continue
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // TODO(a.garipov): Currently, this function returns the first
// definitive result. So if /etc/dhcpcd.conf has a static IP while
// /etc/network/interfaces doesn't, it will return true. Perhaps this
// is not the most desirable behavior.
</s> add // TODO(a.garipov): Currently, this function returns the first definitive
// result. So if /etc/dhcpcd.conf has and /etc/network/interfaces has no
// static IP configuration, it will return true. Perhaps this is not the
// most desirable behavior. </s> remove var netInterfaces []*NetInterface
</s> add </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove // First of all we should find hardware port name
</s> add // First of all we should find hardware port name. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net.go |
"bufio"
"bytes" | <mask> package aghnet
<mask>
<mask> import (
<mask> "fmt"
<mask> "io"
<mask> "regexp"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/errors"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "os"
</s> add "io" </s> remove "strings"
</s> add </s> remove "io"
</s> add </s> remove "io"
</s> add | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
"io" | <mask> package aghnet
<mask>
<mask> import (
<mask> "fmt"
<mask> "os"
<mask> "regexp"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/errors"
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "strings"
</s> add </s> remove "strings"
</s> add "fmt"
"io/fs" </s> remove "io"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
<mask> import (
<mask> "fmt"
<mask> "os"
<mask> "regexp"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> )
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove "os"
</s> add "io" </s> remove "io"
</s> add </s> remove "strings"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
|
func ifaceHasStaticIP(ifaceName string) (ok bool, err error) { | <mask> func canBindPrivilegedPorts() (can bool, err error) {
<mask> return aghos.HaveAdminRights()
<mask> }
<mask>
<mask> func ifaceHasStaticIP(ifaceName string) (bool, error) {
<mask> portInfo, err := getCurrentHardwarePortInfo(ifaceName)
<mask> if err != nil {
<mask> return false, err
<mask> }
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove return aghos.FileWalker(hostnameIfStaticConfig).Walk(aghos.RootDirFS(), filename)
</s> add return aghos.FileWalker(hostnameIfStaticConfig).Walk(rootDirFS, filename) </s> remove h.name = hardwarePort
h.ip = match[1]
h.subnet = match[2]
h.gatewayIP = match[3]
if strings.Index(out, "Manual Configuration") == 0 {
h.static = true
}
return h, nil
</s> add return hardwarePortInfo{
name: hardwarePort,
ip: string(match[1]),
subnet: string(match[2]),
gatewayIP: string(match[3]),
static: bytes.Index(out, []byte("Manual Configuration")) == 0,
}, nil </s> remove return net.ParseIP(fields[2])
</s> add return net.ParseIP(string(fields[2])) </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove _, out, err := aghos.RunCommand("networksetup", "-getinfo", hardwarePort)
</s> add func getHardwarePortInfo(hardwarePort string) (h hardwarePortInfo, err error) {
_, out, err := aghosRunCommand("networksetup", "-getinfo", hardwarePort) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
// getCurrentHardwarePortInfo gets information for the specified network
// interface. | <mask>
<mask> return portInfo.static, nil
<mask> }
<mask>
<mask> // getCurrentHardwarePortInfo gets information for the specified network interface.
<mask> func getCurrentHardwarePortInfo(ifaceName string) (hardwarePortInfo, error) {
<mask> // First of all we should find hardware port name
<mask> m := getNetworkSetupHardwareReports()
<mask> hardwarePort, ok := m[ifaceName]
<mask> if !ok {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // First of all we should find hardware port name
</s> add // First of all we should find hardware port name. </s> remove return m
</s> add return reports </s> remove func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
h := hardwarePortInfo{}
</s> add // hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") </s> remove func getNetworkSetupHardwareReports() map[string]string {
_, out, err := aghos.RunCommand("networksetup", "-listallhardwareports")
if err != nil {
return nil
}
re, err := regexp.Compile("Hardware Port: (.*?)\nDevice: (.*?)\n")
</s> add func getNetworkSetupHardwareReports() (reports map[string]string) {
_, out, err := aghosRunCommand("networksetup", "-listallhardwareports") </s> remove h.name = hardwarePort
h.ip = match[1]
h.subnet = match[2]
h.gatewayIP = match[3]
if strings.Index(out, "Manual Configuration") == 0 {
h.static = true
}
return h, nil
</s> add return hardwarePortInfo{
name: hardwarePort,
ip: string(match[1]),
subnet: string(match[2]),
gatewayIP: string(match[3]),
static: bytes.Index(out, []byte("Manual Configuration")) == 0,
}, nil | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
// First of all we should find hardware port name. | <mask> }
<mask>
<mask> // getCurrentHardwarePortInfo gets information for the specified network interface.
<mask> func getCurrentHardwarePortInfo(ifaceName string) (hardwarePortInfo, error) {
<mask> // First of all we should find hardware port name
<mask> m := getNetworkSetupHardwareReports()
<mask> hardwarePort, ok := m[ifaceName]
<mask> if !ok {
<mask> return hardwarePortInfo{}, fmt.Errorf("could not find hardware port for %s", ifaceName)
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // getCurrentHardwarePortInfo gets information for the specified network interface.
</s> add // getCurrentHardwarePortInfo gets information for the specified network
// interface. </s> remove h.name = hardwarePort
h.ip = match[1]
h.subnet = match[2]
h.gatewayIP = match[3]
if strings.Index(out, "Manual Configuration") == 0 {
h.static = true
}
return h, nil
</s> add return hardwarePortInfo{
name: hardwarePort,
ip: string(match[1]),
subnet: string(match[2]),
gatewayIP: string(match[3]),
static: bytes.Index(out, []byte("Manual Configuration")) == 0,
}, nil </s> remove re := regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n")
match := re.FindStringSubmatch(out)
if len(match) == 0 {
</s> add match := hardwarePortReg.FindSubmatch(out)
if len(match) != 4 { </s> remove return m
</s> add return reports </s> remove func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
h := hardwarePortInfo{}
</s> add // hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
// hardwareReportsReg is the regular expression matching the lines of
// networksetup command output lines containing the interface information.
var hardwareReportsReg = regexp.MustCompile("Hardware Port: (.*?)\nDevice: (.*?)\n")
| <mask> }
<mask>
<mask> // getNetworkSetupHardwareReports parses the output of the `networksetup
<mask> // -listallhardwareports` command it returns a map where the key is the
<mask> // interface name, and the value is the "hardware port" returns nil if it fails
<mask> // to parse the output
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove // runCmdFunc is the function that runs some command and returns its output
// wrapped to be a io.Reader.
type runCmdFunc func() (r io.Reader, err error)
</s> add </s> remove // TODO(a.garipov): Currently, this function returns the first
// definitive result. So if /etc/dhcpcd.conf has a static IP while
// /etc/network/interfaces doesn't, it will return true. Perhaps this
// is not the most desirable behavior.
</s> add // TODO(a.garipov): Currently, this function returns the first definitive
// result. So if /etc/dhcpcd.conf has and /etc/network/interfaces has no
// static IP configuration, it will return true. Perhaps this is not the
// most desirable behavior. | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
func getNetworkSetupHardwareReports() (reports map[string]string) {
_, out, err := aghosRunCommand("networksetup", "-listallhardwareports") | <mask> //
<mask> // TODO(e.burkov): There should be more proper approach than parsing the
<mask> // command output. For example, see
<mask> // https://developer.apple.com/documentation/systemconfiguration.
<mask> func getNetworkSetupHardwareReports() map[string]string {
<mask> _, out, err := aghos.RunCommand("networksetup", "-listallhardwareports")
<mask> if err != nil {
<mask> return nil
<mask> }
<mask>
<mask> re, err := regexp.Compile("Hardware Port: (.*?)\nDevice: (.*?)\n")
<mask> if err != nil {
<mask> return nil
<mask> }
<mask>
<mask> m := make(map[string]string)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
h := hardwarePortInfo{}
</s> add // hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") </s> remove func GatewayIP(ifaceName string) net.IP {
cmd := exec.Command("ip", "route", "show", "dev", ifaceName)
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
d, err := cmd.Output()
if err != nil || cmd.ProcessState.ExitCode() != 0 {
</s> add //
// TODO(e.burkov): Investigate if the gateway address may be fetched in another
// way since not every machine has the software installed.
func GatewayIP(ifaceName string) (ip net.IP) {
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
if err != nil {
log.Debug("%s", err)
return nil
} else if code != 0 {
log.Debug("fetching gateway ip: unexpected exit code: %d", code)
</s> remove m := make(map[string]string)
</s> add reports = make(map[string]string) </s> remove _, out, err := aghos.RunCommand("networksetup", "-getinfo", hardwarePort)
</s> add func getHardwarePortInfo(hardwarePort string) (h hardwarePortInfo, err error) {
_, out, err := aghosRunCommand("networksetup", "-getinfo", hardwarePort) </s> remove fields := strings.Fields(string(d))
</s> add fields := bytes.Fields(out) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
reports = make(map[string]string) | <mask> if err != nil {
<mask> return nil
<mask> }
<mask>
<mask> m := make(map[string]string)
<mask>
<mask> matches := re.FindAllStringSubmatch(out, -1)
<mask> for i := range matches {
<mask> port := matches[i][1]
<mask> device := matches[i][2]
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove matches := re.FindAllStringSubmatch(out, -1)
for i := range matches {
port := matches[i][1]
device := matches[i][2]
m[device] = port
</s> add matches := hardwareReportsReg.FindAllSubmatch(out, -1)
for _, m := range matches {
reports[string(m[2])] = string(m[1]) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove return m
</s> add return reports </s> remove func getNetworkSetupHardwareReports() map[string]string {
_, out, err := aghos.RunCommand("networksetup", "-listallhardwareports")
if err != nil {
return nil
}
re, err := regexp.Compile("Hardware Port: (.*?)\nDevice: (.*?)\n")
</s> add func getNetworkSetupHardwareReports() (reports map[string]string) {
_, out, err := aghosRunCommand("networksetup", "-listallhardwareports") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
matches := hardwareReportsReg.FindAllSubmatch(out, -1)
for _, m := range matches {
reports[string(m[2])] = string(m[1]) | <mask> }
<mask>
<mask> m := make(map[string]string)
<mask>
<mask> matches := re.FindAllStringSubmatch(out, -1)
<mask> for i := range matches {
<mask> port := matches[i][1]
<mask> device := matches[i][2]
<mask> m[device] = port
<mask> }
<mask>
<mask> return m
<mask> }
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove m := make(map[string]string)
</s> add reports = make(map[string]string) </s> remove return m
</s> add return reports </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove // First of all we should find hardware port name
</s> add // First of all we should find hardware port name. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
return reports | <mask> device := matches[i][2]
<mask> m[device] = port
<mask> }
<mask>
<mask> return m
<mask> }
<mask>
<mask> func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
<mask> h := hardwarePortInfo{}
<mask>
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove matches := re.FindAllStringSubmatch(out, -1)
for i := range matches {
port := matches[i][1]
device := matches[i][2]
m[device] = port
</s> add matches := hardwareReportsReg.FindAllSubmatch(out, -1)
for _, m := range matches {
reports[string(m[2])] = string(m[1]) </s> remove func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
h := hardwarePortInfo{}
</s> add // hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") </s> remove _, out, err := aghos.RunCommand("networksetup", "-getinfo", hardwarePort)
</s> add func getHardwarePortInfo(hardwarePort string) (h hardwarePortInfo, err error) {
_, out, err := aghosRunCommand("networksetup", "-getinfo", hardwarePort) </s> remove m := make(map[string]string)
</s> add reports = make(map[string]string) </s> remove // First of all we should find hardware port name
</s> add // First of all we should find hardware port name. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
// hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") | <mask>
<mask> return m
<mask> }
<mask>
<mask> func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
<mask> h := hardwarePortInfo{}
<mask>
<mask> _, out, err := aghos.RunCommand("networksetup", "-getinfo", hardwarePort)
<mask> if err != nil {
<mask> return h, err
<mask> }
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove _, out, err := aghos.RunCommand("networksetup", "-getinfo", hardwarePort)
</s> add func getHardwarePortInfo(hardwarePort string) (h hardwarePortInfo, err error) {
_, out, err := aghosRunCommand("networksetup", "-getinfo", hardwarePort) </s> remove return m
</s> add return reports </s> remove func getNetworkSetupHardwareReports() map[string]string {
_, out, err := aghos.RunCommand("networksetup", "-listallhardwareports")
if err != nil {
return nil
}
re, err := regexp.Compile("Hardware Port: (.*?)\nDevice: (.*?)\n")
</s> add func getNetworkSetupHardwareReports() (reports map[string]string) {
_, out, err := aghosRunCommand("networksetup", "-listallhardwareports") </s> remove func ifaceHasStaticIP(ifaceName string) (bool, error) {
</s> add func ifaceHasStaticIP(ifaceName string) (ok bool, err error) { </s> remove // getCurrentHardwarePortInfo gets information for the specified network interface.
</s> add // getCurrentHardwarePortInfo gets information for the specified network
// interface. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
func getHardwarePortInfo(hardwarePort string) (h hardwarePortInfo, err error) {
_, out, err := aghosRunCommand("networksetup", "-getinfo", hardwarePort) | <mask>
<mask> func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
<mask> h := hardwarePortInfo{}
<mask>
<mask> _, out, err := aghos.RunCommand("networksetup", "-getinfo", hardwarePort)
<mask> if err != nil {
<mask> return h, err
<mask> }
<mask>
<mask> re := regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n")
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
h := hardwarePortInfo{}
</s> add // hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") </s> remove re := regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n")
match := re.FindStringSubmatch(out)
if len(match) == 0 {
</s> add match := hardwarePortReg.FindSubmatch(out)
if len(match) != 4 { </s> remove return m
</s> add return reports </s> remove func getNetworkSetupHardwareReports() map[string]string {
_, out, err := aghos.RunCommand("networksetup", "-listallhardwareports")
if err != nil {
return nil
}
re, err := regexp.Compile("Hardware Port: (.*?)\nDevice: (.*?)\n")
</s> add func getNetworkSetupHardwareReports() (reports map[string]string) {
_, out, err := aghosRunCommand("networksetup", "-listallhardwareports") </s> remove func ifaceHasStaticIP(ifaceName string) (bool, error) {
</s> add func ifaceHasStaticIP(ifaceName string) (ok bool, err error) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
match := hardwarePortReg.FindSubmatch(out)
if len(match) != 4 { | <mask> if err != nil {
<mask> return h, err
<mask> }
<mask>
<mask> re := regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n")
<mask>
<mask> match := re.FindStringSubmatch(out)
<mask> if len(match) == 0 {
<mask> return h, errors.Error("could not find hardware port info")
<mask> }
<mask>
<mask> h.name = hardwarePort
<mask> h.ip = match[1]
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove h.name = hardwarePort
h.ip = match[1]
h.subnet = match[2]
h.gatewayIP = match[3]
if strings.Index(out, "Manual Configuration") == 0 {
h.static = true
}
return h, nil
</s> add return hardwarePortInfo{
name: hardwarePort,
ip: string(match[1]),
subnet: string(match[2]),
gatewayIP: string(match[3]),
static: bytes.Index(out, []byte("Manual Configuration")) == 0,
}, nil </s> remove _, out, err := aghos.RunCommand("networksetup", "-getinfo", hardwarePort)
</s> add func getHardwarePortInfo(hardwarePort string) (h hardwarePortInfo, err error) {
_, out, err := aghosRunCommand("networksetup", "-getinfo", hardwarePort) </s> remove func getHardwarePortInfo(hardwarePort string) (hardwarePortInfo, error) {
h := hardwarePortInfo{}
</s> add // hardwarePortReg is the regular expression matching the lines of networksetup
// command output lines containing the port information.
var hardwarePortReg = regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n") </s> remove // First of all we should find hardware port name
</s> add // First of all we should find hardware port name. </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
return hardwarePortInfo{
name: hardwarePort,
ip: string(match[1]),
subnet: string(match[2]),
gatewayIP: string(match[3]),
static: bytes.Index(out, []byte("Manual Configuration")) == 0,
}, nil | <mask> if len(match) == 0 {
<mask> return h, errors.Error("could not find hardware port info")
<mask> }
<mask>
<mask> h.name = hardwarePort
<mask> h.ip = match[1]
<mask> h.subnet = match[2]
<mask> h.gatewayIP = match[3]
<mask>
<mask> if strings.Index(out, "Manual Configuration") == 0 {
<mask> h.static = true
<mask> }
<mask>
<mask> return h, nil
<mask> }
<mask>
<mask> func ifaceSetStaticIP(ifaceName string) (err error) {
<mask> portInfo, err := getCurrentHardwarePortInfo(ifaceName)
<mask> if err != nil {
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove re := regexp.MustCompile("IP address: (.*?)\nSubnet mask: (.*?)\nRouter: (.*?)\n")
match := re.FindStringSubmatch(out)
if len(match) == 0 {
</s> add match := hardwarePortReg.FindSubmatch(out)
if len(match) != 4 { </s> remove func ifaceHasStaticIP(ifaceName string) (bool, error) {
</s> add func ifaceHasStaticIP(ifaceName string) (ok bool, err error) { </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove // First of all we should find hardware port name
</s> add // First of all we should find hardware port name. </s> remove var netInterfaces []*NetInterface
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
return errors.Error("ip address is already static") | <mask> return err
<mask> }
<mask>
<mask> if portInfo.static {
<mask> return errors.Error("IP address is already static")
<mask> }
<mask>
<mask> dnsAddrs, err := getEtcResolvConfServers()
<mask> if err != nil {
<mask> return err
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove func getEtcResolvConfServers() ([]string, error) {
body, err := os.ReadFile("/etc/resolv.conf")
</s> add func getEtcResolvConfServers() (addrs []string, err error) {
const filename = "etc/resolv.conf"
_, err = aghos.FileWalker(func(r io.Reader) (_ []string, _ bool, err error) {
sc := bufio.NewScanner(r)
for sc.Scan() {
matches := etcResolvConfReg.FindAllStringSubmatch(sc.Text(), -1)
if len(matches) == 0 {
continue
}
for _, m := range matches {
addrs = append(addrs, m[1])
}
}
return nil, false, sc.Err()
}).Walk(rootDirFS, filename) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove fields := strings.Fields(string(d))
</s> add fields := bytes.Fields(out) </s> remove func GatewayIP(ifaceName string) net.IP {
cmd := exec.Command("ip", "route", "show", "dev", ifaceName)
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
d, err := cmd.Output()
if err != nil || cmd.ProcessState.ExitCode() != 0 {
</s> add //
// TODO(e.burkov): Investigate if the gateway address may be fetched in another
// way since not every machine has the software installed.
func GatewayIP(ifaceName string) (ip net.IP) {
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
if err != nil {
log.Debug("%s", err)
return nil
} else if code != 0 {
log.Debug("fetching gateway ip: unexpected exit code: %d", code)
</s> remove if errors.As(err, new(*exec.ExitError)) {
return cmd.ProcessState.ExitCode(), string(out), nil
} else if err != nil {
return 1, "", fmt.Errorf("command %q failed: %w: %s", command, err, out)
</s> add if err != nil {
if eerr := new(exec.ExitError); errors.As(err, &eerr) {
return eerr.ExitCode(), eerr.Stderr, nil
}
return 1, nil, fmt.Errorf("command %q failed: %w: %s", command, err, out) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
args := append([]string{"-setdnsservers", portInfo.name}, dnsAddrs...) | <mask> if err != nil {
<mask> return err
<mask> }
<mask>
<mask> args := make([]string, 0)
<mask> args = append(args, "-setdnsservers", portInfo.name)
<mask> args = append(args, dnsAddrs...)
<mask>
<mask> // Setting DNS servers is necessary when configuring a static IP
<mask> code, _, err := aghos.RunCommand("networksetup", args...)
<mask> if err != nil {
<mask> return err
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove code, _, err := aghos.RunCommand("networksetup", args...)
</s> add code, _, err := aghosRunCommand("networksetup", args...) </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove code, _, err = aghos.RunCommand("networksetup", "-setmanual",
portInfo.name, portInfo.ip, portInfo.subnet, portInfo.gatewayIP)
</s> add code, _, err = aghosRunCommand(
"networksetup",
"-setmanual",
portInfo.name,
portInfo.ip,
portInfo.subnet,
portInfo.gatewayIP,
) </s> remove return nil, err
}
re := regexp.MustCompile("nameserver ([a-zA-Z0-9.:]+)")
matches := re.FindAllStringSubmatch(string(body), -1)
if len(matches) == 0 {
return nil, errors.Error("found no DNS servers in /etc/resolv.conf")
}
addrs := make([]string, 0)
for i := range matches {
addrs = append(addrs, matches[i][1])
</s> add return nil, fmt.Errorf("parsing etc/resolv.conf file: %w", err)
} else if len(addrs) == 0 {
return nil, fmt.Errorf("found no dns servers in %s", filename) </s> remove }
if code != 0 {
</s> add } else if code != 0 { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
code, _, err := aghosRunCommand("networksetup", args...) | <mask> args = append(args, "-setdnsservers", portInfo.name)
<mask> args = append(args, dnsAddrs...)
<mask>
<mask> // Setting DNS servers is necessary when configuring a static IP
<mask> code, _, err := aghos.RunCommand("networksetup", args...)
<mask> if err != nil {
<mask> return err
<mask> }
<mask> if code != 0 {
<mask> return fmt.Errorf("failed to set DNS servers, code=%d", code)
</s> Pull request: 2846 cover aghnet vol.3
Merge in DNS/adguard-home from 2846-cover-aghnet-vol.3 to master
Updates #2846.
Squashed commit of the following:
commit cb22987c43c17bbc8d098e65639cc84e2284bc7b
Merge: cf995e9d f31ffcc5
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 30 15:01:10 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit cf995e9dce635f16e10406a61e2ab12f06407f1f
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:29:50 2022 +0300
aghnet: imp tests
commit bc225fe8800633b29216840bc7d5b82d7c2d2bfb
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 18:03:06 2022 +0300
aghnet: imp tests
commit a82eb6045495b94a2e81ced9a3ef5bfe65788e56
Merge: f8081249 0d562a7b
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:39:13 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit f80812490c49f69655d409c6f015b069affa2f19
Merge: edccaa79 3603b1fc
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 17:29:20 2022 +0300
Merge branch 'master' into 2846-cover-aghnet-vol.3
commit edccaa79fca061ffeea1985c293eed123b16a09c
Author: Eugene Burkov <[email protected]>
Date: Mon Mar 28 13:53:40 2022 +0300
aghnet: imp tests
commit 7c5028c92f0a6680516bda67c73e794182c9b825
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 18:01:28 2022 +0300
aghnet: imp code & docs
commit 7897c6b13e9be340ae8a71947a8a0bab82c682eb
Author: Eugene Burkov <[email protected]>
Date: Fri Mar 25 17:11:46 2022 +0300
aghnet: imp coverage
commit 1eef110af3bf721a0275c695bf27c31815abff04
Author: Eugene Burkov <[email protected]>
Date: Wed Mar 23 21:10:29 2022 +0300
all: return byte slice </s> remove args := make([]string, 0)
args = append(args, "-setdnsservers", portInfo.name)
args = append(args, dnsAddrs...)
</s> add args := append([]string{"-setdnsservers", portInfo.name}, dnsAddrs...) </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove code, _, err = aghos.RunCommand("networksetup", "-setmanual",
portInfo.name, portInfo.ip, portInfo.subnet, portInfo.gatewayIP)
</s> add code, _, err = aghosRunCommand(
"networksetup",
"-setmanual",
portInfo.name,
portInfo.ip,
portInfo.subnet,
portInfo.gatewayIP,
) </s> remove }
if code != 0 {
</s> add } else if code != 0 { </s> remove // runCmd runs the cmd with it's args and returns the result wrapped to be an
// io.Reader. The error is returned either if the exit code retured by command
// not equals 0 or the execution itself failed.
func runCmd(cmd string, args ...string) (r io.Reader, err error) {
var code int
var out string
code, out, err = aghos.RunCommand(cmd, args...)
if err != nil {
return nil, err
} else if code != 0 {
return nil, fmt.Errorf("unexpected exit code %d", code)
}
return strings.NewReader(out), nil
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/5e71f5df6a8cd12a65fecd2f1e28b2aa69609193 | internal/aghnet/net_darwin.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.