Skip to content

Commit 5ac410a

Browse files
authored
Merge branch 'multiformats:master' into feature/add-TLS-protocol
2 parents 99477a3 + 7cb054e commit 5ac410a

File tree

5 files changed

+81
-29
lines changed

5 files changed

+81
-29
lines changed

.github/workflows/automerge.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,35 @@
55
# This reduces the friction associated with updating with our workflows.
66

77
on: [ pull_request ]
8+
name: Automerge
89

910
jobs:
10-
automerge:
11+
automerge-check:
1112
if: github.event.pull_request.user.login == 'web3-bot'
1213
runs-on: ubuntu-latest
14+
outputs:
15+
status: ${{ steps.should-automerge.outputs.status }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- name: Check if we should automerge
21+
id: should-automerge
22+
run: |
23+
for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do
24+
committer=$(git show --format=$'%ce' -s $commit)
25+
echo "Committer: $committer"
26+
if [[ "$committer" != "[email protected]" ]]; then
27+
echo "Commit $commit wasn't committed by web3-bot, but by $committer."
28+
echo "::set-output name=status::false"
29+
exit
30+
fi
31+
done
32+
echo "::set-output name=status::true"
33+
automerge:
34+
needs: automerge-check
35+
runs-on: ubuntu-latest
36+
if: ${{ needs.automerge-check.outputs.status == 'true' }}
1337
steps:
1438
- name: Wait on tests
1539
uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2

.github/workflows/go-check.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,31 @@
22
# See https://github.com/protocol/.github/ for details.
33

44
on: [push, pull_request]
5+
name: Go Checks
56

67
jobs:
78
unit:
89
runs-on: ubuntu-latest
9-
name: Go checks
10+
name: All
1011
steps:
1112
- uses: actions/checkout@v2
13+
with:
14+
submodules: recursive
1215
- uses: actions/setup-go@v2
1316
with:
1417
go-version: "1.16.x"
1518
- name: Install staticcheck
16-
run: go install honnef.co/go/tools/cmd/staticcheck@be534f007836a777104a15f2456cd1fffd3ddee8 # v2020.2.2
19+
run: go install honnef.co/go/tools/cmd/staticcheck@434f5f3816b358fe468fa83dcba62d794e7fe04b # 2021.1 (v0.2.0)
1720
- name: Check that go.mod is tidy
18-
run: |
19-
go mod tidy
20-
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
21-
echo "go.sum was added by go mod tidy"
22-
exit 1
23-
fi
24-
git diff --exit-code -- go.sum go.mod
21+
uses: protocol/[email protected]
22+
with:
23+
run: |
24+
go mod tidy
25+
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
26+
echo "go.sum was added by go mod tidy"
27+
exit 1
28+
fi
29+
git diff --exit-code -- go.sum go.mod
2530
- name: gofmt
2631
if: ${{ success() || failure() }} # run this step even if the previous one failed
2732
run: |
@@ -32,10 +37,14 @@ jobs:
3237
fi
3338
- name: go vet
3439
if: ${{ success() || failure() }} # run this step even if the previous one failed
35-
run: go vet ./...
40+
uses: protocol/[email protected]
41+
with:
42+
run: go vet ./...
3643
- name: staticcheck
3744
if: ${{ success() || failure() }} # run this step even if the previous one failed
38-
run: |
39-
set -o pipefail
40-
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
45+
uses: protocol/[email protected]
46+
with:
47+
run: |
48+
set -o pipefail
49+
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
4150

.github/workflows/go-test.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# See https://github.com/protocol/.github/ for details.
33

44
on: [push, pull_request]
5+
name: Go Test
56

67
jobs:
78
unit:
@@ -11,9 +12,11 @@ jobs:
1112
os: [ "ubuntu", "windows", "macos" ]
1213
go: [ "1.15.x", "1.16.x" ]
1314
runs-on: ${{ matrix.os }}-latest
14-
name: Unit tests (${{ matrix.os}}, Go ${{ matrix.go }})
15+
name: ${{ matrix.os}} (go ${{ matrix.go }})
1516
steps:
1617
- uses: actions/checkout@v2
18+
with:
19+
submodules: recursive
1720
- uses: actions/setup-go@v2
1821
with:
1922
go-version: ${{ matrix.go }}
@@ -22,17 +25,23 @@ jobs:
2225
go version
2326
go env
2427
- name: Run tests
25-
run: go test -v -coverprofile coverage.txt ./...
28+
uses: protocol/[email protected]
29+
with:
30+
run: go test -v -coverprofile coverage.txt ./...
2631
- name: Run tests (32 bit)
2732
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
33+
uses: protocol/[email protected]
2834
env:
2935
GOARCH: 386
30-
run: go test -v ./...
36+
with:
37+
run: go test -v ./...
3138
- name: Run tests with race detector
3239
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
33-
run: go test -v -race ./...
40+
uses: protocol/[email protected]
41+
with:
42+
run: go test -v -race ./...
3443
- name: Upload coverage to Codecov
35-
uses: codecov/codecov-action@967e2b38a85a62bd61be5529ada27ebc109948c2 # v1.4.1
44+
uses: codecov/codecov-action@a1ed4b322b4b38cb846afb5a0ebfa17086917d27 # v1.5.0
3645
with:
3746
file: coverage.txt
3847
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}

net/net.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,16 @@ func (l *maListener) Accept() (Conn, error) {
248248
var raddr ma.Multiaddr
249249
// This block protects us in transports (i.e. unix sockets) that don't have
250250
// remote addresses for inbound connections.
251-
if nconn.RemoteAddr().String() != "" {
252-
raddr, err = FromNetAddr(nconn.RemoteAddr())
251+
if addr := nconn.RemoteAddr(); addr != nil && addr.String() != "" {
252+
raddr, err = FromNetAddr(addr)
253253
if err != nil {
254254
return nil, fmt.Errorf("failed to convert conn.RemoteAddr: %s", err)
255255
}
256256
}
257257

258258
var laddr ma.Multiaddr
259-
if nconn.LocalAddr().String() != "" {
260-
laddr, err = FromNetAddr(nconn.LocalAddr())
259+
if addr := nconn.LocalAddr(); addr != nil && addr.String() != "" {
260+
laddr, err = FromNetAddr(addr)
261261
if err != nil {
262262
return nil, fmt.Errorf("failed to convert conn.LocalAddr: %s", err)
263263
}

net/registry.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ type ToNetAddrFunc func(ma ma.Multiaddr) (net.Addr, error)
1717
var defaultCodecs = NewCodecMap()
1818

1919
func init() {
20-
defaultCodecs.RegisterFromNetAddr(parseTCPNetAddr, "tcp", "tcp4", "tcp6")
21-
defaultCodecs.RegisterFromNetAddr(parseUDPNetAddr, "udp", "udp4", "udp6")
22-
defaultCodecs.RegisterFromNetAddr(parseIPNetAddr, "ip", "ip4", "ip6")
23-
defaultCodecs.RegisterFromNetAddr(parseIPPlusNetAddr, "ip+net")
24-
defaultCodecs.RegisterFromNetAddr(parseUnixNetAddr, "unix")
20+
RegisterFromNetAddr(parseTCPNetAddr, "tcp", "tcp4", "tcp6")
21+
RegisterFromNetAddr(parseUDPNetAddr, "udp", "udp4", "udp6")
22+
RegisterFromNetAddr(parseIPNetAddr, "ip", "ip4", "ip6")
23+
RegisterFromNetAddr(parseIPPlusNetAddr, "ip+net")
24+
RegisterFromNetAddr(parseUnixNetAddr, "unix")
2525

26-
defaultCodecs.RegisterToNetAddr(parseBasicNetMaddr, "tcp", "udp", "ip6", "ip4", "unix")
26+
RegisterToNetAddr(parseBasicNetMaddr, "tcp", "udp", "ip6", "ip4", "unix")
2727
}
2828

2929
// CodecMap holds a map of NetCodecs indexed by their Protocol ID
@@ -77,6 +77,16 @@ func RegisterNetCodec(a *NetCodec) {
7777
defaultCodecs.RegisterNetCodec(a)
7878
}
7979

80+
// RegisterFromNetAddr registers a conversion from net.Addr instances to multiaddrs.
81+
func RegisterFromNetAddr(from FromNetAddrFunc, networks ...string) {
82+
defaultCodecs.RegisterFromNetAddr(from, networks...)
83+
}
84+
85+
// RegisterToNetAddr registers a conversion from multiaddrs to net.Addr instances.
86+
func RegisterToNetAddr(to ToNetAddrFunc, protocols ...string) {
87+
defaultCodecs.RegisterToNetAddr(to, protocols...)
88+
}
89+
8090
// RegisterNetCodec adds a new NetCodec to the CodecMap. This function is
8191
// thread safe.
8292
func (cm *CodecMap) RegisterNetCodec(a *NetCodec) {

0 commit comments

Comments
 (0)