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
936074ab
Unverified
Commit
936074ab
authored
Mar 17, 2017
by
Marten Seemann
Browse files
use conn wrapper functions to construct a go-libp2p-transport.Conn
parent
05430963
Changes
2
Hide whitespace changes
Inline
Side-by-side
conn.go
deleted
100644 → 0
View file @
05430963
package
libp2pquic
import
(
"net"
"time"
tpt
"github.com/libp2p/go-libp2p-transport"
ma
"github.com/multiformats/go-multiaddr"
)
type
conn
struct
{
quicConn
net
.
Conn
transport
tpt
.
Transport
}
func
(
c
*
conn
)
Read
(
p
[]
byte
)
(
int
,
error
)
{
return
c
.
quicConn
.
Read
(
p
)
}
func
(
c
*
conn
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
return
c
.
quicConn
.
Write
(
p
)
}
func
(
c
*
conn
)
Close
()
error
{
return
c
.
quicConn
.
Close
()
}
func
(
c
*
conn
)
LocalAddr
()
net
.
Addr
{
return
c
.
quicConn
.
LocalAddr
()
}
func
(
c
*
conn
)
RemoteAddr
()
net
.
Addr
{
return
c
.
quicConn
.
RemoteAddr
()
}
func
(
c
*
conn
)
LocalMultiaddr
()
ma
.
Multiaddr
{
panic
(
"not implemented"
)
}
func
(
c
*
conn
)
RemoteMultiaddr
()
ma
.
Multiaddr
{
panic
(
"not implemented"
)
}
func
(
c
*
conn
)
Transport
()
tpt
.
Transport
{
return
c
.
transport
}
func
(
c
*
conn
)
SetDeadline
(
t
time
.
Time
)
error
{
return
nil
}
func
(
c
*
conn
)
SetReadDeadline
(
t
time
.
Time
)
error
{
return
nil
}
func
(
c
*
conn
)
SetWriteDeadline
(
t
time
.
Time
)
error
{
return
nil
}
var
_
tpt
.
Conn
=
&
conn
{}
listener.go
View file @
936074ab
...
@@ -40,9 +40,15 @@ func (l *listener) Accept() (tpt.Conn, error) {
...
@@ -40,9 +40,15 @@ func (l *listener) Accept() (tpt.Conn, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
&
conn
{
quicConn
:
c
,
mnc
,
err
:=
manet
.
WrapNetConn
(
c
)
transport
:
l
.
transport
,
if
err
!=
nil
{
return
nil
,
err
}
return
&
tpt
.
ConnWrap
{
Conn
:
mnc
,
Tpt
:
l
.
transport
,
},
nil
},
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