-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circuit Relay integration #4091
Merged
+219
−8
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ba5940e
integrate circuit-relay transport
vyzo 4900935
account for p2p-circuit address intricacies
vyzo 1f40c52
test/sharness: circuit relay test
vyzo 98da085
test/sharness: extended circuit relay test
vyzo 6c63cec
swarm: more robust logic in remote address printing
vyzo 3e7dce2
ipfsaddr: add TODO comment to clean up p2p-circuit special case
vyzo 9d15e63
core: address factory composition for constructPeerHost
vyzo 16247cb
docs/config: document relay options
vyzo 4f39962
fix competing address factories in host options
vyzo 6f54181
ipfs swarm addrs listen command, fix t0060-daemon
vyzo d7922e7
more descriptive help message for ipfs swarm addrs local
vyzo 1141705
gx: update go-libp2p-circuit
vyzo a130659
don't hardcode ipfs protocol name in multiaddr display
vyzo 31e3b8f
simplify code for ipfs protocol scheme in multiaddr display
vyzo 322bb98
don't leak host in case of error adding relay
vyzo b6150b2
make filterRelayAddrs a named function, not a closure
vyzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/sh | ||
|
||
test_description="Test circuit relay" | ||
|
||
. lib/test-lib.sh | ||
|
||
# start iptb + wait for peering | ||
NUM_NODES=3 | ||
test_expect_success 'init iptb' ' | ||
iptb init -n $NUM_NODES --bootstrap=none --port=0 | ||
' | ||
|
||
# Network toplogy: A <-> Relay <-> B | ||
test_expect_success 'start up nodes for configuration' ' | ||
iptb start --args --routing=none | ||
' | ||
|
||
test_expect_success 'configure EnableRelayHop in relay node' ' | ||
ipfsi 1 config --json Swarm.EnableRelayHop true | ||
' | ||
|
||
test_expect_success 'restart nodes' ' | ||
iptb stop && | ||
iptb start --args --routing=none | ||
' | ||
|
||
test_expect_success 'connect A <-> Relay' ' | ||
iptb connect 0 1 | ||
' | ||
|
||
test_expect_success 'connect B <-> Relay' ' | ||
iptb connect 2 1 | ||
' | ||
|
||
test_expect_success 'wait until relay is ready to do work' ' | ||
sleep 1 | ||
' | ||
|
||
test_expect_success 'peer ids' ' | ||
PEERID_0=$(iptb get id 0) && | ||
PEERID_1=$(iptb get id 1) && | ||
PEERID_2=$(iptb get id 2) | ||
' | ||
|
||
test_expect_success 'connect A <-Relay-> B' ' | ||
ipfsi 0 swarm connect /p2p-circuit/ipfs/$PEERID_2 > peers_out | ||
' | ||
|
||
test_expect_success 'output looks good' ' | ||
echo "connect $PEERID_2 success" > peers_exp && | ||
test_cmp peers_exp peers_out | ||
' | ||
|
||
test_expect_success 'peers for A look good' ' | ||
ipfsi 0 swarm peers | grep p2p-circuit > peers_out && | ||
echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_2" > peers_exp && | ||
test_cmp peers_exp peers_out | ||
' | ||
|
||
test_expect_success 'peers for B look good' ' | ||
ipfsi 2 swarm peers | grep p2p-circuit > peers_out && | ||
echo "/ipfs/$PEERID_1/p2p-circuit/ipfs/$PEERID_0" > peers_exp && | ||
test_cmp peers_exp peers_out | ||
' | ||
|
||
test_expect_success 'add an object in A' ' | ||
echo "hello relay" | ipfsi 0 add > peers_out | ||
' | ||
|
||
test_expect_success 'object ID' ' | ||
OBJID=$(cut -f3 -d " " peers_out) | ||
' | ||
|
||
test_expect_success 'cat the object in B' ' | ||
ipfsi 2 cat $OBJID > peers_out | ||
' | ||
|
||
test_expect_success 'output looks good' ' | ||
echo "hello relay" > peers_exp && | ||
test_cmp peers_exp peers_out | ||
' | ||
|
||
test_expect_success 'stop iptb' ' | ||
iptb stop | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import ( | |
ma "gx/ipfs/QmXY77cVe7rVRQXZZQRioukUM7aRW3BTcAgJe12MCtb3Ji/go-multiaddr" | ||
|
||
path "github.com/ipfs/go-ipfs/path" | ||
circuit "gx/ipfs/QmSC7288aesJAC3BQ4Duy6Pk2CMfQWL7cr5t9SV4HBmKFT/go-libp2p-circuit" | ||
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" | ||
peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" | ||
) | ||
|
@@ -106,6 +107,16 @@ func ParseMultiaddr(m ma.Multiaddr) (a IPFSAddr, err error) { | |
|
||
func Transport(iaddr IPFSAddr) (maddr ma.Multiaddr) { | ||
maddr = iaddr.Multiaddr() | ||
|
||
// /ipfs/QmId is part of the transport address for p2p-circuit | ||
// TODO clean up the special case | ||
// we need a consistent way of composing and consumig multiaddrs | ||
// so that we don't have to do this | ||
_, err := maddr.ValueForProtocol(circuit.P_CIRCUIT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please create issue for this TODO. TODOs in code get lost in time and space. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, will do once we merge. |
||
if err == nil { | ||
return maddr | ||
} | ||
|
||
split := ma.Split(maddr) | ||
maddr = ma.Join(split[:len(split)-1]...) | ||
return | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will this disable relays entirely or just disable listening on relayed addresses? There are three cases:
It would be nice to be able to enable/disable these independently. Can we currently do that?
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.
Setting to true will disable the relay transport entirely.
The
DislableRelay
controls option 1 and 3, so by default we listen for relay connections and we can connect to peers through relay.In order to act as a hop relay (2), you need to
EnableRelayHop
, in addition to having the relay transport enabled.I don't think it makes sense to have more fine-grained independent configuration, as we can't really separate listening from dial (and do we really want to do that?) and we already have an option to control hop relaying.
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.
As discussed on IRC, I misunderstood what these toggles did. DisableRelay disables relaying entirely and we don't yet support advertising relayed addresses; when implemented, that will probably have an additional toggle.
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.
Yes, that's the plan.