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
4c75c749
Unverified
Commit
4c75c749
authored
Apr 08, 2020
by
Janoš Guljaš
Committed by
GitHub
Apr 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add debug api overlay address endpoint (#78)
parent
a8afbded
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
5 deletions
+18
-5
debugapi.go
pkg/debugapi/debugapi.go
+2
-0
debugapi_test.go
pkg/debugapi/debugapi_test.go
+4
-1
p2p.go
pkg/debugapi/p2p.go
+6
-3
p2p_test.go
pkg/debugapi/p2p_test.go
+5
-1
node.go
pkg/node/node.go
+1
-0
No files found.
pkg/debugapi/debugapi.go
View file @
4c75c749
...
...
@@ -10,6 +10,7 @@ import (
"github.com/ethersphere/bee/pkg/addressbook"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/topology"
"github.com/prometheus/client_golang/prometheus"
)
...
...
@@ -27,6 +28,7 @@ type server struct {
}
type
Options
struct
{
Overlay
swarm
.
Address
P2P
p2p
.
Service
Addressbook
addressbook
.
GetPutter
TopologyDriver
topology
.
PeerAdder
...
...
pkg/debugapi/debugapi_test.go
View file @
4c75c749
...
...
@@ -16,13 +16,15 @@ import (
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/topology/mock"
"github.com/multiformats/go-multiaddr"
"resenje.org/web"
)
type
testServerOptions
struct
{
P2P
p2p
.
Service
Overlay
swarm
.
Address
P2P
p2p
.
Service
}
type
testServer
struct
{
...
...
@@ -37,6 +39,7 @@ func newTestServer(t *testing.T, o testServerOptions) *testServer {
topologyDriver
:=
mock
.
NewTopologyDriver
()
s
:=
debugapi
.
New
(
debugapi
.
Options
{
Overlay
:
o
.
Overlay
,
P2P
:
o
.
P2P
,
Logger
:
logging
.
New
(
ioutil
.
Discard
,
0
),
Addressbook
:
addressbook
,
...
...
pkg/debugapi/p2p.go
View file @
4c75c749
...
...
@@ -8,21 +8,24 @@ import (
"net/http"
"github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/multiformats/go-multiaddr"
)
type
addressesResponse
struct
{
Addresses
[]
multiaddr
.
Multiaddr
`json:"addresses"`
Overlay
swarm
.
Address
`json:"overlay"`
Underlay
[]
multiaddr
.
Multiaddr
`json:"underlay"`
}
func
(
s
*
server
)
addressesHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
addresses
,
err
:=
s
.
P2P
.
Addresses
()
underlay
,
err
:=
s
.
P2P
.
Addresses
()
if
err
!=
nil
{
s
.
Logger
.
Debugf
(
"debug api: p2p addresses: %v"
,
err
)
jsonhttp
.
InternalServerError
(
w
,
err
)
return
}
jsonhttp
.
OK
(
w
,
addressesResponse
{
Addresses
:
addresses
,
Overlay
:
s
.
Overlay
,
Underlay
:
underlay
,
})
}
pkg/debugapi/p2p_test.go
View file @
4c75c749
...
...
@@ -13,10 +13,12 @@ import (
"github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
"github.com/ethersphere/bee/pkg/p2p/mock"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/multiformats/go-multiaddr"
)
func
TestAddresses
(
t
*
testing
.
T
)
{
overlay
:=
swarm
.
MustParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
addresses
:=
[]
multiaddr
.
Multiaddr
{
mustMultiaddr
(
t
,
"/ip4/127.0.0.1/tcp/7071/p2p/16Uiu2HAmTBuJT9LvNmBiQiNoTsxE5mtNy6YG3paw79m94CRa9sRb"
),
mustMultiaddr
(
t
,
"/ip4/192.168.0.101/tcp/7071/p2p/16Uiu2HAmTBuJT9LvNmBiQiNoTsxE5mtNy6YG3paw79m94CRa9sRb"
),
...
...
@@ -24,6 +26,7 @@ func TestAddresses(t *testing.T) {
}
testServer
:=
newTestServer
(
t
,
testServerOptions
{
Overlay
:
overlay
,
P2P
:
mock
.
New
(
mock
.
WithAddressesFunc
(
func
()
([]
multiaddr
.
Multiaddr
,
error
)
{
return
addresses
,
nil
})),
...
...
@@ -32,7 +35,8 @@ func TestAddresses(t *testing.T) {
t
.
Run
(
"ok"
,
func
(
t
*
testing
.
T
)
{
jsonhttptest
.
ResponseDirect
(
t
,
testServer
.
Client
,
http
.
MethodGet
,
"/addresses"
,
nil
,
http
.
StatusOK
,
debugapi
.
AddressesResponse
{
Addresses
:
addresses
,
Overlay
:
overlay
,
Underlay
:
addresses
,
})
})
...
...
pkg/node/node.go
View file @
4c75c749
...
...
@@ -195,6 +195,7 @@ func NewBee(o Options) (*Bee, error) {
if
o
.
DebugAPIAddr
!=
""
{
// Debug API server
debugAPIService
:=
debugapi
.
New
(
debugapi
.
Options
{
Overlay
:
address
,
P2P
:
p2ps
,
Logger
:
logger
,
Addressbook
:
addressbook
,
...
...
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