Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Commit 9e6dd2b

Browse files
committed
fix: expose full multiaddrs from conn.RemoteMultiaddr
There's no reason _not_ to do this.
1 parent 64eca16 commit 9e6dd2b

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

conn.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,7 @@ func (c *Conn) untagHop() {
8080

8181
// TODO: is it okay to cast c.Conn().RemotePeer() into a multiaddr? might be "user input"
8282
func (c *Conn) RemoteMultiaddr() ma.Multiaddr {
83-
proto := ma.ProtocolWithCode(ma.P_P2P).Name
84-
peerid := c.stream.Conn().RemotePeer().Pretty()
85-
p2paddr := ma.StringCast(fmt.Sprintf("/%s/%s", proto, peerid))
86-
87-
circaddr := ma.Cast(ma.CodeToVarint(P_CIRCUIT))
88-
return p2paddr.Encapsulate(circaddr)
83+
return c.stream.Conn().RemoteMultiaddr().Encapsulate(circuitAddr)
8984
}
9085

9186
func (c *Conn) LocalMultiaddr() ma.Multiaddr {

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ require (
1111
github.com/multiformats/go-multiaddr v0.0.4
1212
github.com/multiformats/go-multiaddr-net v0.0.1
1313
)
14+
15+
go 1.12

listen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (l *RelayListener) Addr() net.Addr {
5050
}
5151

5252
func (l *RelayListener) Multiaddr() ma.Multiaddr {
53-
return ma.Cast(ma.CodeToVarint(P_CIRCUIT))
53+
return circuitAddr
5454
}
5555

5656
func (l *RelayListener) Close() error {

transport.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ var Protocol = ma.Protocol{
2020
VCode: ma.CodeToVarint(P_CIRCUIT),
2121
}
2222

23+
var circuitAddr ma.Multiaddr = ma.Cast(Protocol.VCode)
24+
2325
func init() {
2426
ma.AddProtocol(Protocol)
2527
}

0 commit comments

Comments
 (0)