Skip to content
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 with basic_host #210

Merged
merged 6 commits into from
Aug 2, 2017
Merged

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Jul 24, 2017

Integrates Circuit Relay as a transport option in basic_host.NewHost.
See #209

@vyzo
Copy link
Contributor Author

vyzo commented Jul 24, 2017

summoning @Stebalien @whyrusleeping

@vyzo vyzo mentioned this pull request Jul 24, 2017
@vyzo
Copy link
Contributor Author

vyzo commented Jul 24, 2017

cc @lgierth

if err != nil {
// perhaps inappropriate, but otherwise we have to change the interface
// to return an error, which will nost likely lead to a fatality anyway
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm... this construction feels very entangled. we need a host to create a relay that we're using to create a host? Maybe we should set the relay post construction?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also, panics are bad, if we need to lets just switch to returning an error here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, relay needs a pre-existing host to attach.
Maybe we can leave it outside the basic host construction if you prefer, although it would be nice to have it simply available through the host options.

Re: panic: I can change the interface to return an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to keep the legacy interface unchanged however.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the relay attachment post construction in fd23cf6

Copy link
Contributor Author

@vyzo vyzo Aug 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inappropriate panic was squashed earlier in 7f1ffcb

@vyzo
Copy link
Contributor Author

vyzo commented Jul 25, 2017

@whyrusleeping updated the NewHost interface to return an error, so that we don't panic there.

I did not change the legacy New constructor, as it would be an interface breaking change -- plus it's a deprecated interface!
I added a panic there however for handing the NewHost error, but it should be impossible with the legacy options the interface supports.

@vyzo
Copy link
Contributor Author

vyzo commented Aug 1, 2017

rebased on master and updated go-libp2p-circuit dep to 1.1.3 to keep up with upstream deps.

var relayCtx context.Context
var relayCancel func()
if opts.Relay {
relayCtx, relayCancel = context.WithCancel(context.Background())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this context is off -- it's not wired to anything, but is used to dial peers, open streams, and open relayed streams. It should be wired to something so it correctly gets cancelled when shutting down go-ipfs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's loosely wired via the cancel funciton. When the basic host gets closed, it will call cancel.

Regardless, I agree that ideally this context should come from the outside and be tied to the lifetime of the host. It would take an interface change to pass it as a NewHost argument though, so that's why I didn't do that initially.

But we are changing the interface already for the error return. It's not widely used so we might as well change it further to take a context argument.
The legacy interface can pass in a context.Background().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added base context as parameter to NewHost in 6be81d3

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, LGTM

@vyzo vyzo merged commit e44e538 into master Aug 2, 2017
@vyzo vyzo deleted the feat/circuit-relay branch August 2, 2017 21:46
marten-seemann added a commit that referenced this pull request Apr 22, 2022
don't compare peer IDs when hole punching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants