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

Expose IP and port of connected peers #97

Open
gmaclennan opened this issue Feb 3, 2022 · 6 comments
Open

Expose IP and port of connected peers #97

gmaclennan opened this issue Feb 3, 2022 · 6 comments

Comments

@gmaclennan
Copy link

gmaclennan commented Feb 3, 2022

Currently neither the socket or peerInfo objects returned from swarm.on('connection') expose the IP or port of the connected peer. This is a feature request to expose this information.

Our use-case is to use to IP to determine if the peer is local (e.g. if the IP is in a private range 10.0.0.0, 172.16.0.0, 192.168.0.0).

It would also be really great to expose this to opts.firewall, so that we could auto-reject non-local connections if we want to ensure that nothing connects online.

@mafintosh

@smoyer64
Copy link

smoyer64 commented Feb 3, 2022

Reference for those unfamiliar with private network space (I've had so many problems when these networks collide within an organization): https://datatracker.ietf.org/doc/html/rfc1918

@mafintosh
Copy link
Contributor

We already know internally if it's a local connection, so we should prob bubble that up additionally vs just the ip - the ip is fine as well, but a user shouldn't be required to analyse that i think.

@smoyer64
Copy link

smoyer64 commented Feb 3, 2022

@mafintosh - I haven't looked at the v3 code as much be in v2 didn't it consider a loopback IP address local?

@gmaclennan
Copy link
Author

We already know internally if it's a local connection, so we should prob bubble that up additionally vs just the ip - the ip is fine as well, but a user shouldn't be required to analyse that i think.

For our use-case, just knowing if it is a local connection would be all the information we need. We don't need the IP.

@mafintosh
Copy link
Contributor

@smoyer64 it uses this https://github.com/mafintosh/bogon/blob/master/index.js to map how to holepunch to people

@mafintosh
Copy link
Contributor

Tracking issue here: holepunchto/hyperdht#76

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

No branches or pull requests

3 participants