Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-transport-upgrader
Commits
f5212e58
Commit
f5212e58
authored
Feb 04, 2021
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread underlying conn Stat to allow transports to propagate stat information
parent
a5591186
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
conn.go
conn.go
+5
-0
upgrader.go
upgrader.go
+6
-0
No files found.
conn.go
View file @
f5212e58
...
...
@@ -13,6 +13,7 @@ type transportConn struct {
network
.
ConnMultiaddrs
network
.
ConnSecurity
transport
transport
.
Transport
stat
network
.
Stat
}
func
(
t
*
transportConn
)
Transport
()
transport
.
Transport
{
...
...
@@ -33,3 +34,7 @@ func (t *transportConn) String() string {
t
.
RemotePeer
(),
)
}
func
(
t
*
transportConn
)
Stat
()
network
.
Stat
{
return
t
.
stat
}
upgrader.go
View file @
f5212e58
...
...
@@ -66,6 +66,11 @@ func (u *Upgrader) UpgradeInbound(ctx context.Context, t transport.Transport, ma
}
func
(
u
*
Upgrader
)
upgrade
(
ctx
context
.
Context
,
t
transport
.
Transport
,
maconn
manet
.
Conn
,
p
peer
.
ID
,
dir
network
.
Direction
)
(
transport
.
CapableConn
,
error
)
{
var
stat
network
.
Stat
if
cs
,
ok
:=
maconn
.
(
network
.
ConnStat
);
ok
{
stat
=
cs
.
Stat
()
}
var
conn
net
.
Conn
=
maconn
if
u
.
PSK
!=
nil
{
pconn
,
err
:=
pnet
.
NewProtectedConn
(
u
.
PSK
,
conn
)
...
...
@@ -107,6 +112,7 @@ func (u *Upgrader) upgrade(ctx context.Context, t transport.Transport, maconn ma
ConnMultiaddrs
:
maconn
,
ConnSecurity
:
sconn
,
transport
:
t
,
stat
:
stat
,
}
return
tc
,
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