-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
501ede1
to
58c1e1e
Compare
panic(err) | ||
} | ||
|
||
for _, tp := range tps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there equivalent code for this or is it handled in a different manner now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's handled by the swarm internally. See: libp2p/go-addr-util#11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the swarm explicitly aware of relay addresses or does it ask the transports dynamically to respond whether they support the address?
If so, how are encapsulations handled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The swarm asks its transports.
For listening, we just figure out which transport is responsible using the algorithm described here and ask it to listen on the address.
For dialing, we lookup the appropriate transport (same algorithm) and call the CanDial
function on it (code). We could just try dialing but this way allows us to filter out addresses we definitely can't dial higher up the stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear it will have the same behaviour -- for example we want to pick up relay for /ip4/X.X.X.X/tcp/YY/ipfs/Qmfoo//p2p-circuit/ip4/X.X.X.X/tcp/YY/ipfs/Qmbar
(that's explicit relay dialing).
What will the algorithm pick here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how that's related to this function but it will pick the relay transport. It'll:
- Iterate over the protocols (ip4, tcp, ipfs, p2p-circuit, ip4, tcp, ipfs).
- When it gets to the p2p-circuit protocol, it will notice that the associated transport is a
Proxy
transport and will pass the address off to that transport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, being a proxy is the key feature.
deb6334
to
22305ab
Compare
transport.go
Outdated
if !t.Matches(laddr) { | ||
func (t *RelayTransport) Listen(laddr ma.Multiaddr) (tpt.Listener, error) { | ||
protos := laddr.Protocols() | ||
if len(protos) == 0 || protos[len(protos)-1].Code == P_CIRCUIT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by this -- you fail with "not a relay address" if it's the passive relay address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting... So, I intended to write !=
however, that wouldn't have worked because we listen with /p2p-circuit/ipfs/QmId
. Really, it should support both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I wanted the check to be a bit more specific than "has a p2p-circuit protocol". However, I'll have to consider carefully how to do this properly.
c799cc4
to
7fcacee
Compare
@@ -54,8 +57,9 @@ func (e RelayError) Error() string { | |||
return fmt.Sprintf("error opening relay circuit: %s (%d)", pb.CircuitRelay_Status_name[int32(e.Code)], e.Code) | |||
} | |||
|
|||
func NewRelay(ctx context.Context, h host.Host, opts ...RelayOpt) (*Relay, error) { | |||
func NewRelay(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) (*Relay, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does one get a transport upgrader?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We construct it when constructing the transports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, this looks good.
e603515
to
c24509e
Compare
DO NOT MERGE (yet)
Part of: libp2p/go-libp2p#297
(tests failing as gx deps need updating)