Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p-quic-transport
Commits
37a190d7
Unverified
Commit
37a190d7
authored
Mar 18, 2017
by
Marten Seemann
Browse files
implement transport.Matches
parent
eb02a73d
Changes
2
Show whitespace changes
Inline
Side-by-side
transport.go
View file @
37a190d7
...
...
@@ -6,6 +6,7 @@ import (
pstore
"github.com/libp2p/go-libp2p-peerstore"
tpt
"github.com/libp2p/go-libp2p-transport"
ma
"github.com/multiformats/go-multiaddr"
"github.com/whyrusleeping/mafmt"
)
// QuicTransport implements a QUIC Transport
...
...
@@ -50,8 +51,8 @@ func (t *QuicTransport) Listen(laddr ma.Multiaddr) (tpt.Listener, error) {
return
ln
,
nil
}
func
(
t
*
QuicTransport
)
Matches
(
ma
.
Multiaddr
)
bool
{
panic
(
"not implemented"
)
func
(
t
*
QuicTransport
)
Matches
(
a
ma
.
Multiaddr
)
bool
{
return
mafmt
.
QUIC
.
Matches
(
a
)
}
var
_
tpt
.
Transport
=
&
QuicTransport
{}
transport_test.go
0 → 100644
View file @
37a190d7
package
libp2pquic
import
(
ma
"github.com/multiformats/go-multiaddr"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
)
var
_
=
Describe
(
"Transport"
,
func
()
{
var
t
*
QuicTransport
BeforeEach
(
func
()
{
t
=
NewQuicTransport
(
nil
)
})
It
(
"matches"
,
func
()
{
invalidAddr
,
err
:=
ma
.
NewMultiaddr
(
"/ip4/127.0.0.1/udp/1234"
)
Expect
(
err
)
.
ToNot
(
HaveOccurred
())
validAddr
,
err
:=
ma
.
NewMultiaddr
(
"/ip4/127.0.0.1/udp/1234/quic"
)
Expect
(
err
)
.
ToNot
(
HaveOccurred
())
Expect
(
t
.
Matches
(
invalidAddr
))
.
To
(
BeFalse
())
Expect
(
t
.
Matches
(
validAddr
))
.
To
(
BeTrue
())
})
})
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