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

onWire called with undefined address when the peer is a web seed #1094

Closed
Robien opened this issue Apr 3, 2017 · 4 comments
Closed

onWire called with undefined address when the peer is a web seed #1094

Robien opened this issue Apr 3, 2017 · 4 comments

Comments

@Robien
Copy link

@Robien Robien commented Apr 3, 2017

I use the event onWire (for a bittorrent extension) and I found out that the 'addr' parameter is 'undefined' when the peer connected is a webseed.

I have also seen in the code : "Sometimes RTCPeerConnection.getStats() doesn't return an ip:port for peers" which means that in that case 'addr' is also 'undefined'.

I guess bittorrent extensions are not made for webseed. But how should we know which is which? (in my case I just "wire.use" in all cases)

Moreover, if we want to know which url the webseed is, we can't.

I think webtorrent should provide the web seed's url in 'addr' field but it may break other extensions code (which may not expect an url but ip:port)
We can check afterward if 'addr' is an url or ip:port to determine if it's a web seed or not.

If you think it's safe or if you have a better way to fix this, I can make a PR.

Tested with webtorrent 0.98.15 but it was also the case with older versions.
npm 4.4.4 on linux (debian) on Firefox 52b

@DiegoRBaquero

This comment has been minimized.

Copy link
Member

@DiegoRBaquero DiegoRBaquero commented Apr 3, 2017

Web peer > URL? Do you mean webseed?

A WebRTC Peer doesn't have a url.

@Robien

This comment has been minimized.

Copy link
Author

@Robien Robien commented Apr 3, 2017

Do you mean webseed?

Yes ! sorry, I have updated my message.

@Robien Robien changed the title onWire called with undefined address when the peer is a web peer onWire called with undefined address when the peer is a web seed Apr 3, 2017
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Apr 3, 2017

Eventually we may refactor the web seed implementation so that they don't use the same wire interface as normal peers. If that happens then there would be no 'wire' event for web seeds.

However, in the meantime, you can detect the type of wire by checking the wire.type property. If you got a web seed, then wire.type === 'webSeed'.

So, you can either check this property inside your bittorrent extension, or you can just skip calling wire.use() depending on the value of wire.type.

Cheers!

@feross feross closed this Apr 3, 2017
@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 3, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.