update dependencies to work with update eth-block-extractor

This commit is contained in:
Ian Norden
2019-12-02 13:24:49 -06:00
parent 31a9017c4f
commit d702cb720c
3000 changed files with 433987 additions and 182448 deletions
@@ -0,0 +1 @@
/madns/madns
+32
View File
@@ -0,0 +1,32 @@
os:
- linux
language: go
go:
- 1.11.x
env:
global:
- GOTFLAGS="-race"
matrix:
- BUILD_DEPTYPE=gx
- BUILD_DEPTYPE=gomod
# disable travis install
install:
- true
script:
- bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh)
cache:
directories:
- $GOPATH/src/gx
- $GOPATH/pkg/mod
- /home/travis/.cache/go-build
notifications:
email: false
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Juan Batiz-Benet
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+57
View File
@@ -0,0 +1,57 @@
# go-multiaddr-dns
> Resolve /dns4, /dns6, and /dnsaddr multiaddrs.
```sh
> madns /dnsaddr/ipfs.io/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
/ip6/2604:a880:1:20::1d9:6001/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
/ip6/fc3d:9a4e:3c96:2fd2:1afa:18fe:8dd2:b602/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
/dns4/jupiter.i.ipfs.io/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
/dns6/jupiter.i.ipfs.io/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
```
In more detail:
```sh
> madns /dns6/example.net
/ip6/2001:db8::a3
/ip6/2001:db8::a4
...
> madns /dns4/example.net/tcp/443/wss
/ip4/192.0.2.1/tcp/443/wss
/ip4/192.0.2.2/tcp/443/wss
# No-op if it's not a dns-ish address.
> madns /ip4/127.0.0.1/tcp/8080
/ip4/127.0.0.1/tcp/8080
# /dnsaddr resolves by looking up TXT records.
> dig +short TXT _dnsaddr.example.net
"dnsaddr=/ip6/2001:db8::a3/tcp/443/wss/ipfs/Qmfoo"
"dnsaddr=/ip6/2001:db8::a4/tcp/443/wss/ipfs/Qmbar"
"dnsaddr=/ip4/192.0.2.1/tcp/443/wss/ipfs/Qmfoo"
"dnsaddr=/ip4/192.0.2.2/tcp/443/wss/ipfs/Qmbar"
...
# /dnsaddr returns addrs which encapsulate whatever /dnsaddr encapsulates too.
> madns example.net/ipfs/Qmfoo
info: changing query to /dnsaddr/example.net/ipfs/Qmfoo
/ip6/2001:db8::a3/tcp/443/wss/ipfs/Qmfoo
/ip4/192.0.2.1/tcp/443/wss/ipfs/Qmfoo
# TODO -p filters by protocol stacks.
> madns -p /ip6/tcp/wss /dnsaddr/example.net
/ip6/2001:db8::a3/tcp/443/wss/ipfs/Qmfoo
/ip6/2001:db8::a4/tcp/443/wss/ipfs/Qmbar
# TOOD -c filters by CIDR
> madns -c /ip4/104.236.76.0/ipcidr/24 /dnsaddr/example.net
/ip4/192.0.2.2/tcp/443/wss/ipfs/Qmbar
```
+69
View File
@@ -0,0 +1,69 @@
package madns
import (
"bytes"
"fmt"
ma "github.com/multiformats/go-multiaddr"
)
// Extracted from source of truth for multicodec codes: https://github.com/multiformats/multicodec
const (
P_DNS4 = 0x0036
P_DNS6 = 0x0037
P_DNSADDR = 0x0038
)
var Dns4Protocol = ma.Protocol{
Code: P_DNS4,
Size: ma.LengthPrefixedVarSize,
Name: "dns4",
VCode: ma.CodeToVarint(P_DNS4),
Transcoder: DnsTranscoder,
}
var Dns6Protocol = ma.Protocol{
Code: P_DNS6,
Size: ma.LengthPrefixedVarSize,
Name: "dns6",
VCode: ma.CodeToVarint(P_DNS6),
Transcoder: DnsTranscoder,
}
var DnsaddrProtocol = ma.Protocol{
Code: P_DNSADDR,
Size: ma.LengthPrefixedVarSize,
Name: "dnsaddr",
VCode: ma.CodeToVarint(P_DNSADDR),
Transcoder: DnsTranscoder,
}
func init() {
err := ma.AddProtocol(Dns4Protocol)
if err != nil {
panic(fmt.Errorf("error registering dns4 protocol: %s", err))
}
err = ma.AddProtocol(Dns6Protocol)
if err != nil {
panic(fmt.Errorf("error registering dns6 protocol: %s", err))
}
err = ma.AddProtocol(DnsaddrProtocol)
if err != nil {
panic(fmt.Errorf("error registering dnsaddr protocol: %s", err))
}
}
var DnsTranscoder = ma.NewTranscoderFromFunctions(dnsStB, dnsBtS, dnsVal)
func dnsVal(b []byte) error {
if bytes.IndexByte(b, '/') >= 0 {
return fmt.Errorf("domain name %q contains a slash", string(b))
}
return nil
}
func dnsStB(s string) ([]byte, error) {
return []byte(s), nil
}
func dnsBtS(b []byte) (string, error) {
return string(b), nil
}
+3
View File
@@ -0,0 +1,3 @@
module github.com/multiformats/go-multiaddr-dns
require github.com/multiformats/go-multiaddr v0.0.1
+18
View File
@@ -0,0 +1,18 @@
github.com/gxed/hashland/keccakpg v0.0.1 h1:wrk3uMNaMxbXiHibbPO4S0ymqJMm41WiudyFSs7UnsU=
github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU=
github.com/gxed/hashland/murmur3 v0.0.1 h1:SheiaIt0sda5K+8FLz952/1iWS9zrnKsEJaOJu4ZbSc=
github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16 h1:5W7KhL8HVF3XCFOweFD3BNESdnO8ewyYTFT2R+/b8FQ=
github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
github.com/mr-tron/base58 v1.1.0 h1:Y51FGVJ91WBqCEabAi5OPUz38eAx8DakuAm5svLcsfQ=
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
github.com/multiformats/go-multiaddr v0.0.1 h1:/QUV3VBMDI6pi6xfiw7lr6xhDWWvQKn9udPn68kLSdY=
github.com/multiformats/go-multiaddr v0.0.1/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44=
github.com/multiformats/go-multihash v0.0.1 h1:HHwN1K12I+XllBCrqKnhX949Orn4oawPkegHMu2vDqQ=
github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20190219092855-153ac476189d h1:Z0Ahzd7HltpJtjAHHxX8QFP3j1yYgiuvjbjRzDj/KH0=
golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+24
View File
@@ -0,0 +1,24 @@
{
"author": "lgierth",
"bugs": {
"url": "https://github.com/multiformats/go-multiaddr-dns/issues"
},
"gx": {
"dvcsimport": "github.com/multiformats/go-multiaddr-dns"
},
"gxDependencies": [
{
"author": "multiformats",
"hash": "QmTZBfrPJmjWsCvHEtX5FE6KimVJhsJg5sBbqEFYf4UZtL",
"name": "go-multiaddr",
"version": "1.4.1"
}
],
"gxVersion": "0.10.0",
"language": "go",
"license": "MIT",
"name": "go-multiaddr-dns",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "0.3.2"
}
+181
View File
@@ -0,0 +1,181 @@
package madns
import (
"context"
"fmt"
"net"
"strings"
ma "github.com/multiformats/go-multiaddr"
)
var ResolvableProtocols = []ma.Protocol{DnsaddrProtocol, Dns4Protocol, Dns6Protocol}
var DefaultResolver = &Resolver{Backend: net.DefaultResolver}
type backend interface {
LookupIPAddr(context.Context, string) ([]net.IPAddr, error)
LookupTXT(context.Context, string) ([]string, error)
}
type Resolver struct {
Backend backend
}
type MockBackend struct {
IP map[string][]net.IPAddr
TXT map[string][]string
}
func (r *MockBackend) LookupIPAddr(ctx context.Context, name string) ([]net.IPAddr, error) {
results, ok := r.IP[name]
if ok {
return results, nil
} else {
return []net.IPAddr{}, nil
}
}
func (r *MockBackend) LookupTXT(ctx context.Context, name string) ([]string, error) {
results, ok := r.TXT[name]
if ok {
return results, nil
} else {
return []string{}, nil
}
}
func Matches(maddr ma.Multiaddr) bool {
protos := maddr.Protocols()
if len(protos) == 0 {
return false
}
for _, p := range ResolvableProtocols {
if protos[0].Code == p.Code {
return true
}
}
return false
}
func Resolve(ctx context.Context, maddr ma.Multiaddr) ([]ma.Multiaddr, error) {
return DefaultResolver.Resolve(ctx, maddr)
}
func (r *Resolver) Resolve(ctx context.Context, maddr ma.Multiaddr) ([]ma.Multiaddr, error) {
if !Matches(maddr) {
return []ma.Multiaddr{maddr}, nil
}
protos := maddr.Protocols()
if protos[0].Code == Dns4Protocol.Code {
return r.resolveDns4(ctx, maddr)
}
if protos[0].Code == Dns6Protocol.Code {
return r.resolveDns6(ctx, maddr)
}
if protos[0].Code == DnsaddrProtocol.Code {
return r.resolveDnsaddr(ctx, maddr)
}
panic("unreachable")
}
func (r *Resolver) resolveDns4(ctx context.Context, maddr ma.Multiaddr) ([]ma.Multiaddr, error) {
value, err := maddr.ValueForProtocol(Dns4Protocol.Code)
if err != nil {
return nil, fmt.Errorf("error resolving %s: %s", maddr.String(), err)
}
encap := ma.Split(maddr)[1:]
result := []ma.Multiaddr{}
records, err := r.Backend.LookupIPAddr(ctx, value)
if err != nil {
return result, err
}
for _, r := range records {
ip4 := r.IP.To4()
if ip4 == nil {
continue
}
ip4maddr, err := ma.NewMultiaddr("/ip4/" + ip4.String())
if err != nil {
return result, err
}
parts := append([]ma.Multiaddr{ip4maddr}, encap...)
result = append(result, ma.Join(parts...))
}
return result, nil
}
func (r *Resolver) resolveDns6(ctx context.Context, maddr ma.Multiaddr) ([]ma.Multiaddr, error) {
value, err := maddr.ValueForProtocol(Dns6Protocol.Code)
if err != nil {
return nil, fmt.Errorf("error resolving %s: %s", maddr.String(), err)
}
encap := ma.Split(maddr)[1:]
result := []ma.Multiaddr{}
records, err := r.Backend.LookupIPAddr(ctx, value)
if err != nil {
return result, err
}
for _, r := range records {
if r.IP.To4() != nil {
continue
}
ip6maddr, err := ma.NewMultiaddr("/ip6/" + r.IP.To16().String())
if err != nil {
return result, err
}
parts := append([]ma.Multiaddr{ip6maddr}, encap...)
result = append(result, ma.Join(parts...))
}
return result, nil
}
func (r *Resolver) resolveDnsaddr(ctx context.Context, maddr ma.Multiaddr) ([]ma.Multiaddr, error) {
value, err := maddr.ValueForProtocol(DnsaddrProtocol.Code)
if err != nil {
return nil, fmt.Errorf("error resolving %s: %s", maddr.String(), err)
}
trailer := ma.Split(maddr)[1:]
result := []ma.Multiaddr{}
records, err := r.Backend.LookupTXT(ctx, "_dnsaddr."+value)
if err != nil {
return result, err
}
for _, r := range records {
rv := strings.Split(r, "dnsaddr=")
if len(rv) != 2 {
continue
}
rmaddr, err := ma.NewMultiaddr(rv[1])
if err != nil {
return result, err
}
if matchDnsaddr(rmaddr, trailer) {
result = append(result, rmaddr)
}
}
return result, nil
}
// XXX probably insecure
func matchDnsaddr(maddr ma.Multiaddr, trailer []ma.Multiaddr) bool {
parts := ma.Split(maddr)
if ma.Join(parts[len(parts)-len(trailer):]...).Equal(ma.Join(trailer...)) {
return true
}
return false
}