Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
07adec3b
Unverified
Commit
07adec3b
authored
Jun 10, 2020
by
Ivan Vandot
Committed by
GitHub
Jun 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dns discovery (#276)
parent
6187edf0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
18 deletions
+113
-18
beekeeper-dns-disco.yaml
.github/workflows/beekeeper-dns-disco.yaml
+38
-0
go.mod
go.mod
+1
-0
go.sum
go.sum
+1
-0
node.go
pkg/node/node.go
+29
-18
discover.go
pkg/p2p/discover.go
+44
-0
No files found.
.github/workflows/beekeeper-dns-disco.yaml
0 → 100644
View file @
07adec3b
name
:
BeekeeperDNSDisco
on
:
push
:
branches
:
-
master
jobs
:
beekeeper
:
env
:
REPLICA
:
3
runs-on
:
ubuntu-latest
steps
:
-
uses
:
actions/checkout@v1
-
name
:
Install bee-local
run
:
|
export URL=$(curl -s https://api.github.com/repos/ethersphere/bee-local/releases/latest | jq -r .tarball_url)
curl -Ls ${URL} -o bee-local.tar.gz
tar --strip-components=1 --wildcards -xzf bee-local.tar.gz ethersphere-bee-local-*/{beeinfra.sh,helm-values,hack}
-
name
:
Install latest beekeeper
run
:
|
export TAG=$(curl -s https://api.github.com/repos/ethersphere/beekeeper/releases/latest | jq -r .tag_name)
curl -Ls https://github.com/ethersphere/beekeeper/releases/download/${TAG}/beekeeper-linux-amd64 -o beekeeper
chmod +x beekeeper
-
name
:
Add entries to /etc/hosts
run
:
|
echo -e "127.0.0.10\tregistry.localhost" | sudo tee -a /etc/hosts
for ((i=0; i<REPLICA; i++)); do echo -e "127.0.1.$((i+1))\tbee-${i}.localhost bee-${i}-debug.localhost"; done | sudo tee -a /etc/hosts
-
name
:
Set testing cluster
run
:
./beeinfra.sh install --dns-disco --local -r "${REPLICA}"
-
name
:
Test fullconnectivity
run
:
./beekeeper check fullconnectivity --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}"
-
name
:
Test pingpong
run
:
./beekeeper check pingpong --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}"
-
name
:
Test pushsync (bzz API)
run
:
./beekeeper check pushsync --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" --chunks-per-node
3
-
name
:
Test pushsync (bzz-chunk API)
run
:
./beekeeper check pushsync --bzz-chunk --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" --chunks-per-node
3
go.mod
View file @
07adec3b
...
...
@@ -21,6 +21,7 @@ require (
github.com/libp2p/go-ws-transport v0.2.0
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/multiformats/go-multiaddr v0.2.0
github.com/multiformats/go-multiaddr-dns v0.2.0
github.com/multiformats/go-multistream v0.1.0
github.com/opentracing/opentracing-go v1.1.0
github.com/prometheus/client_golang v1.3.0
...
...
go.sum
View file @
07adec3b
...
...
@@ -225,6 +225,7 @@ github.com/libp2p/go-libp2p-core v0.2.4/go.mod h1:STh4fdfa5vDYr0/SzYYeqnt+E6KfEV
github.com/libp2p/go-libp2p-core v0.2.5/go.mod h1:6+5zJmKhsf7yHn1RbmYDu08qDUpIUxGdqHuEZckmZOA=
github.com/libp2p/go-libp2p-core v0.3.0 h1:F7PqduvrztDtFsAa/bcheQ3azmNo+Nq7m8hQY5GiUW8=
github.com/libp2p/go-libp2p-core v0.3.0/go.mod h1:ACp3DmS3/N64c2jDzcV429ukDpicbL6+TrrxANBjPGw=
github.com/libp2p/go-libp2p-core v0.5.6 h1:IxFH4PmtLlLdPf4fF/i129SnK/C+/v8WEX644MxhC48=
github.com/libp2p/go-libp2p-crypto v0.1.0/go.mod h1:sPUokVISZiy+nNuTTH/TY+leRSxnFj/2GLjtOTW90hI=
github.com/libp2p/go-libp2p-discovery v0.1.0/go.mod h1:4F/x+aldVHjHDHuX85x1zWoFTGElt8HnoDzwkFZm29g=
github.com/libp2p/go-libp2p-discovery v0.2.0 h1:1p3YSOq7VsgaL+xVHPi8XAmtGyas6D2J6rWBEfz/aiY=
...
...
pkg/node/node.go
View file @
07adec3b
...
...
@@ -28,6 +28,7 @@ import (
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/metrics"
"github.com/ethersphere/bee/pkg/netstore"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p/libp2p"
"github.com/ethersphere/bee/pkg/pingpong"
"github.com/ethersphere/bee/pkg/pusher"
...
...
@@ -352,12 +353,13 @@ func NewBee(o Options) (*Bee, error) {
logger
.
Errorf
(
"connect to bootnode %s"
,
a
)
return
}
var
count
int
if
_
,
err
:=
p2p
.
Discover
(
p2pCtx
,
addr
,
func
(
addr
ma
.
Multiaddr
)
(
stop
bool
,
err
error
)
{
bzzAddr
,
err
:=
p2ps
.
Connect
(
p2pCtx
,
addr
)
if
err
!=
nil
{
logger
.
Debugf
(
"connect fail %s: %v"
,
a
,
err
)
logger
.
Errorf
(
"connect to bootnode %s"
,
a
)
return
return
false
,
nil
}
err
=
addressbook
.
Put
(
bzzAddr
.
Overlay
,
*
bzzAddr
)
...
...
@@ -365,13 +367,22 @@ func NewBee(o Options) (*Bee, error) {
_
=
p2ps
.
Disconnect
(
bzzAddr
.
Overlay
)
logger
.
Debugf
(
"addressbook error persisting %s %s: %v"
,
a
,
bzzAddr
.
Overlay
,
err
)
logger
.
Errorf
(
"connect to bootnode %s"
,
a
)
return
return
false
,
nil
}
if
err
:=
topologyDriver
.
Connected
(
p2pCtx
,
bzzAddr
.
Overlay
);
err
!=
nil
{
_
=
p2ps
.
Disconnect
(
bzzAddr
.
Overlay
)
logger
.
Debugf
(
"topology connected fail %s %s: %v"
,
a
,
bzzAddr
.
Overlay
,
err
)
logger
.
Errorf
(
"connect to bootnode %s"
,
a
)
return
false
,
nil
}
count
++
// connect to max 3 bootnodes
// using DNS discovery one node is discovered twice (TCP and UDP)
return
count
>
6
,
nil
});
err
!=
nil
{
logger
.
Debugf
(
"connect fail %s: %v"
,
a
,
err
)
logger
.
Errorf
(
"connect to bootnode %s"
,
a
)
return
}
}(
a
)
...
...
pkg/p2p/discover.go
0 → 100644
View file @
07adec3b
// Copyright 2020 The Swarm 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
p2p
import
(
"context"
"errors"
"math/rand"
ma
"github.com/multiformats/go-multiaddr"
madns
"github.com/multiformats/go-multiaddr-dns"
)
func
Discover
(
ctx
context
.
Context
,
addr
ma
.
Multiaddr
,
f
func
(
ma
.
Multiaddr
)
(
stop
bool
,
err
error
))
(
stopped
bool
,
err
error
)
{
if
comp
,
_
:=
ma
.
SplitFirst
(
addr
);
comp
.
Protocol
()
.
Name
!=
"dnsaddr"
{
return
f
(
addr
)
}
dnsResolver
:=
madns
.
DefaultResolver
addrs
,
err
:=
dnsResolver
.
Resolve
(
ctx
,
addr
)
if
err
!=
nil
{
return
false
,
err
}
if
len
(
addrs
)
==
0
{
return
false
,
errors
.
New
(
"non-resolvable API endpoint"
)
}
rand
.
Shuffle
(
len
(
addrs
),
func
(
i
,
j
int
)
{
addrs
[
i
],
addrs
[
j
]
=
addrs
[
j
],
addrs
[
i
]
})
for
_
,
addr
:=
range
addrs
{
stopped
,
err
=
Discover
(
ctx
,
addr
,
f
)
if
err
!=
nil
{
return
false
,
err
}
if
stopped
{
break
}
}
return
false
,
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment