Bump github.com/miekg/dns from 1.1.50 to 1.1.52

Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.50 to 1.1.52.
- [Release notes](https://github.com/miekg/dns/releases)
- [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
- [Commits](https://github.com/miekg/dns/compare/v1.1.50...v1.1.52)

---
updated-dependencies:
- dependency-name: github.com/miekg/dns
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot] 2023-03-13 03:59:30 +00:00 committed by GitHub
parent 15c87a68a1
commit f56c77aaef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
67 changed files with 1519 additions and 408 deletions

6
go.mod
View file

@ -18,7 +18,7 @@ require (
github.com/jedisct1/xsecretbox v0.0.0-20230211185120-2025cdbb9f0f github.com/jedisct1/xsecretbox v0.0.0-20230211185120-2025cdbb9f0f
github.com/k-sone/critbitgo v1.4.0 github.com/k-sone/critbitgo v1.4.0
github.com/kardianos/service v1.2.2 github.com/kardianos/service v1.2.2
github.com/miekg/dns v1.1.50 github.com/miekg/dns v1.1.52
github.com/powerman/check v1.6.0 github.com/powerman/check v1.6.0
github.com/quic-go/quic-go v0.33.0 github.com/quic-go/quic-go v0.33.0
golang.org/x/crypto v0.6.0 golang.org/x/crypto v0.6.0
@ -161,9 +161,9 @@ require (
github.com/uudashr/gocognit v1.0.1 // indirect github.com/uudashr/gocognit v1.0.1 // indirect
github.com/yeya24/promlinter v0.1.0 // indirect github.com/yeya24/promlinter v0.1.0 // indirect
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
golang.org/x/mod v0.6.0 // indirect golang.org/x/mod v0.7.0 // indirect
golang.org/x/text v0.7.0 // indirect golang.org/x/text v0.7.0 // indirect
golang.org/x/tools v0.2.0 // indirect golang.org/x/tools v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20200707001353-8e8330bf89df // indirect google.golang.org/genproto v0.0.0-20200707001353-8e8330bf89df // indirect
google.golang.org/grpc v1.38.0 // indirect google.golang.org/grpc v1.38.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect google.golang.org/protobuf v1.28.0 // indirect

17
go.sum
View file

@ -469,8 +469,8 @@ github.com/mgechev/revive v1.0.7 h1:5kEWTY/W5a0Eiqnkn2BAWsRZpxbs1ft15PsyNC7Rml8=
github.com/mgechev/revive v1.0.7/go.mod h1:vuE5ox/4L/HDd63MCcCk3H6wTLQ6XXezRphJ8cJJOxY= github.com/mgechev/revive v1.0.7/go.mod h1:vuE5ox/4L/HDd63MCcCk3H6wTLQ6XXezRphJ8cJJOxY=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA= github.com/miekg/dns v1.1.52 h1:Bmlc/qsNNULOe6bpXcUTsuOajd0DzRHwup6D9k1An0c=
github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= github.com/miekg/dns v1.1.52/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY=
github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
@ -777,8 +777,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -820,7 +820,6 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@ -893,10 +892,8 @@ golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
@ -907,7 +904,6 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@ -1001,9 +997,8 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM=
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

49
vendor/github.com/miekg/dns/LICENSE generated vendored
View file

@ -1,30 +1,29 @@
Copyright (c) 2009 The Go Authors. All rights reserved. BSD 3-Clause License
Copyright (c) 2009, The Go Authors. Extensions copyright (c) 2011, Miek Gieben.
All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are modification, are permitted provided that the following conditions are met:
met:
* Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright notice, this
notice, this list of conditions and the following disclaimer. list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2. Redistributions in binary form must reproduce the above copyright notice,
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT this list of conditions and the following disclaimer in the documentation
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR and/or other materials provided with the distribution.
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3. Neither the name of the copyright holder nor the names of its
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT contributors may be used to endorse or promote products derived from
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, this software without specific prior written permission.
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
As this is fork of the official Go code the same license applies.
Extensions of the original work are copyright (c) 2011 Miek Gieben

View file

@ -77,6 +77,10 @@ A not-so-up-to-date-list-that-may-be-actually-current:
* https://ping.sx/dig * https://ping.sx/dig
* https://fleetdeck.io/ * https://fleetdeck.io/
* https://github.com/markdingo/autoreverse * https://github.com/markdingo/autoreverse
* https://github.com/slackhq/nebula
* https://github.com/dnschecktool/dow-proxy
* https://dnscheck.tools/
* https://github.com/egbakou/domainverifier
Send pull request if you want to be listed here. Send pull request if you want to be listed here.
@ -140,6 +144,7 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
* 340{1,2,3} - NAPTR record * 340{1,2,3} - NAPTR record
* 3445 - Limiting the scope of (DNS)KEY * 3445 - Limiting the scope of (DNS)KEY
* 3597 - Unknown RRs * 3597 - Unknown RRs
* 4025 - A Method for Storing IPsec Keying Material in DNS
* 403{3,4,5} - DNSSEC + validation functions * 403{3,4,5} - DNSSEC + validation functions
* 4255 - SSHFP record * 4255 - SSHFP record
* 4343 - Case insensitivity * 4343 - Case insensitivity
@ -175,6 +180,7 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
* 8080 - EdDSA for DNSSEC * 8080 - EdDSA for DNSSEC
* 8499 - DNS Terminology * 8499 - DNS Terminology
* 8659 - DNS Certification Authority Authorization (CAA) Resource Record * 8659 - DNS Certification Authority Authorization (CAA) Resource Record
* 8777 - DNS Reverse IP Automatic Multicast Tunneling (AMT) Discovery
* 8914 - Extended DNS Errors * 8914 - Extended DNS Errors
* 8976 - Message Digest for DNS Zones (ZONEMD RR) * 8976 - Message Digest for DNS Zones (ZONEMD RR)

View file

@ -19,7 +19,6 @@ type MsgAcceptFunc func(dh Header) MsgAcceptAction
// * has more than 0 RRs in the Authority section // * has more than 0 RRs in the Authority section
// //
// * has more than 2 RRs in the Additional section // * has more than 2 RRs in the Additional section
//
var DefaultMsgAcceptFunc MsgAcceptFunc = defaultMsgAcceptFunc var DefaultMsgAcceptFunc MsgAcceptFunc = defaultMsgAcceptFunc
// MsgAcceptAction represents the action to be taken. // MsgAcceptAction represents the action to be taken.

View file

@ -106,7 +106,6 @@ func (c *Client) Dial(address string) (conn *Conn, err error) {
} }
// DialContext connects to the address on the named network, with a context.Context. // DialContext connects to the address on the named network, with a context.Context.
// For TLS over TCP (DoT) the context isn't used yet. This will be enabled when Go 1.18 is released.
func (c *Client) DialContext(ctx context.Context, address string) (conn *Conn, err error) { func (c *Client) DialContext(ctx context.Context, address string) (conn *Conn, err error) {
// create a new dialer with the appropriate timeout // create a new dialer with the appropriate timeout
var d net.Dialer var d net.Dialer
@ -127,15 +126,11 @@ func (c *Client) DialContext(ctx context.Context, address string) (conn *Conn, e
if useTLS { if useTLS {
network = strings.TrimSuffix(network, "-tls") network = strings.TrimSuffix(network, "-tls")
// TODO(miekg): Enable after Go 1.18 is released, to be able to support two prev. releases. tlsDialer := tls.Dialer{
/* NetDialer: &d,
tlsDialer := tls.Dialer{ Config: c.TLSConfig,
NetDialer: &d, }
Config: c.TLSConfig, conn.Conn, err = tlsDialer.DialContext(ctx, network, address)
}
conn.Conn, err = tlsDialer.DialContext(ctx, network, address)
*/
conn.Conn, err = tls.DialWithDialer(&d, network, address, c.TLSConfig)
} else { } else {
conn.Conn, err = d.DialContext(ctx, network, address) conn.Conn, err = d.DialContext(ctx, network, address)
} }
@ -185,7 +180,7 @@ func (c *Client) Exchange(m *Msg, address string) (r *Msg, rtt time.Duration, er
// that entails when using "tcp" and especially "tcp-tls" clients. // that entails when using "tcp" and especially "tcp-tls" clients.
// //
// When the singleflight is set for this client the context is _not_ forwarded to the (shared) exchange, to // When the singleflight is set for this client the context is _not_ forwarded to the (shared) exchange, to
// prevent one cancelation from canceling all outstanding requests. // prevent one cancellation from canceling all outstanding requests.
func (c *Client) ExchangeWithConn(m *Msg, conn *Conn) (r *Msg, rtt time.Duration, err error) { func (c *Client) ExchangeWithConn(m *Msg, conn *Conn) (r *Msg, rtt time.Duration, err error) {
return c.exchangeWithConnContext(context.Background(), m, conn) return c.exchangeWithConnContext(context.Background(), m, conn)
} }
@ -198,7 +193,7 @@ func (c *Client) exchangeWithConnContext(ctx context.Context, m *Msg, conn *Conn
q := m.Question[0] q := m.Question[0]
key := fmt.Sprintf("%s:%d:%d", q.Name, q.Qtype, q.Qclass) key := fmt.Sprintf("%s:%d:%d", q.Name, q.Qtype, q.Qclass)
r, rtt, err, shared := c.group.Do(key, func() (*Msg, time.Duration, error) { r, rtt, err, shared := c.group.Do(key, func() (*Msg, time.Duration, error) {
// When we're doing singleflight we don't want one context cancelation, cancel _all_ outstanding queries. // When we're doing singleflight we don't want one context cancellation, cancel _all_ outstanding queries.
// Hence we ignore the context and use Background(). // Hence we ignore the context and use Background().
return c.exchangeContext(context.Background(), m, conn) return c.exchangeContext(context.Background(), m, conn)
}) })
@ -431,7 +426,6 @@ func ExchangeContext(ctx context.Context, m *Msg, a string) (r *Msg, err error)
// co.WriteMsg(m) // co.WriteMsg(m)
// in, _ := co.ReadMsg() // in, _ := co.ReadMsg()
// co.Close() // co.Close()
//
func ExchangeConn(c net.Conn, m *Msg) (r *Msg, err error) { func ExchangeConn(c net.Conn, m *Msg) (r *Msg, err error) {
println("dns: ExchangeConn: this function is deprecated") println("dns: ExchangeConn: this function is deprecated")
co := new(Conn) co := new(Conn)

View file

@ -68,7 +68,7 @@ func ClientConfigFromReader(resolvconf io.Reader) (*ClientConfig, error) {
} }
case "search": // set search path to given servers case "search": // set search path to given servers
c.Search = append([]string(nil), f[1:]...) c.Search = cloneSlice(f[1:])
case "options": // magic options case "options": // magic options
for _, s := range f[1:] { for _, s := range f[1:] {

86
vendor/github.com/miekg/dns/doc.go generated vendored
View file

@ -13,28 +13,28 @@ names in a message will result in a packing failure.
Resource records are native types. They are not stored in wire format. Basic Resource records are native types. They are not stored in wire format. Basic
usage pattern for creating a new resource record: usage pattern for creating a new resource record:
r := new(dns.MX) r := new(dns.MX)
r.Hdr = dns.RR_Header{Name: "miek.nl.", Rrtype: dns.TypeMX, Class: dns.ClassINET, Ttl: 3600} r.Hdr = dns.RR_Header{Name: "miek.nl.", Rrtype: dns.TypeMX, Class: dns.ClassINET, Ttl: 3600}
r.Preference = 10 r.Preference = 10
r.Mx = "mx.miek.nl." r.Mx = "mx.miek.nl."
Or directly from a string: Or directly from a string:
mx, err := dns.NewRR("miek.nl. 3600 IN MX 10 mx.miek.nl.") mx, err := dns.NewRR("miek.nl. 3600 IN MX 10 mx.miek.nl.")
Or when the default origin (.) and TTL (3600) and class (IN) suit you: Or when the default origin (.) and TTL (3600) and class (IN) suit you:
mx, err := dns.NewRR("miek.nl MX 10 mx.miek.nl") mx, err := dns.NewRR("miek.nl MX 10 mx.miek.nl")
Or even: Or even:
mx, err := dns.NewRR("$ORIGIN nl.\nmiek 1H IN MX 10 mx.miek") mx, err := dns.NewRR("$ORIGIN nl.\nmiek 1H IN MX 10 mx.miek")
In the DNS messages are exchanged, these messages contain resource records In the DNS messages are exchanged, these messages contain resource records
(sets). Use pattern for creating a message: (sets). Use pattern for creating a message:
m := new(dns.Msg) m := new(dns.Msg)
m.SetQuestion("miek.nl.", dns.TypeMX) m.SetQuestion("miek.nl.", dns.TypeMX)
Or when not certain if the domain name is fully qualified: Or when not certain if the domain name is fully qualified:
@ -45,17 +45,17 @@ records for the miek.nl. zone.
The following is slightly more verbose, but more flexible: The following is slightly more verbose, but more flexible:
m1 := new(dns.Msg) m1 := new(dns.Msg)
m1.Id = dns.Id() m1.Id = dns.Id()
m1.RecursionDesired = true m1.RecursionDesired = true
m1.Question = make([]dns.Question, 1) m1.Question = make([]dns.Question, 1)
m1.Question[0] = dns.Question{"miek.nl.", dns.TypeMX, dns.ClassINET} m1.Question[0] = dns.Question{"miek.nl.", dns.TypeMX, dns.ClassINET}
After creating a message it can be sent. Basic use pattern for synchronous After creating a message it can be sent. Basic use pattern for synchronous
querying the DNS at a server configured on 127.0.0.1 and port 53: querying the DNS at a server configured on 127.0.0.1 and port 53:
c := new(dns.Client) c := new(dns.Client)
in, rtt, err := c.Exchange(m1, "127.0.0.1:53") in, rtt, err := c.Exchange(m1, "127.0.0.1:53")
Suppressing multiple outstanding queries (with the same question, type and Suppressing multiple outstanding queries (with the same question, type and
class) is as easy as setting: class) is as easy as setting:
@ -72,7 +72,7 @@ and port to use for the connection:
Port: 12345, Port: 12345,
Zone: "", Zone: "",
} }
c.Dialer := &net.Dialer{ c.Dialer = &net.Dialer{
Timeout: 200 * time.Millisecond, Timeout: 200 * time.Millisecond,
LocalAddr: &laddr, LocalAddr: &laddr,
} }
@ -96,7 +96,7 @@ the Answer section:
// do something with t.Txt // do something with t.Txt
} }
Domain Name and TXT Character String Representations # Domain Name and TXT Character String Representations
Both domain names and TXT character strings are converted to presentation form Both domain names and TXT character strings are converted to presentation form
both when unpacked and when converted to strings. both when unpacked and when converted to strings.
@ -108,7 +108,7 @@ be escaped. Bytes below 32 and above 127 will be converted to \DDD form.
For domain names, in addition to the above rules brackets, periods, spaces, For domain names, in addition to the above rules brackets, periods, spaces,
semicolons and the at symbol are escaped. semicolons and the at symbol are escaped.
DNSSEC # DNSSEC
DNSSEC (DNS Security Extension) adds a layer of security to the DNS. It uses DNSSEC (DNS Security Extension) adds a layer of security to the DNS. It uses
public key cryptography to sign resource records. The public keys are stored in public key cryptography to sign resource records. The public keys are stored in
@ -117,12 +117,12 @@ DNSKEY records and the signatures in RRSIG records.
Requesting DNSSEC information for a zone is done by adding the DO (DNSSEC OK) Requesting DNSSEC information for a zone is done by adding the DO (DNSSEC OK)
bit to a request. bit to a request.
m := new(dns.Msg) m := new(dns.Msg)
m.SetEdns0(4096, true) m.SetEdns0(4096, true)
Signature generation, signature verification and key generation are all supported. Signature generation, signature verification and key generation are all supported.
DYNAMIC UPDATES # DYNAMIC UPDATES
Dynamic updates reuses the DNS message format, but renames three of the Dynamic updates reuses the DNS message format, but renames three of the
sections. Question is Zone, Answer is Prerequisite, Authority is Update, only sections. Question is Zone, Answer is Prerequisite, Authority is Update, only
@ -133,30 +133,30 @@ certain resource records or names in a zone to specify if resource records
should be added or removed. The table from RFC 2136 supplemented with the Go should be added or removed. The table from RFC 2136 supplemented with the Go
DNS function shows which functions exist to specify the prerequisites. DNS function shows which functions exist to specify the prerequisites.
3.2.4 - Table Of Metavalues Used In Prerequisite Section 3.2.4 - Table Of Metavalues Used In Prerequisite Section
CLASS TYPE RDATA Meaning Function CLASS TYPE RDATA Meaning Function
-------------------------------------------------------------- --------------------------------------------------------------
ANY ANY empty Name is in use dns.NameUsed ANY ANY empty Name is in use dns.NameUsed
ANY rrset empty RRset exists (value indep) dns.RRsetUsed ANY rrset empty RRset exists (value indep) dns.RRsetUsed
NONE ANY empty Name is not in use dns.NameNotUsed NONE ANY empty Name is not in use dns.NameNotUsed
NONE rrset empty RRset does not exist dns.RRsetNotUsed NONE rrset empty RRset does not exist dns.RRsetNotUsed
zone rrset rr RRset exists (value dep) dns.Used zone rrset rr RRset exists (value dep) dns.Used
The prerequisite section can also be left empty. If you have decided on the The prerequisite section can also be left empty. If you have decided on the
prerequisites you can tell what RRs should be added or deleted. The next table prerequisites you can tell what RRs should be added or deleted. The next table
shows the options you have and what functions to call. shows the options you have and what functions to call.
3.4.2.6 - Table Of Metavalues Used In Update Section 3.4.2.6 - Table Of Metavalues Used In Update Section
CLASS TYPE RDATA Meaning Function CLASS TYPE RDATA Meaning Function
--------------------------------------------------------------- ---------------------------------------------------------------
ANY ANY empty Delete all RRsets from name dns.RemoveName ANY ANY empty Delete all RRsets from name dns.RemoveName
ANY rrset empty Delete an RRset dns.RemoveRRset ANY rrset empty Delete an RRset dns.RemoveRRset
NONE rrset rr Delete an RR from RRset dns.Remove NONE rrset rr Delete an RR from RRset dns.Remove
zone rrset rr Add to an RRset dns.Insert zone rrset rr Add to an RRset dns.Insert
TRANSACTION SIGNATURE # TRANSACTION SIGNATURE
An TSIG or transaction signature adds a HMAC TSIG record to each message sent. An TSIG or transaction signature adds a HMAC TSIG record to each message sent.
The supported algorithms include: HmacSHA1, HmacSHA256 and HmacSHA512. The supported algorithms include: HmacSHA1, HmacSHA256 and HmacSHA512.
@ -239,7 +239,7 @@ Basic use pattern validating and replying to a message that has TSIG set.
w.WriteMsg(m) w.WriteMsg(m)
} }
PRIVATE RRS # PRIVATE RRS
RFC 6895 sets aside a range of type codes for private use. This range is 65,280 RFC 6895 sets aside a range of type codes for private use. This range is 65,280
- 65,534 (0xFF00 - 0xFFFE). When experimenting with new Resource Records these - 65,534 (0xFF00 - 0xFFFE). When experimenting with new Resource Records these
@ -248,7 +248,7 @@ can be used, before requesting an official type code from IANA.
See https://miek.nl/2014/september/21/idn-and-private-rr-in-go-dns/ for more See https://miek.nl/2014/september/21/idn-and-private-rr-in-go-dns/ for more
information. information.
EDNS0 # EDNS0
EDNS0 is an extension mechanism for the DNS defined in RFC 2671 and updated by EDNS0 is an extension mechanism for the DNS defined in RFC 2671 and updated by
RFC 6891. It defines a new RR type, the OPT RR, which is then completely RFC 6891. It defines a new RR type, the OPT RR, which is then completely
@ -279,9 +279,9 @@ SIG(0)
From RFC 2931: From RFC 2931:
SIG(0) provides protection for DNS transactions and requests .... SIG(0) provides protection for DNS transactions and requests ....
... protection for glue records, DNS requests, protection for message headers ... protection for glue records, DNS requests, protection for message headers
on requests and responses, and protection of the overall integrity of a response. on requests and responses, and protection of the overall integrity of a response.
It works like TSIG, except that SIG(0) uses public key cryptography, instead of It works like TSIG, except that SIG(0) uses public key cryptography, instead of
the shared secret approach in TSIG. Supported algorithms: ECDSAP256SHA256, the shared secret approach in TSIG. Supported algorithms: ECDSAP256SHA256,

52
vendor/github.com/miekg/dns/edns.go generated vendored
View file

@ -78,7 +78,10 @@ func (rr *OPT) String() string {
if rr.Do() { if rr.Do() {
s += "flags: do; " s += "flags: do; "
} else { } else {
s += "flags: ; " s += "flags:; "
}
if rr.Hdr.Ttl&0x7FFF != 0 {
s += fmt.Sprintf("MBZ: 0x%04x, ", rr.Hdr.Ttl&0x7FFF)
} }
s += "udp: " + strconv.Itoa(int(rr.UDPSize())) s += "udp: " + strconv.Itoa(int(rr.UDPSize()))
@ -98,6 +101,8 @@ func (rr *OPT) String() string {
s += "\n; SUBNET: " + o.String() s += "\n; SUBNET: " + o.String()
case *EDNS0_COOKIE: case *EDNS0_COOKIE:
s += "\n; COOKIE: " + o.String() s += "\n; COOKIE: " + o.String()
case *EDNS0_EXPIRE:
s += "\n; EXPIRE: " + o.String()
case *EDNS0_TCP_KEEPALIVE: case *EDNS0_TCP_KEEPALIVE:
s += "\n; KEEPALIVE: " + o.String() s += "\n; KEEPALIVE: " + o.String()
case *EDNS0_UL: case *EDNS0_UL:
@ -258,7 +263,7 @@ func (e *EDNS0_NSID) copy() EDNS0 { return &EDNS0_NSID{e.Code, e.Nsid}
// o.Hdr.Name = "." // o.Hdr.Name = "."
// o.Hdr.Rrtype = dns.TypeOPT // o.Hdr.Rrtype = dns.TypeOPT
// e := new(dns.EDNS0_SUBNET) // e := new(dns.EDNS0_SUBNET)
// e.Code = dns.EDNS0SUBNET // e.Code = dns.EDNS0SUBNET // by default this is filled in through unpacking OPT packets (unpackDataOpt)
// e.Family = 1 // 1 for IPv4 source address, 2 for IPv6 // e.Family = 1 // 1 for IPv4 source address, 2 for IPv6
// e.SourceNetmask = 32 // 32 for IPV4, 128 for IPv6 // e.SourceNetmask = 32 // 32 for IPV4, 128 for IPv6
// e.SourceScope = 0 // e.SourceScope = 0
@ -515,8 +520,8 @@ type EDNS0_DAU struct {
// Option implements the EDNS0 interface. // Option implements the EDNS0 interface.
func (e *EDNS0_DAU) Option() uint16 { return EDNS0DAU } func (e *EDNS0_DAU) Option() uint16 { return EDNS0DAU }
func (e *EDNS0_DAU) pack() ([]byte, error) { return e.AlgCode, nil } func (e *EDNS0_DAU) pack() ([]byte, error) { return cloneSlice(e.AlgCode), nil }
func (e *EDNS0_DAU) unpack(b []byte) error { e.AlgCode = b; return nil } func (e *EDNS0_DAU) unpack(b []byte) error { e.AlgCode = cloneSlice(b); return nil }
func (e *EDNS0_DAU) String() string { func (e *EDNS0_DAU) String() string {
s := "" s := ""
@ -539,8 +544,8 @@ type EDNS0_DHU struct {
// Option implements the EDNS0 interface. // Option implements the EDNS0 interface.
func (e *EDNS0_DHU) Option() uint16 { return EDNS0DHU } func (e *EDNS0_DHU) Option() uint16 { return EDNS0DHU }
func (e *EDNS0_DHU) pack() ([]byte, error) { return e.AlgCode, nil } func (e *EDNS0_DHU) pack() ([]byte, error) { return cloneSlice(e.AlgCode), nil }
func (e *EDNS0_DHU) unpack(b []byte) error { e.AlgCode = b; return nil } func (e *EDNS0_DHU) unpack(b []byte) error { e.AlgCode = cloneSlice(b); return nil }
func (e *EDNS0_DHU) String() string { func (e *EDNS0_DHU) String() string {
s := "" s := ""
@ -563,8 +568,8 @@ type EDNS0_N3U struct {
// Option implements the EDNS0 interface. // Option implements the EDNS0 interface.
func (e *EDNS0_N3U) Option() uint16 { return EDNS0N3U } func (e *EDNS0_N3U) Option() uint16 { return EDNS0N3U }
func (e *EDNS0_N3U) pack() ([]byte, error) { return e.AlgCode, nil } func (e *EDNS0_N3U) pack() ([]byte, error) { return cloneSlice(e.AlgCode), nil }
func (e *EDNS0_N3U) unpack(b []byte) error { e.AlgCode = b; return nil } func (e *EDNS0_N3U) unpack(b []byte) error { e.AlgCode = cloneSlice(b); return nil }
func (e *EDNS0_N3U) String() string { func (e *EDNS0_N3U) String() string {
// Re-use the hash map // Re-use the hash map
@ -641,30 +646,21 @@ type EDNS0_LOCAL struct {
// Option implements the EDNS0 interface. // Option implements the EDNS0 interface.
func (e *EDNS0_LOCAL) Option() uint16 { return e.Code } func (e *EDNS0_LOCAL) Option() uint16 { return e.Code }
func (e *EDNS0_LOCAL) String() string { func (e *EDNS0_LOCAL) String() string {
return strconv.FormatInt(int64(e.Code), 10) + ":0x" + hex.EncodeToString(e.Data) return strconv.FormatInt(int64(e.Code), 10) + ":0x" + hex.EncodeToString(e.Data)
} }
func (e *EDNS0_LOCAL) copy() EDNS0 { func (e *EDNS0_LOCAL) copy() EDNS0 {
b := make([]byte, len(e.Data)) return &EDNS0_LOCAL{e.Code, cloneSlice(e.Data)}
copy(b, e.Data)
return &EDNS0_LOCAL{e.Code, b}
} }
func (e *EDNS0_LOCAL) pack() ([]byte, error) { func (e *EDNS0_LOCAL) pack() ([]byte, error) {
b := make([]byte, len(e.Data)) return cloneSlice(e.Data), nil
copied := copy(b, e.Data)
if copied != len(e.Data) {
return nil, ErrBuf
}
return b, nil
} }
func (e *EDNS0_LOCAL) unpack(b []byte) error { func (e *EDNS0_LOCAL) unpack(b []byte) error {
e.Data = make([]byte, len(b)) e.Data = cloneSlice(b)
copied := copy(e.Data, b)
if copied != len(b) {
return ErrBuf
}
return nil return nil
} }
@ -727,14 +723,10 @@ type EDNS0_PADDING struct {
// Option implements the EDNS0 interface. // Option implements the EDNS0 interface.
func (e *EDNS0_PADDING) Option() uint16 { return EDNS0PADDING } func (e *EDNS0_PADDING) Option() uint16 { return EDNS0PADDING }
func (e *EDNS0_PADDING) pack() ([]byte, error) { return e.Padding, nil } func (e *EDNS0_PADDING) pack() ([]byte, error) { return cloneSlice(e.Padding), nil }
func (e *EDNS0_PADDING) unpack(b []byte) error { e.Padding = b; return nil } func (e *EDNS0_PADDING) unpack(b []byte) error { e.Padding = cloneSlice(b); return nil }
func (e *EDNS0_PADDING) String() string { return fmt.Sprintf("%0X", e.Padding) } func (e *EDNS0_PADDING) String() string { return fmt.Sprintf("%0X", e.Padding) }
func (e *EDNS0_PADDING) copy() EDNS0 { func (e *EDNS0_PADDING) copy() EDNS0 { return &EDNS0_PADDING{cloneSlice(e.Padding)} }
b := make([]byte, len(e.Padding))
copy(b, e.Padding)
return &EDNS0_PADDING{b}
}
// Extended DNS Error Codes (RFC 8914). // Extended DNS Error Codes (RFC 8914).
const ( const (
@ -821,7 +813,7 @@ func (e *EDNS0_EDE) String() string {
func (e *EDNS0_EDE) pack() ([]byte, error) { func (e *EDNS0_EDE) pack() ([]byte, error) {
b := make([]byte, 2+len(e.ExtraText)) b := make([]byte, 2+len(e.ExtraText))
binary.BigEndian.PutUint16(b[0:], e.InfoCode) binary.BigEndian.PutUint16(b[0:], e.InfoCode)
copy(b[2:], []byte(e.ExtraText)) copy(b[2:], e.ExtraText)
return b, nil return b, nil
} }

View file

@ -1,3 +1,4 @@
//go:build fuzz
// +build fuzz // +build fuzz
package dns package dns

View file

@ -122,7 +122,7 @@ func Split(s string) []int {
} }
// NextLabel returns the index of the start of the next label in the // NextLabel returns the index of the start of the next label in the
// string s starting at offset. // string s starting at offset. A negative offset will cause a panic.
// The bool end is true when the end of the string has been reached. // The bool end is true when the end of the string has been reached.
// Also see PrevLabel. // Also see PrevLabel.
func NextLabel(s string, offset int) (i int, end bool) { func NextLabel(s string, offset int) (i int, end bool) {

View file

@ -1,4 +1,5 @@
// +build !go1.11 !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd //go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd
// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd
package dns package dns

View file

@ -1,4 +1,4 @@
// +build go1.11 //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd
// +build aix darwin dragonfly freebsd linux netbsd openbsd // +build aix darwin dragonfly freebsd linux netbsd openbsd
package dns package dns

35
vendor/github.com/miekg/dns/msg.go generated vendored
View file

@ -448,7 +448,7 @@ Loop:
return string(s), off1, nil return string(s), off1, nil
} }
func packTxt(txt []string, msg []byte, offset int, tmp []byte) (int, error) { func packTxt(txt []string, msg []byte, offset int) (int, error) {
if len(txt) == 0 { if len(txt) == 0 {
if offset >= len(msg) { if offset >= len(msg) {
return offset, ErrBuf return offset, ErrBuf
@ -458,10 +458,7 @@ func packTxt(txt []string, msg []byte, offset int, tmp []byte) (int, error) {
} }
var err error var err error
for _, s := range txt { for _, s := range txt {
if len(s) > len(tmp) { offset, err = packTxtString(s, msg, offset)
return offset, ErrBuf
}
offset, err = packTxtString(s, msg, offset, tmp)
if err != nil { if err != nil {
return offset, err return offset, err
} }
@ -469,32 +466,30 @@ func packTxt(txt []string, msg []byte, offset int, tmp []byte) (int, error) {
return offset, nil return offset, nil
} }
func packTxtString(s string, msg []byte, offset int, tmp []byte) (int, error) { func packTxtString(s string, msg []byte, offset int) (int, error) {
lenByteOffset := offset lenByteOffset := offset
if offset >= len(msg) || len(s) > len(tmp) { if offset >= len(msg) || len(s) > 256*4+1 /* If all \DDD */ {
return offset, ErrBuf return offset, ErrBuf
} }
offset++ offset++
bs := tmp[:len(s)] for i := 0; i < len(s); i++ {
copy(bs, s)
for i := 0; i < len(bs); i++ {
if len(msg) <= offset { if len(msg) <= offset {
return offset, ErrBuf return offset, ErrBuf
} }
if bs[i] == '\\' { if s[i] == '\\' {
i++ i++
if i == len(bs) { if i == len(s) {
break break
} }
// check for \DDD // check for \DDD
if i+2 < len(bs) && isDigit(bs[i]) && isDigit(bs[i+1]) && isDigit(bs[i+2]) { if i+2 < len(s) && isDigit(s[i]) && isDigit(s[i+1]) && isDigit(s[i+2]) {
msg[offset] = dddToByte(bs[i:]) msg[offset] = dddStringToByte(s[i:])
i += 2 i += 2
} else { } else {
msg[offset] = bs[i] msg[offset] = s[i]
} }
} else { } else {
msg[offset] = bs[i] msg[offset] = s[i]
} }
offset++ offset++
} }
@ -680,9 +675,9 @@ func unpackRRslice(l int, msg []byte, off int) (dst1 []RR, off1 int, err error)
// Convert a MsgHdr to a string, with dig-like headers: // Convert a MsgHdr to a string, with dig-like headers:
// //
//;; opcode: QUERY, status: NOERROR, id: 48404 // ;; opcode: QUERY, status: NOERROR, id: 48404
// //
//;; flags: qr aa rd ra; // ;; flags: qr aa rd ra;
func (h *MsgHdr) String() string { func (h *MsgHdr) String() string {
if h == nil { if h == nil {
return "<nil> MsgHdr" return "<nil> MsgHdr"
@ -1065,8 +1060,8 @@ func (dns *Msg) CopyTo(r1 *Msg) *Msg {
r1.Compress = dns.Compress r1.Compress = dns.Compress
if len(dns.Question) > 0 { if len(dns.Question) > 0 {
r1.Question = make([]Question, len(dns.Question)) // TODO(miek): Question is an immutable value, ok to do a shallow-copy
copy(r1.Question, dns.Question) // TODO(miek): Question is an immutable value, ok to do a shallow-copy r1.Question = cloneSlice(dns.Question)
} }
rrArr := make([]RR, len(dns.Answer)+len(dns.Ns)+len(dns.Extra)) rrArr := make([]RR, len(dns.Answer)+len(dns.Ns)+len(dns.Extra))

View file

@ -299,8 +299,7 @@ func unpackString(msg []byte, off int) (string, int, error) {
} }
func packString(s string, msg []byte, off int) (int, error) { func packString(s string, msg []byte, off int) (int, error) {
txtTmp := make([]byte, 256*4+1) off, err := packTxtString(s, msg, off)
off, err := packTxtString(s, msg, off, txtTmp)
if err != nil { if err != nil {
return len(msg), err return len(msg), err
} }
@ -402,8 +401,7 @@ func unpackStringTxt(msg []byte, off int) ([]string, int, error) {
} }
func packStringTxt(s []string, msg []byte, off int) (int, error) { func packStringTxt(s []string, msg []byte, off int) (int, error) {
txtTmp := make([]byte, 256*4+1) // If the whole string consists out of \DDD we need this many. off, err := packTxt(s, msg, off)
off, err := packTxt(s, msg, off, txtTmp)
if err != nil { if err != nil {
return len(msg), err return len(msg), err
} }
@ -625,7 +623,7 @@ func unpackDataSVCB(msg []byte, off int) ([]SVCBKeyValue, int, error) {
} }
func packDataSVCB(pairs []SVCBKeyValue, msg []byte, off int) (int, error) { func packDataSVCB(pairs []SVCBKeyValue, msg []byte, off int) (int, error) {
pairs = append([]SVCBKeyValue(nil), pairs...) pairs = cloneSlice(pairs)
sort.Slice(pairs, func(i, j int) bool { sort.Slice(pairs, func(i, j int) bool {
return pairs[i].Key() < pairs[j].Key() return pairs[i].Key() < pairs[j].Key()
}) })
@ -810,3 +808,37 @@ func unpackDataAplPrefix(msg []byte, off int) (APLPrefix, int, error) {
Network: ipnet, Network: ipnet,
}, off, nil }, off, nil
} }
func unpackIPSECGateway(msg []byte, off int, gatewayType uint8) (net.IP, string, int, error) {
var retAddr net.IP
var retString string
var err error
switch gatewayType {
case IPSECGatewayNone: // do nothing
case IPSECGatewayIPv4:
retAddr, off, err = unpackDataA(msg, off)
case IPSECGatewayIPv6:
retAddr, off, err = unpackDataAAAA(msg, off)
case IPSECGatewayHost:
retString, off, err = UnpackDomainName(msg, off)
}
return retAddr, retString, off, err
}
func packIPSECGateway(gatewayAddr net.IP, gatewayString string, msg []byte, off int, gatewayType uint8, compression compressionMap, compress bool) (int, error) {
var err error
switch gatewayType {
case IPSECGatewayNone: // do nothing
case IPSECGatewayIPv4:
off, err = packDataA(gatewayAddr, msg, off)
case IPSECGatewayIPv6:
off, err = packDataAAAA(gatewayAddr, msg, off)
case IPSECGatewayHost:
off, err = packDomainName(gatewayString, msg, off, compression, compress)
}
return off, err
}

View file

@ -3,6 +3,7 @@ package dns
import ( import (
"bytes" "bytes"
"encoding/base64" "encoding/base64"
"errors"
"net" "net"
"strconv" "strconv"
"strings" "strings"
@ -1216,6 +1217,117 @@ func (rr *DS) parse(c *zlexer, o string) *ParseError { return rr.parseDS(c,
func (rr *DLV) parse(c *zlexer, o string) *ParseError { return rr.parseDS(c, o, "DLV") } func (rr *DLV) parse(c *zlexer, o string) *ParseError { return rr.parseDS(c, o, "DLV") }
func (rr *CDS) parse(c *zlexer, o string) *ParseError { return rr.parseDS(c, o, "CDS") } func (rr *CDS) parse(c *zlexer, o string) *ParseError { return rr.parseDS(c, o, "CDS") }
func (rr *IPSECKEY) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
num, err := strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
return &ParseError{"", "bad IPSECKEY value", l}
}
rr.Precedence = uint8(num)
c.Next() // zBlank
l, _ = c.Next()
num, err = strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
return &ParseError{"", "bad IPSECKEY value", l}
}
rr.GatewayType = uint8(num)
c.Next() // zBlank
l, _ = c.Next()
num, err = strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
return &ParseError{"", "bad IPSECKEY value", l}
}
rr.Algorithm = uint8(num)
c.Next() // zBlank
l, _ = c.Next()
if l.err {
return &ParseError{"", "bad IPSECKEY gateway", l}
}
rr.GatewayAddr, rr.GatewayHost, err = parseAddrHostUnion(l.token, o, rr.GatewayType)
if err != nil {
return &ParseError{"", "IPSECKEY " + err.Error(), l}
}
c.Next() // zBlank
s, pErr := endingToString(c, "bad IPSECKEY PublicKey")
if pErr != nil {
return pErr
}
rr.PublicKey = s
return slurpRemainder(c)
}
func (rr *AMTRELAY) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
num, err := strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
return &ParseError{"", "bad AMTRELAY value", l}
}
rr.Precedence = uint8(num)
c.Next() // zBlank
l, _ = c.Next()
if l.err || !(l.token == "0" || l.token == "1") {
return &ParseError{"", "bad discovery value", l}
}
if l.token == "1" {
rr.GatewayType = 0x80
}
c.Next() // zBlank
l, _ = c.Next()
num, err = strconv.ParseUint(l.token, 10, 8)
if err != nil || l.err {
return &ParseError{"", "bad AMTRELAY value", l}
}
rr.GatewayType |= uint8(num)
c.Next() // zBlank
l, _ = c.Next()
if l.err {
return &ParseError{"", "bad AMTRELAY gateway", l}
}
rr.GatewayAddr, rr.GatewayHost, err = parseAddrHostUnion(l.token, o, rr.GatewayType&0x7f)
if err != nil {
return &ParseError{"", "AMTRELAY " + err.Error(), l}
}
return slurpRemainder(c)
}
// same constants and parsing between IPSECKEY and AMTRELAY
func parseAddrHostUnion(token, o string, gatewayType uint8) (addr net.IP, host string, err error) {
switch gatewayType {
case IPSECGatewayNone:
if token != "." {
return addr, host, errors.New("gateway type none with gateway set")
}
case IPSECGatewayIPv4, IPSECGatewayIPv6:
addr = net.ParseIP(token)
if addr == nil {
return addr, host, errors.New("gateway IP invalid")
}
if (addr.To4() == nil) == (gatewayType == IPSECGatewayIPv4) {
return addr, host, errors.New("gateway IP family mismatch")
}
case IPSECGatewayHost:
var ok bool
host, ok = toAbsoluteName(token, o)
if !ok {
return addr, host, errors.New("invalid gateway host")
}
}
return addr, host, nil
}
func (rr *RKEY) parse(c *zlexer, o string) *ParseError { func (rr *RKEY) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next() l, _ := c.Next()
i, e := strconv.ParseUint(l.token, 10, 16) i, e := strconv.ParseUint(l.token, 10, 16)

View file

@ -18,7 +18,7 @@ import (
const maxTCPQueries = 128 const maxTCPQueries = 128
// aLongTimeAgo is a non-zero time, far in the past, used for // aLongTimeAgo is a non-zero time, far in the past, used for
// immediate cancelation of network operations. // immediate cancellation of network operations.
var aLongTimeAgo = time.Unix(1, 0) var aLongTimeAgo = time.Unix(1, 0)
// Handler is implemented by any value that implements ServeDNS. // Handler is implemented by any value that implements ServeDNS.
@ -224,7 +224,7 @@ type Server struct {
// Maximum number of TCP queries before we close the socket. Default is maxTCPQueries (unlimited if -1). // Maximum number of TCP queries before we close the socket. Default is maxTCPQueries (unlimited if -1).
MaxTCPQueries int MaxTCPQueries int
// Whether to set the SO_REUSEPORT socket option, allowing multiple listeners to be bound to a single address. // Whether to set the SO_REUSEPORT socket option, allowing multiple listeners to be bound to a single address.
// It is only supported on go1.11+ and when using ListenAndServe. // It is only supported on certain GOOSes and when using ListenAndServe.
ReusePort bool ReusePort bool
// AcceptMsgFunc will check the incoming message and will reject it early in the process. // AcceptMsgFunc will check the incoming message and will reject it early in the process.
// By default DefaultMsgAcceptFunc will be used. // By default DefaultMsgAcceptFunc will be used.

63
vendor/github.com/miekg/dns/svcb.go generated vendored
View file

@ -289,7 +289,7 @@ func (s *SVCBMandatory) String() string {
} }
func (s *SVCBMandatory) pack() ([]byte, error) { func (s *SVCBMandatory) pack() ([]byte, error) {
codes := append([]SVCBKey(nil), s.Code...) codes := cloneSlice(s.Code)
sort.Slice(codes, func(i, j int) bool { sort.Slice(codes, func(i, j int) bool {
return codes[i] < codes[j] return codes[i] < codes[j]
}) })
@ -328,9 +328,7 @@ func (s *SVCBMandatory) len() int {
} }
func (s *SVCBMandatory) copy() SVCBKeyValue { func (s *SVCBMandatory) copy() SVCBKeyValue {
return &SVCBMandatory{ return &SVCBMandatory{cloneSlice(s.Code)}
append([]SVCBKey(nil), s.Code...),
}
} }
// SVCBAlpn pair is used to list supported connection protocols. // SVCBAlpn pair is used to list supported connection protocols.
@ -353,7 +351,7 @@ func (*SVCBAlpn) Key() SVCBKey { return SVCB_ALPN }
func (s *SVCBAlpn) String() string { func (s *SVCBAlpn) String() string {
// An ALPN value is a comma-separated list of values, each of which can be // An ALPN value is a comma-separated list of values, each of which can be
// an arbitrary binary value. In order to allow parsing, the comma and // an arbitrary binary value. In order to allow parsing, the comma and
// backslash characters are themselves excaped. // backslash characters are themselves escaped.
// //
// However, this escaping is done in addition to the normal escaping which // However, this escaping is done in addition to the normal escaping which
// happens in zone files, meaning that these values must be // happens in zone files, meaning that these values must be
@ -481,9 +479,7 @@ func (s *SVCBAlpn) len() int {
} }
func (s *SVCBAlpn) copy() SVCBKeyValue { func (s *SVCBAlpn) copy() SVCBKeyValue {
return &SVCBAlpn{ return &SVCBAlpn{cloneSlice(s.Alpn)}
append([]string(nil), s.Alpn...),
}
} }
// SVCBNoDefaultAlpn pair signifies no support for default connection protocols. // SVCBNoDefaultAlpn pair signifies no support for default connection protocols.
@ -563,15 +559,15 @@ func (s *SVCBPort) parse(b string) error {
// to the hinted IP address may be terminated and a new connection may be opened. // to the hinted IP address may be terminated and a new connection may be opened.
// Basic use pattern for creating an ipv4hint option: // Basic use pattern for creating an ipv4hint option:
// //
// h := new(dns.HTTPS) // h := new(dns.HTTPS)
// h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET} // h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET}
// e := new(dns.SVCBIPv4Hint) // e := new(dns.SVCBIPv4Hint)
// e.Hint = []net.IP{net.IPv4(1,1,1,1).To4()} // e.Hint = []net.IP{net.IPv4(1,1,1,1).To4()}
// //
// Or // Or
// //
// e.Hint = []net.IP{net.ParseIP("1.1.1.1").To4()} // e.Hint = []net.IP{net.ParseIP("1.1.1.1").To4()}
// h.Value = append(h.Value, e) // h.Value = append(h.Value, e)
type SVCBIPv4Hint struct { type SVCBIPv4Hint struct {
Hint []net.IP Hint []net.IP
} }
@ -595,6 +591,7 @@ func (s *SVCBIPv4Hint) unpack(b []byte) error {
if len(b) == 0 || len(b)%4 != 0 { if len(b) == 0 || len(b)%4 != 0 {
return errors.New("dns: svcbipv4hint: ipv4 address byte array length is not a multiple of 4") return errors.New("dns: svcbipv4hint: ipv4 address byte array length is not a multiple of 4")
} }
b = cloneSlice(b)
x := make([]net.IP, 0, len(b)/4) x := make([]net.IP, 0, len(b)/4)
for i := 0; i < len(b); i += 4 { for i := 0; i < len(b); i += 4 {
x = append(x, net.IP(b[i:i+4])) x = append(x, net.IP(b[i:i+4]))
@ -635,12 +632,9 @@ func (s *SVCBIPv4Hint) parse(b string) error {
func (s *SVCBIPv4Hint) copy() SVCBKeyValue { func (s *SVCBIPv4Hint) copy() SVCBKeyValue {
hint := make([]net.IP, len(s.Hint)) hint := make([]net.IP, len(s.Hint))
for i, ip := range s.Hint { for i, ip := range s.Hint {
hint[i] = copyIP(ip) hint[i] = cloneSlice(ip)
}
return &SVCBIPv4Hint{
Hint: hint,
} }
return &SVCBIPv4Hint{Hint: hint}
} }
// SVCBECHConfig pair contains the ECHConfig structure defined in draft-ietf-tls-esni [RFC xxxx]. // SVCBECHConfig pair contains the ECHConfig structure defined in draft-ietf-tls-esni [RFC xxxx].
@ -660,19 +654,18 @@ func (s *SVCBECHConfig) String() string { return toBase64(s.ECH) }
func (s *SVCBECHConfig) len() int { return len(s.ECH) } func (s *SVCBECHConfig) len() int { return len(s.ECH) }
func (s *SVCBECHConfig) pack() ([]byte, error) { func (s *SVCBECHConfig) pack() ([]byte, error) {
return append([]byte(nil), s.ECH...), nil return cloneSlice(s.ECH), nil
} }
func (s *SVCBECHConfig) copy() SVCBKeyValue { func (s *SVCBECHConfig) copy() SVCBKeyValue {
return &SVCBECHConfig{ return &SVCBECHConfig{cloneSlice(s.ECH)}
append([]byte(nil), s.ECH...),
}
} }
func (s *SVCBECHConfig) unpack(b []byte) error { func (s *SVCBECHConfig) unpack(b []byte) error {
s.ECH = append([]byte(nil), b...) s.ECH = cloneSlice(b)
return nil return nil
} }
func (s *SVCBECHConfig) parse(b string) error { func (s *SVCBECHConfig) parse(b string) error {
x, err := fromBase64([]byte(b)) x, err := fromBase64([]byte(b))
if err != nil { if err != nil {
@ -715,6 +708,7 @@ func (s *SVCBIPv6Hint) unpack(b []byte) error {
if len(b) == 0 || len(b)%16 != 0 { if len(b) == 0 || len(b)%16 != 0 {
return errors.New("dns: svcbipv6hint: ipv6 address byte array length not a multiple of 16") return errors.New("dns: svcbipv6hint: ipv6 address byte array length not a multiple of 16")
} }
b = cloneSlice(b)
x := make([]net.IP, 0, len(b)/16) x := make([]net.IP, 0, len(b)/16)
for i := 0; i < len(b); i += 16 { for i := 0; i < len(b); i += 16 {
ip := net.IP(b[i : i+16]) ip := net.IP(b[i : i+16])
@ -758,12 +752,9 @@ func (s *SVCBIPv6Hint) parse(b string) error {
func (s *SVCBIPv6Hint) copy() SVCBKeyValue { func (s *SVCBIPv6Hint) copy() SVCBKeyValue {
hint := make([]net.IP, len(s.Hint)) hint := make([]net.IP, len(s.Hint))
for i, ip := range s.Hint { for i, ip := range s.Hint {
hint[i] = copyIP(ip) hint[i] = cloneSlice(ip)
}
return &SVCBIPv6Hint{
Hint: hint,
} }
return &SVCBIPv6Hint{Hint: hint}
} }
// SVCBDoHPath pair is used to indicate the URI template that the // SVCBDoHPath pair is used to indicate the URI template that the
@ -831,11 +822,11 @@ type SVCBLocal struct {
func (s *SVCBLocal) Key() SVCBKey { return s.KeyCode } func (s *SVCBLocal) Key() SVCBKey { return s.KeyCode }
func (s *SVCBLocal) String() string { return svcbParamToStr(s.Data) } func (s *SVCBLocal) String() string { return svcbParamToStr(s.Data) }
func (s *SVCBLocal) pack() ([]byte, error) { return append([]byte(nil), s.Data...), nil } func (s *SVCBLocal) pack() ([]byte, error) { return cloneSlice(s.Data), nil }
func (s *SVCBLocal) len() int { return len(s.Data) } func (s *SVCBLocal) len() int { return len(s.Data) }
func (s *SVCBLocal) unpack(b []byte) error { func (s *SVCBLocal) unpack(b []byte) error {
s.Data = append([]byte(nil), b...) s.Data = cloneSlice(b)
return nil return nil
} }
@ -849,9 +840,7 @@ func (s *SVCBLocal) parse(b string) error {
} }
func (s *SVCBLocal) copy() SVCBKeyValue { func (s *SVCBLocal) copy() SVCBKeyValue {
return &SVCBLocal{s.KeyCode, return &SVCBLocal{s.KeyCode, cloneSlice(s.Data)}
append([]byte(nil), s.Data...),
}
} }
func (rr *SVCB) String() string { func (rr *SVCB) String() string {
@ -867,8 +856,8 @@ func (rr *SVCB) String() string {
// areSVCBPairArraysEqual checks if SVCBKeyValue arrays are equal after sorting their // areSVCBPairArraysEqual checks if SVCBKeyValue arrays are equal after sorting their
// copies. arrA and arrB have equal lengths, otherwise zduplicate.go wouldn't call this function. // copies. arrA and arrB have equal lengths, otherwise zduplicate.go wouldn't call this function.
func areSVCBPairArraysEqual(a []SVCBKeyValue, b []SVCBKeyValue) bool { func areSVCBPairArraysEqual(a []SVCBKeyValue, b []SVCBKeyValue) bool {
a = append([]SVCBKeyValue(nil), a...) a = cloneSlice(a)
b = append([]SVCBKeyValue(nil), b...) b = cloneSlice(b)
sort.Slice(a, func(i, j int) bool { return a[i].Key() < a[j].Key() }) sort.Slice(a, func(i, j int) bool { return a[i].Key() < a[j].Key() })
sort.Slice(b, func(i, j int) bool { return b[i].Key() < b[j].Key() }) sort.Slice(b, func(i, j int) bool { return b[i].Key() < b[j].Key() })
for i, e := range a { for i, e := range a {

View file

@ -1,3 +1,4 @@
//go:build tools
// +build tools // +build tools
// We include our tool dependencies for `go generate` here to ensure they're // We include our tool dependencies for `go generate` here to ensure they're

101
vendor/github.com/miekg/dns/types.go generated vendored
View file

@ -65,6 +65,7 @@ const (
TypeAPL uint16 = 42 TypeAPL uint16 = 42
TypeDS uint16 = 43 TypeDS uint16 = 43
TypeSSHFP uint16 = 44 TypeSSHFP uint16 = 44
TypeIPSECKEY uint16 = 45
TypeRRSIG uint16 = 46 TypeRRSIG uint16 = 46
TypeNSEC uint16 = 47 TypeNSEC uint16 = 47
TypeDNSKEY uint16 = 48 TypeDNSKEY uint16 = 48
@ -98,6 +99,7 @@ const (
TypeURI uint16 = 256 TypeURI uint16 = 256
TypeCAA uint16 = 257 TypeCAA uint16 = 257
TypeAVC uint16 = 258 TypeAVC uint16 = 258
TypeAMTRELAY uint16 = 260
TypeTKEY uint16 = 249 TypeTKEY uint16 = 249
TypeTSIG uint16 = 250 TypeTSIG uint16 = 250
@ -159,6 +161,22 @@ const (
ZoneMDHashAlgSHA512 = 2 ZoneMDHashAlgSHA512 = 2
) )
// Used in IPSEC https://datatracker.ietf.org/doc/html/rfc4025#section-2.3
const (
IPSECGatewayNone uint8 = iota
IPSECGatewayIPv4
IPSECGatewayIPv6
IPSECGatewayHost
)
// Used in AMTRELAY https://datatracker.ietf.org/doc/html/rfc8777#section-4.2.3
const (
AMTRELAYNone = IPSECGatewayNone
AMTRELAYIPv4 = IPSECGatewayIPv4
AMTRELAYIPv6 = IPSECGatewayIPv6
AMTRELAYHost = IPSECGatewayHost
)
// Header is the wire format for the DNS packet header. // Header is the wire format for the DNS packet header.
type Header struct { type Header struct {
Id uint16 Id uint16
@ -994,6 +1012,69 @@ func (rr *DNSKEY) String() string {
" " + rr.PublicKey " " + rr.PublicKey
} }
// IPSECKEY RR. See RFC 4025.
type IPSECKEY struct {
Hdr RR_Header
Precedence uint8
GatewayType uint8
Algorithm uint8
GatewayAddr net.IP `dns:"-"` // packing/unpacking/parsing/etc handled together with GatewayHost
GatewayHost string `dns:"ipsechost"`
PublicKey string `dns:"base64"`
}
func (rr *IPSECKEY) String() string {
var gateway string
switch rr.GatewayType {
case IPSECGatewayIPv4, IPSECGatewayIPv6:
gateway = rr.GatewayAddr.String()
case IPSECGatewayHost:
gateway = rr.GatewayHost
case IPSECGatewayNone:
fallthrough
default:
gateway = "."
}
return rr.Hdr.String() + strconv.Itoa(int(rr.Precedence)) +
" " + strconv.Itoa(int(rr.GatewayType)) +
" " + strconv.Itoa(int(rr.Algorithm)) +
" " + gateway +
" " + rr.PublicKey
}
// AMTRELAY RR. See RFC 8777.
type AMTRELAY struct {
Hdr RR_Header
Precedence uint8
GatewayType uint8 // discovery is packed in here at bit 0x80
GatewayAddr net.IP `dns:"-"` // packing/unpacking/parsing/etc handled together with GatewayHost
GatewayHost string `dns:"amtrelayhost"`
}
func (rr *AMTRELAY) String() string {
var gateway string
switch rr.GatewayType & 0x7f {
case AMTRELAYIPv4, AMTRELAYIPv6:
gateway = rr.GatewayAddr.String()
case AMTRELAYHost:
gateway = rr.GatewayHost
case AMTRELAYNone:
fallthrough
default:
gateway = "."
}
boolS := "0"
if rr.GatewayType&0x80 == 0x80 {
boolS = "1"
}
return rr.Hdr.String() + strconv.Itoa(int(rr.Precedence)) +
" " + boolS +
" " + strconv.Itoa(int(rr.GatewayType&0x7f)) +
" " + gateway
}
// RKEY RR. See https://www.iana.org/assignments/dns-parameters/RKEY/rkey-completed-template. // RKEY RR. See https://www.iana.org/assignments/dns-parameters/RKEY/rkey-completed-template.
type RKEY struct { type RKEY struct {
Hdr RR_Header Hdr RR_Header
@ -1450,7 +1531,7 @@ func (a *APLPrefix) str() string {
// equals reports whether two APL prefixes are identical. // equals reports whether two APL prefixes are identical.
func (a *APLPrefix) equals(b *APLPrefix) bool { func (a *APLPrefix) equals(b *APLPrefix) bool {
return a.Negation == b.Negation && return a.Negation == b.Negation &&
bytes.Equal(a.Network.IP, b.Network.IP) && a.Network.IP.Equal(b.Network.IP) &&
bytes.Equal(a.Network.Mask, b.Network.Mask) bytes.Equal(a.Network.Mask, b.Network.Mask)
} }
@ -1518,21 +1599,19 @@ func euiToString(eui uint64, bits int) (hex string) {
return return
} }
// copyIP returns a copy of ip. // cloneSlice returns a shallow copy of s.
func copyIP(ip net.IP) net.IP { func cloneSlice[E any, S ~[]E](s S) S {
p := make(net.IP, len(ip)) if s == nil {
copy(p, ip) return nil
return p }
return append(S(nil), s...)
} }
// copyNet returns a copy of a subnet. // copyNet returns a copy of a subnet.
func copyNet(n net.IPNet) net.IPNet { func copyNet(n net.IPNet) net.IPNet {
m := make(net.IPMask, len(n.Mask))
copy(m, n.Mask)
return net.IPNet{ return net.IPNet{
IP: copyIP(n.IP), IP: cloneSlice(n.IP),
Mask: m, Mask: cloneSlice(n.Mask),
} }
} }

1
vendor/github.com/miekg/dns/udp.go generated vendored
View file

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
package dns package dns

View file

@ -1,5 +1,9 @@
//go:build windows
// +build windows // +build windows
// TODO(tmthrgd): Remove this Windows-specific code if go.dev/issue/7175 and
// go.dev/issue/7174 are ever fixed.
package dns package dns
import "net" import "net"
@ -14,7 +18,6 @@ func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr }
// ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a // ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a
// net.UDPAddr. // net.UDPAddr.
// TODO(fastest963): Once go1.10 is released, use ReadMsgUDP.
func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) { func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) {
n, raddr, err := conn.ReadFrom(b) n, raddr, err := conn.ReadFrom(b)
if err != nil { if err != nil {
@ -24,12 +27,9 @@ func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) {
} }
// WriteToSessionUDP acts just like net.UDPConn.WriteTo(), but uses a *SessionUDP instead of a net.Addr. // WriteToSessionUDP acts just like net.UDPConn.WriteTo(), but uses a *SessionUDP instead of a net.Addr.
// TODO(fastest963): Once go1.10 is released, use WriteMsgUDP.
func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) { func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) {
return conn.WriteTo(b, session.raddr) return conn.WriteTo(b, session.raddr)
} }
// TODO(fastest963): Once go1.10 is released and we can use *MsgUDP methods
// use the standard method in udp.go for these.
func setUDPSocketOptions(*net.UDPConn) error { return nil } func setUDPSocketOptions(*net.UDPConn) error { return nil }
func parseDstFromOOB([]byte, net.IP) net.IP { return nil } func parseDstFromOOB([]byte, net.IP) net.IP { return nil }

View file

@ -3,7 +3,7 @@ package dns
import "fmt" import "fmt"
// Version is current version of this library. // Version is current version of this library.
var Version = v{1, 1, 50} var Version = v{1, 1, 52}
// v holds the version of this library. // v holds the version of this library.
type v struct { type v struct {

1
vendor/github.com/miekg/dns/xfr.go generated vendored
View file

@ -44,7 +44,6 @@ func (t *Transfer) tsigProvider() TsigProvider {
// dnscon := &dns.Conn{Conn:con} // dnscon := &dns.Conn{Conn:con}
// transfer = &dns.Transfer{Conn: dnscon} // transfer = &dns.Transfer{Conn: dnscon}
// channel, err := transfer.In(message, master) // channel, err := transfer.In(message, master)
//
func (t *Transfer) In(q *Msg, a string) (env chan *Envelope, err error) { func (t *Transfer) In(q *Msg, a string) (env chan *Envelope, err error) {
switch q.Question[0].Qtype { switch q.Question[0].Qtype {
case TypeAXFR, TypeIXFR: case TypeAXFR, TypeIXFR:

View file

@ -43,6 +43,32 @@ func (r1 *AFSDB) isDuplicate(_r2 RR) bool {
return true return true
} }
func (r1 *AMTRELAY) isDuplicate(_r2 RR) bool {
r2, ok := _r2.(*AMTRELAY)
if !ok {
return false
}
_ = r2
if r1.Precedence != r2.Precedence {
return false
}
if r1.GatewayType != r2.GatewayType {
return false
}
switch r1.GatewayType {
case IPSECGatewayIPv4, IPSECGatewayIPv6:
if !r1.GatewayAddr.Equal(r2.GatewayAddr) {
return false
}
case IPSECGatewayHost:
if !isDuplicateName(r1.GatewayHost, r2.GatewayHost) {
return false
}
}
return true
}
func (r1 *ANY) isDuplicate(_r2 RR) bool { func (r1 *ANY) isDuplicate(_r2 RR) bool {
r2, ok := _r2.(*ANY) r2, ok := _r2.(*ANY)
if !ok { if !ok {
@ -423,6 +449,38 @@ func (r1 *HTTPS) isDuplicate(_r2 RR) bool {
return true return true
} }
func (r1 *IPSECKEY) isDuplicate(_r2 RR) bool {
r2, ok := _r2.(*IPSECKEY)
if !ok {
return false
}
_ = r2
if r1.Precedence != r2.Precedence {
return false
}
if r1.GatewayType != r2.GatewayType {
return false
}
if r1.Algorithm != r2.Algorithm {
return false
}
switch r1.GatewayType {
case IPSECGatewayIPv4, IPSECGatewayIPv6:
if !r1.GatewayAddr.Equal(r2.GatewayAddr) {
return false
}
case IPSECGatewayHost:
if !isDuplicateName(r1.GatewayHost, r2.GatewayHost) {
return false
}
}
if r1.PublicKey != r2.PublicKey {
return false
}
return true
}
func (r1 *KEY) isDuplicate(_r2 RR) bool { func (r1 *KEY) isDuplicate(_r2 RR) bool {
r2, ok := _r2.(*KEY) r2, ok := _r2.(*KEY)
if !ok { if !ok {

110
vendor/github.com/miekg/dns/zmsg.go generated vendored
View file

@ -32,6 +32,22 @@ func (rr *AFSDB) pack(msg []byte, off int, compression compressionMap, compress
return off, nil return off, nil
} }
func (rr *AMTRELAY) pack(msg []byte, off int, compression compressionMap, compress bool) (off1 int, err error) {
off, err = packUint8(rr.Precedence, msg, off)
if err != nil {
return off, err
}
off, err = packUint8(rr.GatewayType, msg, off)
if err != nil {
return off, err
}
off, err = packIPSECGateway(rr.GatewayAddr, rr.GatewayHost, msg, off, rr.GatewayType, compression, false)
if err != nil {
return off, err
}
return off, nil
}
func (rr *ANY) pack(msg []byte, off int, compression compressionMap, compress bool) (off1 int, err error) { func (rr *ANY) pack(msg []byte, off int, compression compressionMap, compress bool) (off1 int, err error) {
return off, nil return off, nil
} }
@ -332,6 +348,30 @@ func (rr *HTTPS) pack(msg []byte, off int, compression compressionMap, compress
return off, nil return off, nil
} }
func (rr *IPSECKEY) pack(msg []byte, off int, compression compressionMap, compress bool) (off1 int, err error) {
off, err = packUint8(rr.Precedence, msg, off)
if err != nil {
return off, err
}
off, err = packUint8(rr.GatewayType, msg, off)
if err != nil {
return off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
return off, err
}
off, err = packIPSECGateway(rr.GatewayAddr, rr.GatewayHost, msg, off, rr.GatewayType, compression, false)
if err != nil {
return off, err
}
off, err = packStringBase64(rr.PublicKey, msg, off)
if err != nil {
return off, err
}
return off, nil
}
func (rr *KEY) pack(msg []byte, off int, compression compressionMap, compress bool) (off1 int, err error) { func (rr *KEY) pack(msg []byte, off int, compression compressionMap, compress bool) (off1 int, err error) {
off, err = packUint16(rr.Flags, msg, off) off, err = packUint16(rr.Flags, msg, off)
if err != nil { if err != nil {
@ -1180,6 +1220,34 @@ func (rr *AFSDB) unpack(msg []byte, off int) (off1 int, err error) {
return off, nil return off, nil
} }
func (rr *AMTRELAY) unpack(msg []byte, off int) (off1 int, err error) {
rdStart := off
_ = rdStart
rr.Precedence, off, err = unpackUint8(msg, off)
if err != nil {
return off, err
}
if off == len(msg) {
return off, nil
}
rr.GatewayType, off, err = unpackUint8(msg, off)
if err != nil {
return off, err
}
if off == len(msg) {
return off, nil
}
if off == len(msg) {
return off, nil
}
rr.GatewayAddr, rr.GatewayHost, off, err = unpackIPSECGateway(msg, off, rr.GatewayType)
if err != nil {
return off, err
}
return off, nil
}
func (rr *ANY) unpack(msg []byte, off int) (off1 int, err error) { func (rr *ANY) unpack(msg []byte, off int) (off1 int, err error) {
rdStart := off rdStart := off
_ = rdStart _ = rdStart
@ -1636,6 +1704,48 @@ func (rr *HTTPS) unpack(msg []byte, off int) (off1 int, err error) {
return off, nil return off, nil
} }
func (rr *IPSECKEY) unpack(msg []byte, off int) (off1 int, err error) {
rdStart := off
_ = rdStart
rr.Precedence, off, err = unpackUint8(msg, off)
if err != nil {
return off, err
}
if off == len(msg) {
return off, nil
}
rr.GatewayType, off, err = unpackUint8(msg, off)
if err != nil {
return off, err
}
if off == len(msg) {
return off, nil
}
rr.Algorithm, off, err = unpackUint8(msg, off)
if err != nil {
return off, err
}
if off == len(msg) {
return off, nil
}
if off == len(msg) {
return off, nil
}
rr.GatewayAddr, rr.GatewayHost, off, err = unpackIPSECGateway(msg, off, rr.GatewayType)
if err != nil {
return off, err
}
if off == len(msg) {
return off, nil
}
rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
if err != nil {
return off, err
}
return off, nil
}
func (rr *KEY) unpack(msg []byte, off int) (off1 int, err error) { func (rr *KEY) unpack(msg []byte, off int) (off1 int, err error) {
rdStart := off rdStart := off
_ = rdStart _ = rdStart

453
vendor/github.com/miekg/dns/ztypes.go generated vendored

File diff suppressed because it is too large Load diff

View file

@ -92,7 +92,7 @@ var (
asmArchMips64LE = asmArch{name: "mips64le", bigEndian: false, stack: "R29", lr: true} asmArchMips64LE = asmArch{name: "mips64le", bigEndian: false, stack: "R29", lr: true}
asmArchPpc64 = asmArch{name: "ppc64", bigEndian: true, stack: "R1", lr: true, retRegs: []string{"R3", "F1"}} asmArchPpc64 = asmArch{name: "ppc64", bigEndian: true, stack: "R1", lr: true, retRegs: []string{"R3", "F1"}}
asmArchPpc64LE = asmArch{name: "ppc64le", bigEndian: false, stack: "R1", lr: true, retRegs: []string{"R3", "F1"}} asmArchPpc64LE = asmArch{name: "ppc64le", bigEndian: false, stack: "R1", lr: true, retRegs: []string{"R3", "F1"}}
asmArchRISCV64 = asmArch{name: "riscv64", bigEndian: false, stack: "SP", lr: true} asmArchRISCV64 = asmArch{name: "riscv64", bigEndian: false, stack: "SP", lr: true, retRegs: []string{"X10", "F10"}}
asmArchS390X = asmArch{name: "s390x", bigEndian: true, stack: "R15", lr: true} asmArchS390X = asmArch{name: "s390x", bigEndian: true, stack: "R15", lr: true}
asmArchWasm = asmArch{name: "wasm", bigEndian: false, stack: "SP", lr: false} asmArchWasm = asmArch{name: "wasm", bigEndian: false, stack: "SP", lr: false}

View file

@ -14,7 +14,6 @@ import (
"golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector" "golang.org/x/tools/go/ast/inspector"
"golang.org/x/tools/go/types/typeutil" "golang.org/x/tools/go/types/typeutil"
"golang.org/x/tools/internal/analysisinternal"
) )
const Doc = `check references to loop variables from within nested functions const Doc = `check references to loop variables from within nested functions
@ -24,10 +23,11 @@ literal inside the loop body. It checks for patterns where access to a loop
variable is known to escape the current loop iteration: variable is known to escape the current loop iteration:
1. a call to go or defer at the end of the loop body 1. a call to go or defer at the end of the loop body
2. a call to golang.org/x/sync/errgroup.Group.Go at the end of the loop body 2. a call to golang.org/x/sync/errgroup.Group.Go at the end of the loop body
3. a call testing.T.Run where the subtest body invokes t.Parallel()
The analyzer only considers references in the last statement of the loop body In the case of (1) and (2), the analyzer only considers references in the last
as it is not deep enough to understand the effects of subsequent statements statement of the loop body as it is not deep enough to understand the effects
which might render the reference benign. of subsequent statements which might render the reference benign.
For example: For example:
@ -39,10 +39,6 @@ For example:
See: https://golang.org/doc/go_faq.html#closures_and_goroutines` See: https://golang.org/doc/go_faq.html#closures_and_goroutines`
// TODO(rfindley): enable support for checking parallel subtests, pending
// investigation, adding:
// 3. a call testing.T.Run where the subtest body invokes t.Parallel()
var Analyzer = &analysis.Analyzer{ var Analyzer = &analysis.Analyzer{
Name: "loopclosure", Name: "loopclosure",
Doc: Doc, Doc: Doc,
@ -121,7 +117,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
if i == lastStmt { if i == lastStmt {
stmts = litStmts(goInvoke(pass.TypesInfo, call)) stmts = litStmts(goInvoke(pass.TypesInfo, call))
} }
if stmts == nil && analysisinternal.LoopclosureParallelSubtests { if stmts == nil {
stmts = parallelSubtest(pass.TypesInfo, call) stmts = parallelSubtest(pass.TypesInfo, call)
} }
} }
@ -178,15 +174,19 @@ func goInvoke(info *types.Info, call *ast.CallExpr) ast.Expr {
return call.Args[0] return call.Args[0]
} }
// parallelSubtest returns statements that would would be executed // parallelSubtest returns statements that can be easily proven to execute
// asynchronously via the go test runner, as t.Run has been invoked with a // concurrently via the go test runner, as t.Run has been invoked with a
// function literal that calls t.Parallel. // function literal that calls t.Parallel.
// //
// In practice, users rely on the fact that statements before the call to // In practice, users rely on the fact that statements before the call to
// t.Parallel are synchronous. For example by declaring test := test inside the // t.Parallel are synchronous. For example by declaring test := test inside the
// function literal, but before the call to t.Parallel. // function literal, but before the call to t.Parallel.
// //
// Therefore, we only flag references that occur after the call to t.Parallel: // Therefore, we only flag references in statements that are obviously
// dominated by a call to t.Parallel. As a simple heuristic, we only consider
// statements following the final labeled statement in the function body, to
// avoid scenarios where a jump would cause either the call to t.Parallel or
// the problematic reference to be skipped.
// //
// import "testing" // import "testing"
// //
@ -210,17 +210,81 @@ func parallelSubtest(info *types.Info, call *ast.CallExpr) []ast.Stmt {
return nil return nil
} }
for i, stmt := range lit.Body.List { // Capture the *testing.T object for the first argument to the function
// literal.
if len(lit.Type.Params.List[0].Names) == 0 {
return nil
}
tObj := info.Defs[lit.Type.Params.List[0].Names[0]]
if tObj == nil {
return nil
}
// Match statements that occur after a call to t.Parallel following the final
// labeled statement in the function body.
//
// We iterate over lit.Body.List to have a simple, fast and "frequent enough"
// dominance relationship for t.Parallel(): lit.Body.List[i] dominates
// lit.Body.List[j] for i < j unless there is a jump.
var stmts []ast.Stmt
afterParallel := false
for _, stmt := range lit.Body.List {
stmt, labeled := unlabel(stmt)
if labeled {
// Reset: naively we don't know if a jump could have caused the
// previously considered statements to be skipped.
stmts = nil
afterParallel = false
}
if afterParallel {
stmts = append(stmts, stmt)
continue
}
// Check if stmt is a call to t.Parallel(), for the correct t.
exprStmt, ok := stmt.(*ast.ExprStmt) exprStmt, ok := stmt.(*ast.ExprStmt)
if !ok { if !ok {
continue continue
} }
if isMethodCall(info, exprStmt.X, "testing", "T", "Parallel") { expr := exprStmt.X
return lit.Body.List[i+1:] if isMethodCall(info, expr, "testing", "T", "Parallel") {
call, _ := expr.(*ast.CallExpr)
if call == nil {
continue
}
x, _ := call.Fun.(*ast.SelectorExpr)
if x == nil {
continue
}
id, _ := x.X.(*ast.Ident)
if id == nil {
continue
}
if info.Uses[id] == tObj {
afterParallel = true
}
} }
} }
return nil return stmts
}
// unlabel returns the inner statement for the possibly labeled statement stmt,
// stripping any (possibly nested) *ast.LabeledStmt wrapper.
//
// The second result reports whether stmt was an *ast.LabeledStmt.
func unlabel(stmt ast.Stmt) (ast.Stmt, bool) {
labeled := false
for {
labelStmt, ok := stmt.(*ast.LabeledStmt)
if !ok {
return stmt, labeled
}
labeled = true
stmt = labelStmt.Stmt
}
} }
// isMethodCall reports whether expr is a method call of // isMethodCall reports whether expr is a method call of

View file

@ -269,7 +269,9 @@ func isTestingType(typ types.Type, testingType string) bool {
if !ok { if !ok {
return false return false
} }
return named.Obj().Pkg().Path() == "testing" && named.Obj().Name() == testingType obj := named.Obj()
// obj.Pkg is nil for the error type.
return obj != nil && obj.Pkg() != nil && obj.Pkg().Path() == "testing" && obj.Name() == testingType
} }
// Validate that fuzz target function's arguments are of accepted types. // Validate that fuzz target function's arguments are of accepted types.

View file

@ -30,7 +30,7 @@ import (
"io/ioutil" "io/ioutil"
"os/exec" "os/exec"
"golang.org/x/tools/go/internal/gcimporter" "golang.org/x/tools/internal/gcimporter"
) )
// Find returns the name of an object (.o) or archive (.a) file // Find returns the name of an object (.o) or archive (.a) file

View file

@ -453,12 +453,16 @@ func (b *builder) addr(fn *Function, e ast.Expr, escaping bool) lvalue {
} }
wantAddr := true wantAddr := true
v := b.receiver(fn, e.X, wantAddr, escaping, sel) v := b.receiver(fn, e.X, wantAddr, escaping, sel)
last := len(sel.index) - 1 index := sel.index[len(sel.index)-1]
return &address{ fld := typeparams.CoreType(deref(v.Type())).(*types.Struct).Field(index)
addr: emitFieldSelection(fn, v, sel.index[last], true, e.Sel),
pos: e.Sel.Pos(), // Due to the two phases of resolving AssignStmt, a panic from x.f = p()
expr: e.Sel, // when x is nil is required to come after the side-effects of
// evaluating x and p().
emit := func(fn *Function) Value {
return emitFieldSelection(fn, v, index, true, e.Sel)
} }
return &lazyAddress{addr: emit, t: fld.Type(), pos: e.Sel.Pos(), expr: e.Sel}
case *ast.IndexExpr: case *ast.IndexExpr:
var x Value var x Value
@ -487,13 +491,19 @@ func (b *builder) addr(fn *Function, e ast.Expr, escaping bool) lvalue {
if isUntyped(index.Type()) { if isUntyped(index.Type()) {
index = emitConv(fn, index, tInt) index = emitConv(fn, index, tInt)
} }
v := &IndexAddr{ // Due to the two phases of resolving AssignStmt, a panic from x[i] = p()
X: x, // when x is nil or i is out-of-bounds is required to come after the
Index: index, // side-effects of evaluating x, i and p().
emit := func(fn *Function) Value {
v := &IndexAddr{
X: x,
Index: index,
}
v.setPos(e.Lbrack)
v.setType(et)
return fn.emit(v)
} }
v.setPos(e.Lbrack) return &lazyAddress{addr: emit, t: deref(et), pos: e.Lbrack, expr: e}
v.setType(et)
return &address{addr: fn.emit(v), pos: e.Lbrack, expr: e}
case *ast.StarExpr: case *ast.StarExpr:
return &address{addr: b.expr(fn, e.X), pos: e.Star, expr: e} return &address{addr: b.expr(fn, e.X), pos: e.Star, expr: e}
@ -669,6 +679,8 @@ func (b *builder) expr0(fn *Function, e ast.Expr, tv types.TypeAndValue) Value {
y.pos = e.Lparen y.pos = e.Lparen
case *SliceToArrayPointer: case *SliceToArrayPointer:
y.pos = e.Lparen y.pos = e.Lparen
case *UnOp: // conversion from slice to array.
y.pos = e.Lparen
} }
} }
return y return y

View file

@ -177,7 +177,6 @@ func emitConv(f *Function, val Value, typ types.Type) Value {
if types.Identical(t_src, typ) { if types.Identical(t_src, typ) {
return val return val
} }
ut_dst := typ.Underlying() ut_dst := typ.Underlying()
ut_src := t_src.Underlying() ut_src := t_src.Underlying()
@ -229,12 +228,32 @@ func emitConv(f *Function, val Value, typ types.Type) Value {
// Conversion from slice to array pointer? // Conversion from slice to array pointer?
if slice, ok := ut_src.(*types.Slice); ok { if slice, ok := ut_src.(*types.Slice); ok {
if ptr, ok := ut_dst.(*types.Pointer); ok { switch t := ut_dst.(type) {
case *types.Pointer:
ptr := t
if arr, ok := ptr.Elem().Underlying().(*types.Array); ok && types.Identical(slice.Elem(), arr.Elem()) { if arr, ok := ptr.Elem().Underlying().(*types.Array); ok && types.Identical(slice.Elem(), arr.Elem()) {
c := &SliceToArrayPointer{X: val} c := &SliceToArrayPointer{X: val}
c.setType(ut_dst) // TODO(taking): Check if this should be ut_dst or ptr.
c.setType(ptr)
return f.emit(c) return f.emit(c)
} }
case *types.Array:
arr := t
if arr.Len() == 0 {
return zeroValue(f, arr)
}
if types.Identical(slice.Elem(), arr.Elem()) {
c := &SliceToArrayPointer{X: val}
c.setType(types.NewPointer(arr))
x := f.emit(c)
unOp := &UnOp{
Op: token.MUL,
X: x,
CommaOk: false,
}
unOp.setType(typ)
return f.emit(unOp)
}
} }
} }
// A representation-changing conversion? // A representation-changing conversion?

View file

@ -93,6 +93,42 @@ func (e *element) typ() types.Type {
return e.t return e.t
} }
// A lazyAddress is an lvalue whose address is the result of an instruction.
// These work like an *address except a new address.address() Value
// is created on each load, store and address call.
// A lazyAddress can be used to control when a side effect (nil pointer
// dereference, index out of bounds) of using a location happens.
type lazyAddress struct {
addr func(fn *Function) Value // emit to fn the computation of the address
t types.Type // type of the location
pos token.Pos // source position
expr ast.Expr // source syntax of the value (not address) [debug mode]
}
func (l *lazyAddress) load(fn *Function) Value {
load := emitLoad(fn, l.addr(fn))
load.pos = l.pos
return load
}
func (l *lazyAddress) store(fn *Function, v Value) {
store := emitStore(fn, l.addr(fn), v, l.pos)
if l.expr != nil {
// store.Val is v, converted for assignability.
emitDebugRef(fn, l.expr, store.Val, false)
}
}
func (l *lazyAddress) address(fn *Function) Value {
addr := l.addr(fn)
if l.expr != nil {
emitDebugRef(fn, l.expr, addr, true)
}
return addr
}
func (l *lazyAddress) typ() types.Type { return l.t }
// A blank is a dummy variable whose name is "_". // A blank is a dummy variable whose name is "_".
// It is not reified: loads are illegal and stores are ignored. // It is not reified: loads are illegal and stores are ignored.
type blank struct{} type blank struct{}

View file

@ -332,7 +332,9 @@ func (h Hasher) hashFor(t types.Type) uint32 {
// Method order is not significant. // Method order is not significant.
// Ignore m.Pkg(). // Ignore m.Pkg().
m := t.Method(i) m := t.Method(i)
hash += 3*hashString(m.Name()) + 5*h.Hash(m.Type()) // Use shallow hash on method signature to
// avoid anonymous interface cycles.
hash += 3*hashString(m.Name()) + 5*h.shallowHash(m.Type())
} }
// Hash type restrictions. // Hash type restrictions.
@ -434,3 +436,76 @@ func (h Hasher) hashPtr(ptr interface{}) uint32 {
h.ptrMap[ptr] = hash h.ptrMap[ptr] = hash
return hash return hash
} }
// shallowHash computes a hash of t without looking at any of its
// element Types, to avoid potential anonymous cycles in the types of
// interface methods.
//
// When an unnamed non-empty interface type appears anywhere among the
// arguments or results of an interface method, there is a potential
// for endless recursion. Consider:
//
// type X interface { m() []*interface { X } }
//
// The problem is that the Methods of the interface in m's result type
// include m itself; there is no mention of the named type X that
// might help us break the cycle.
// (See comment in go/types.identical, case *Interface, for more.)
func (h Hasher) shallowHash(t types.Type) uint32 {
// t is the type of an interface method (Signature),
// its params or results (Tuples), or their immediate
// elements (mostly Slice, Pointer, Basic, Named),
// so there's no need to optimize anything else.
switch t := t.(type) {
case *types.Signature:
var hash uint32 = 604171
if t.Variadic() {
hash *= 971767
}
// The Signature/Tuple recursion is always finite
// and invariably shallow.
return hash + 1062599*h.shallowHash(t.Params()) + 1282529*h.shallowHash(t.Results())
case *types.Tuple:
n := t.Len()
hash := 9137 + 2*uint32(n)
for i := 0; i < n; i++ {
hash += 53471161 * h.shallowHash(t.At(i).Type())
}
return hash
case *types.Basic:
return 45212177 * uint32(t.Kind())
case *types.Array:
return 1524181 + 2*uint32(t.Len())
case *types.Slice:
return 2690201
case *types.Struct:
return 3326489
case *types.Pointer:
return 4393139
case *typeparams.Union:
return 562448657
case *types.Interface:
return 2124679 // no recursion here
case *types.Map:
return 9109
case *types.Chan:
return 9127
case *types.Named:
return h.hashPtr(t.Obj())
case *typeparams.TypeParam:
return h.hashPtr(t.Obj())
}
panic(fmt.Sprintf("shallowHash: %T: %v", t, t))
}

View file

@ -18,10 +18,6 @@ import (
// in Go 1.18+. // in Go 1.18+.
var DiagnoseFuzzTests bool = false var DiagnoseFuzzTests bool = false
// LoopclosureParallelSubtests controls whether the 'loopclosure' analyzer
// diagnoses loop variables references in parallel subtests.
var LoopclosureParallelSubtests = false
var ( var (
GetTypeErrors func(p interface{}) []types.Error GetTypeErrors func(p interface{}) []types.Error
SetTypeErrors func(p interface{}, errors []types.Error) SetTypeErrors func(p interface{}, errors []types.Error)

View file

@ -12,7 +12,6 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"go/ast"
"go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
@ -145,7 +144,7 @@ func BExportData(fset *token.FileSet, pkg *types.Package) (b []byte, err error)
objcount := 0 objcount := 0
scope := pkg.Scope() scope := pkg.Scope()
for _, name := range scope.Names() { for _, name := range scope.Names() {
if !ast.IsExported(name) { if !token.IsExported(name) {
continue continue
} }
if trace { if trace {
@ -482,7 +481,7 @@ func (p *exporter) method(m *types.Func) {
p.pos(m) p.pos(m)
p.string(m.Name()) p.string(m.Name())
if m.Name() != "_" && !ast.IsExported(m.Name()) { if m.Name() != "_" && !token.IsExported(m.Name()) {
p.pkg(m.Pkg(), false) p.pkg(m.Pkg(), false)
} }
@ -501,7 +500,7 @@ func (p *exporter) fieldName(f *types.Var) {
// 3) field name doesn't match base type name (alias name) // 3) field name doesn't match base type name (alias name)
bname := basetypeName(f.Type()) bname := basetypeName(f.Type())
if name == bname { if name == bname {
if ast.IsExported(name) { if token.IsExported(name) {
name = "" // 1) we don't need to know the field name or package name = "" // 1) we don't need to know the field name or package
} else { } else {
name = "?" // 2) use unexported name "?" to force package export name = "?" // 2) use unexported name "?" to force package export
@ -514,7 +513,7 @@ func (p *exporter) fieldName(f *types.Var) {
} }
p.string(name) p.string(name)
if name != "" && !ast.IsExported(name) { if name != "" && !token.IsExported(name) {
p.pkg(f.Pkg(), false) p.pkg(f.Pkg(), false)
} }
} }

View file

@ -9,7 +9,7 @@
// Package gcimporter provides various functions for reading // Package gcimporter provides various functions for reading
// gc-generated object files that can be used to implement the // gc-generated object files that can be used to implement the
// Importer interface defined by the Go 1.5 standard library package. // Importer interface defined by the Go 1.5 standard library package.
package gcimporter // import "golang.org/x/tools/go/internal/gcimporter" package gcimporter // import "golang.org/x/tools/internal/gcimporter"
import ( import (
"bufio" "bufio"
@ -22,11 +22,14 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"path"
"path/filepath" "path/filepath"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"text/scanner" "text/scanner"
"golang.org/x/tools/internal/goroot"
) )
const ( const (
@ -38,6 +41,25 @@ const (
trace = false trace = false
) )
func lookupGorootExport(pkgpath, srcRoot, srcDir string) (string, bool) {
pkgpath = filepath.ToSlash(pkgpath)
m, err := goroot.PkgfileMap()
if err != nil {
return "", false
}
if export, ok := m[pkgpath]; ok {
return export, true
}
vendorPrefix := "vendor"
if strings.HasPrefix(srcDir, filepath.Join(srcRoot, "cmd")) {
vendorPrefix = path.Join("cmd", vendorPrefix)
}
pkgpath = path.Join(vendorPrefix, pkgpath)
fmt.Fprintln(os.Stderr, "looking up ", pkgpath)
export, ok := m[pkgpath]
return export, ok
}
var pkgExts = [...]string{".a", ".o"} var pkgExts = [...]string{".a", ".o"}
// FindPkg returns the filename and unique package id for an import // FindPkg returns the filename and unique package id for an import
@ -60,11 +82,18 @@ func FindPkg(path, srcDir string) (filename, id string) {
} }
bp, _ := build.Import(path, srcDir, build.FindOnly|build.AllowBinary) bp, _ := build.Import(path, srcDir, build.FindOnly|build.AllowBinary)
if bp.PkgObj == "" { if bp.PkgObj == "" {
id = path // make sure we have an id to print in error message var ok bool
return if bp.Goroot {
filename, ok = lookupGorootExport(path, bp.SrcRoot, srcDir)
}
if !ok {
id = path // make sure we have an id to print in error message
return
}
} else {
noext = strings.TrimSuffix(bp.PkgObj, ".a")
id = bp.ImportPath
} }
noext = strings.TrimSuffix(bp.PkgObj, ".a")
id = bp.ImportPath
case build.IsLocalImport(path): case build.IsLocalImport(path):
// "./x" -> "/this/directory/x.ext", "/this/directory/x" // "./x" -> "/this/directory/x.ext", "/this/directory/x"
@ -85,6 +114,12 @@ func FindPkg(path, srcDir string) (filename, id string) {
} }
} }
if filename != "" {
if f, err := os.Stat(filename); err == nil && !f.IsDir() {
return
}
}
// try extensions // try extensions
for _, ext := range pkgExts { for _, ext := range pkgExts {
filename = noext + ext filename = noext + ext

View file

@ -12,7 +12,6 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"go/ast"
"go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
@ -26,6 +25,41 @@ import (
"golang.org/x/tools/internal/typeparams" "golang.org/x/tools/internal/typeparams"
) )
// IExportShallow encodes "shallow" export data for the specified package.
//
// No promises are made about the encoding other than that it can be
// decoded by the same version of IIExportShallow. If you plan to save
// export data in the file system, be sure to include a cryptographic
// digest of the executable in the key to avoid version skew.
func IExportShallow(fset *token.FileSet, pkg *types.Package) ([]byte, error) {
// In principle this operation can only fail if out.Write fails,
// but that's impossible for bytes.Buffer---and as a matter of
// fact iexportCommon doesn't even check for I/O errors.
// TODO(adonovan): handle I/O errors properly.
// TODO(adonovan): use byte slices throughout, avoiding copying.
const bundle, shallow = false, true
var out bytes.Buffer
err := iexportCommon(&out, fset, bundle, shallow, iexportVersion, []*types.Package{pkg})
return out.Bytes(), err
}
// IImportShallow decodes "shallow" types.Package data encoded by IExportShallow
// in the same executable. This function cannot import data from
// cmd/compile or gcexportdata.Write.
func IImportShallow(fset *token.FileSet, imports map[string]*types.Package, data []byte, path string, insert InsertType) (*types.Package, error) {
const bundle = false
pkgs, err := iimportCommon(fset, imports, data, bundle, path, insert)
if err != nil {
return nil, err
}
return pkgs[0], nil
}
// InsertType is the type of a function that creates a types.TypeName
// object for a named type and inserts it into the scope of the
// specified Package.
type InsertType = func(pkg *types.Package, name string)
// Current bundled export format version. Increase with each format change. // Current bundled export format version. Increase with each format change.
// 0: initial implementation // 0: initial implementation
const bundleVersion = 0 const bundleVersion = 0
@ -36,15 +70,17 @@ const bundleVersion = 0
// The package path of the top-level package will not be recorded, // The package path of the top-level package will not be recorded,
// so that calls to IImportData can override with a provided package path. // so that calls to IImportData can override with a provided package path.
func IExportData(out io.Writer, fset *token.FileSet, pkg *types.Package) error { func IExportData(out io.Writer, fset *token.FileSet, pkg *types.Package) error {
return iexportCommon(out, fset, false, iexportVersion, []*types.Package{pkg}) const bundle, shallow = false, false
return iexportCommon(out, fset, bundle, shallow, iexportVersion, []*types.Package{pkg})
} }
// IExportBundle writes an indexed export bundle for pkgs to out. // IExportBundle writes an indexed export bundle for pkgs to out.
func IExportBundle(out io.Writer, fset *token.FileSet, pkgs []*types.Package) error { func IExportBundle(out io.Writer, fset *token.FileSet, pkgs []*types.Package) error {
return iexportCommon(out, fset, true, iexportVersion, pkgs) const bundle, shallow = true, false
return iexportCommon(out, fset, bundle, shallow, iexportVersion, pkgs)
} }
func iexportCommon(out io.Writer, fset *token.FileSet, bundle bool, version int, pkgs []*types.Package) (err error) { func iexportCommon(out io.Writer, fset *token.FileSet, bundle, shallow bool, version int, pkgs []*types.Package) (err error) {
if !debug { if !debug {
defer func() { defer func() {
if e := recover(); e != nil { if e := recover(); e != nil {
@ -61,6 +97,7 @@ func iexportCommon(out io.Writer, fset *token.FileSet, bundle bool, version int,
p := iexporter{ p := iexporter{
fset: fset, fset: fset,
version: version, version: version,
shallow: shallow,
allPkgs: map[*types.Package]bool{}, allPkgs: map[*types.Package]bool{},
stringIndex: map[string]uint64{}, stringIndex: map[string]uint64{},
declIndex: map[types.Object]uint64{}, declIndex: map[types.Object]uint64{},
@ -82,7 +119,7 @@ func iexportCommon(out io.Writer, fset *token.FileSet, bundle bool, version int,
for _, pkg := range pkgs { for _, pkg := range pkgs {
scope := pkg.Scope() scope := pkg.Scope()
for _, name := range scope.Names() { for _, name := range scope.Names() {
if ast.IsExported(name) { if token.IsExported(name) {
p.pushDecl(scope.Lookup(name)) p.pushDecl(scope.Lookup(name))
} }
} }
@ -205,7 +242,8 @@ type iexporter struct {
out *bytes.Buffer out *bytes.Buffer
version int version int
localpkg *types.Package shallow bool // don't put types from other packages in the index
localpkg *types.Package // (nil in bundle mode)
// allPkgs tracks all packages that have been referenced by // allPkgs tracks all packages that have been referenced by
// the export data, so we can ensure to include them in the // the export data, so we can ensure to include them in the
@ -256,6 +294,11 @@ func (p *iexporter) pushDecl(obj types.Object) {
panic("cannot export package unsafe") panic("cannot export package unsafe")
} }
// Shallow export data: don't index decls from other packages.
if p.shallow && obj.Pkg() != p.localpkg {
return
}
if _, ok := p.declIndex[obj]; ok { if _, ok := p.declIndex[obj]; ok {
return return
} }
@ -497,7 +540,7 @@ func (w *exportWriter) pkg(pkg *types.Package) {
w.string(w.exportPath(pkg)) w.string(w.exportPath(pkg))
} }
func (w *exportWriter) qualifiedIdent(obj types.Object) { func (w *exportWriter) qualifiedType(obj *types.TypeName) {
name := w.p.exportName(obj) name := w.p.exportName(obj)
// Ensure any referenced declarations are written out too. // Ensure any referenced declarations are written out too.
@ -556,11 +599,11 @@ func (w *exportWriter) doTyp(t types.Type, pkg *types.Package) {
return return
} }
w.startType(definedType) w.startType(definedType)
w.qualifiedIdent(t.Obj()) w.qualifiedType(t.Obj())
case *typeparams.TypeParam: case *typeparams.TypeParam:
w.startType(typeParamType) w.startType(typeParamType)
w.qualifiedIdent(t.Obj()) w.qualifiedType(t.Obj())
case *types.Pointer: case *types.Pointer:
w.startType(pointerType) w.startType(pointerType)
@ -602,14 +645,17 @@ func (w *exportWriter) doTyp(t types.Type, pkg *types.Package) {
case *types.Struct: case *types.Struct:
w.startType(structType) w.startType(structType)
w.setPkg(pkg, true)
n := t.NumFields() n := t.NumFields()
if n > 0 {
w.setPkg(t.Field(0).Pkg(), true) // qualifying package for field objects
} else {
w.setPkg(pkg, true)
}
w.uint64(uint64(n)) w.uint64(uint64(n))
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
f := t.Field(i) f := t.Field(i)
w.pos(f.Pos()) w.pos(f.Pos())
w.string(f.Name()) w.string(f.Name()) // unexported fields implicitly qualified by prior setPkg
w.typ(f.Type(), pkg) w.typ(f.Type(), pkg)
w.bool(f.Anonymous()) w.bool(f.Anonymous())
w.string(t.Tag(i)) // note (or tag) w.string(t.Tag(i)) // note (or tag)

View file

@ -85,7 +85,7 @@ const (
// If the export data version is not recognized or the format is otherwise // If the export data version is not recognized or the format is otherwise
// compromised, an error is returned. // compromised, an error is returned.
func IImportData(fset *token.FileSet, imports map[string]*types.Package, data []byte, path string) (int, *types.Package, error) { func IImportData(fset *token.FileSet, imports map[string]*types.Package, data []byte, path string) (int, *types.Package, error) {
pkgs, err := iimportCommon(fset, imports, data, false, path) pkgs, err := iimportCommon(fset, imports, data, false, path, nil)
if err != nil { if err != nil {
return 0, nil, err return 0, nil, err
} }
@ -94,10 +94,10 @@ func IImportData(fset *token.FileSet, imports map[string]*types.Package, data []
// IImportBundle imports a set of packages from the serialized package bundle. // IImportBundle imports a set of packages from the serialized package bundle.
func IImportBundle(fset *token.FileSet, imports map[string]*types.Package, data []byte) ([]*types.Package, error) { func IImportBundle(fset *token.FileSet, imports map[string]*types.Package, data []byte) ([]*types.Package, error) {
return iimportCommon(fset, imports, data, true, "") return iimportCommon(fset, imports, data, true, "", nil)
} }
func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data []byte, bundle bool, path string) (pkgs []*types.Package, err error) { func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data []byte, bundle bool, path string, insert InsertType) (pkgs []*types.Package, err error) {
const currentVersion = iexportVersionCurrent const currentVersion = iexportVersionCurrent
version := int64(-1) version := int64(-1)
if !debug { if !debug {
@ -147,6 +147,7 @@ func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data
p := iimporter{ p := iimporter{
version: int(version), version: int(version),
ipath: path, ipath: path,
insert: insert,
stringData: stringData, stringData: stringData,
stringCache: make(map[uint64]string), stringCache: make(map[uint64]string),
@ -187,11 +188,18 @@ func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data
} else if pkg.Name() != pkgName { } else if pkg.Name() != pkgName {
errorf("conflicting names %s and %s for package %q", pkg.Name(), pkgName, path) errorf("conflicting names %s and %s for package %q", pkg.Name(), pkgName, path)
} }
if i == 0 && !bundle {
p.localpkg = pkg
}
p.pkgCache[pkgPathOff] = pkg p.pkgCache[pkgPathOff] = pkg
// Read index for package.
nameIndex := make(map[string]uint64) nameIndex := make(map[string]uint64)
for nSyms := r.uint64(); nSyms > 0; nSyms-- { nSyms := r.uint64()
// In shallow mode we don't expect an index for other packages.
assert(nSyms == 0 || p.localpkg == pkg || p.insert == nil)
for ; nSyms > 0; nSyms-- {
name := p.stringAt(r.uint64()) name := p.stringAt(r.uint64())
nameIndex[name] = r.uint64() nameIndex[name] = r.uint64()
} }
@ -267,6 +275,9 @@ type iimporter struct {
version int version int
ipath string ipath string
localpkg *types.Package
insert func(pkg *types.Package, name string) // "shallow" mode only
stringData []byte stringData []byte
stringCache map[uint64]string stringCache map[uint64]string
pkgCache map[uint64]*types.Package pkgCache map[uint64]*types.Package
@ -310,6 +321,13 @@ func (p *iimporter) doDecl(pkg *types.Package, name string) {
off, ok := p.pkgIndex[pkg][name] off, ok := p.pkgIndex[pkg][name]
if !ok { if !ok {
// In "shallow" mode, call back to the application to
// find the object and insert it into the package scope.
if p.insert != nil {
assert(pkg != p.localpkg)
p.insert(pkg, name) // "can't fail"
return
}
errorf("%v.%v not in index", pkg, name) errorf("%v.%v not in index", pkg, name)
} }

View file

@ -21,3 +21,17 @@ func additionalPredeclared() []types.Type {
types.Universe.Lookup("any").Type(), types.Universe.Lookup("any").Type(),
} }
} }
// See cmd/compile/internal/types.SplitVargenSuffix.
func splitVargenSuffix(name string) (base, suffix string) {
i := len(name)
for i > 0 && name[i-1] >= '0' && name[i-1] <= '9' {
i--
}
const dot = "·"
if i >= len(dot) && name[i-len(dot):i] == dot {
i -= len(dot)
return name[:i], name[i:]
}
return name, ""
}

View file

@ -14,7 +14,7 @@ import (
"go/types" "go/types"
"strings" "strings"
"golang.org/x/tools/go/internal/pkgbits" "golang.org/x/tools/internal/pkgbits"
) )
// A pkgReader holds the shared state for reading a unified IR package // A pkgReader holds the shared state for reading a unified IR package
@ -490,6 +490,11 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
return objPkg, objName return objPkg, objName
} }
// Ignore local types promoted to global scope (#55110).
if _, suffix := splitVargenSuffix(objName); suffix != "" {
return objPkg, objName
}
if objPkg.Scope().Lookup(objName) == nil { if objPkg.Scope().Lookup(objName) == nil {
dict := pr.objDictIdx(idx) dict := pr.objDictIdx(idx)

71
vendor/golang.org/x/tools/internal/goroot/importcfg.go generated vendored Normal file
View file

@ -0,0 +1,71 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package goroot is a copy of package internal/goroot
// in the main GO repot. It provides a utility to produce
// an importcfg and import path to package file map mapping
// standard library packages to the locations of their export
// data files.
package goroot
import (
"bytes"
"fmt"
"os/exec"
"strings"
"sync"
)
// Importcfg returns an importcfg file to be passed to the
// Go compiler that contains the cached paths for the .a files for the
// standard library.
func Importcfg() (string, error) {
var icfg bytes.Buffer
m, err := PkgfileMap()
if err != nil {
return "", err
}
fmt.Fprintf(&icfg, "# import config")
for importPath, export := range m {
if importPath != "unsafe" && export != "" { // unsafe
fmt.Fprintf(&icfg, "\npackagefile %s=%s", importPath, export)
}
}
s := icfg.String()
return s, nil
}
var (
stdlibPkgfileMap map[string]string
stdlibPkgfileErr error
once sync.Once
)
// PkgfileMap returns a map of package paths to the location on disk
// of the .a file for the package.
// The caller must not modify the map.
func PkgfileMap() (map[string]string, error) {
once.Do(func() {
m := make(map[string]string)
output, err := exec.Command("go", "list", "-export", "-e", "-f", "{{.ImportPath}} {{.Export}}", "std", "cmd").Output()
if err != nil {
stdlibPkgfileErr = err
}
for _, line := range strings.Split(string(output), "\n") {
if line == "" {
continue
}
sp := strings.SplitN(line, " ", 2)
if len(sp) != 2 {
err = fmt.Errorf("determining pkgfile map: invalid line in go list output: %q", line)
return
}
importPath, export := sp[0], sp[1]
m[importPath] = export
}
stdlibPkgfileMap = m
})
return stdlibPkgfileMap, stdlibPkgfileErr
}

13
vendor/modules.txt vendored
View file

@ -352,8 +352,8 @@ github.com/mgechev/revive/config
github.com/mgechev/revive/formatter github.com/mgechev/revive/formatter
github.com/mgechev/revive/lint github.com/mgechev/revive/lint
github.com/mgechev/revive/rule github.com/mgechev/revive/rule
# github.com/miekg/dns v1.1.50 # github.com/miekg/dns v1.1.52
## explicit; go 1.14 ## explicit; go 1.19
github.com/miekg/dns github.com/miekg/dns
# github.com/mitchellh/go-homedir v1.1.0 # github.com/mitchellh/go-homedir v1.1.0
## explicit ## explicit
@ -598,7 +598,7 @@ golang.org/x/crypto/salsa20/salsa
# golang.org/x/exp v0.0.0-20221205204356-47842c84f3db # golang.org/x/exp v0.0.0-20221205204356-47842c84f3db
## explicit; go 1.18 ## explicit; go 1.18
golang.org/x/exp/constraints golang.org/x/exp/constraints
# golang.org/x/mod v0.6.0 # golang.org/x/mod v0.7.0
## explicit; go 1.17 ## explicit; go 1.17
golang.org/x/mod/internal/lazyregexp golang.org/x/mod/internal/lazyregexp
golang.org/x/mod/modfile golang.org/x/mod/modfile
@ -635,7 +635,7 @@ golang.org/x/text/transform
golang.org/x/text/unicode/bidi golang.org/x/text/unicode/bidi
golang.org/x/text/unicode/norm golang.org/x/text/unicode/norm
golang.org/x/text/width golang.org/x/text/width
# golang.org/x/tools v0.2.0 # golang.org/x/tools v0.3.0
## explicit; go 1.18 ## explicit; go 1.18
golang.org/x/tools/cover golang.org/x/tools/cover
golang.org/x/tools/go/analysis golang.org/x/tools/go/analysis
@ -686,9 +686,7 @@ golang.org/x/tools/go/buildutil
golang.org/x/tools/go/cfg golang.org/x/tools/go/cfg
golang.org/x/tools/go/gcexportdata golang.org/x/tools/go/gcexportdata
golang.org/x/tools/go/internal/cgo golang.org/x/tools/go/internal/cgo
golang.org/x/tools/go/internal/gcimporter
golang.org/x/tools/go/internal/packagesdriver golang.org/x/tools/go/internal/packagesdriver
golang.org/x/tools/go/internal/pkgbits
golang.org/x/tools/go/loader golang.org/x/tools/go/loader
golang.org/x/tools/go/packages golang.org/x/tools/go/packages
golang.org/x/tools/go/ssa golang.org/x/tools/go/ssa
@ -702,10 +700,13 @@ golang.org/x/tools/internal/event/core
golang.org/x/tools/internal/event/keys golang.org/x/tools/internal/event/keys
golang.org/x/tools/internal/event/label golang.org/x/tools/internal/event/label
golang.org/x/tools/internal/fastwalk golang.org/x/tools/internal/fastwalk
golang.org/x/tools/internal/gcimporter
golang.org/x/tools/internal/gocommand golang.org/x/tools/internal/gocommand
golang.org/x/tools/internal/gopathwalk golang.org/x/tools/internal/gopathwalk
golang.org/x/tools/internal/goroot
golang.org/x/tools/internal/imports golang.org/x/tools/internal/imports
golang.org/x/tools/internal/packagesinternal golang.org/x/tools/internal/packagesinternal
golang.org/x/tools/internal/pkgbits
golang.org/x/tools/internal/typeparams golang.org/x/tools/internal/typeparams
golang.org/x/tools/internal/typesinternal golang.org/x/tools/internal/typesinternal
# google.golang.org/genproto v0.0.0-20200707001353-8e8330bf89df # google.golang.org/genproto v0.0.0-20200707001353-8e8330bf89df