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

Documentation on getting a PeerConnection instance? #39

Closed
kg6zvp opened this issue Oct 19, 2017 · 3 comments
Closed

Documentation on getting a PeerConnection instance? #39

kg6zvp opened this issue Oct 19, 2017 · 3 comments

Comments

@kg6zvp
Copy link

kg6zvp commented Oct 19, 2017

I've been looking through your code at everything related to direct connections to peers, but am having trouble piecing it together. I'm not using your library for BitTorrent per se, but am trying to look up peers in DHT by their ID and make a socket connection to them.

Ideally I'll stumble on code like the following:

CompletableFuture<PeerConnection> peerFut = runtime.getPeerconnectionById(peerID);
peerFut.get().postMessage(new Message("Hello"));

Is there any documentation or particular area of the source that you could point me to on establishing peer connections? I'd rather not re-write all of the hard work done by you and others required to punch holes in firewalls, etc.

@kg6zvp kg6zvp changed the title Documentation on PeerConnection? Documentation on getting a PeerConnection instance? Oct 19, 2017
@atomashpolskiy
Copy link
Owner

atomashpolskiy commented Oct 19, 2017

@kg6zvp ,

If you have the ID of a DHT node (this is different from BitTorrent's peer ID by the way and usually picked randomly for each session), you may use NodeLookup task in mldht to get the node's socket address. See bt.dht.MldhtService for an example of how to use mldht tasks.

Then you need to decide, what protocol is going to be used to talk to the peer. If it's BitTorrent, then you'll need a torrent ID (info hash) for establishing a standard BitTorrent connection. To connect to a peer, use bt.net.IPeerConnectionPool#requestConnection() method.

@kg6zvp
Copy link
Author

kg6zvp commented Oct 19, 2017

Thank you. That's a very helpful answer, particularly with all the links to code you included. 👍

Is there any way of establishing this type of connection without a torrent utilizing all of the hard work you and the bittorrent devs have already done to make connections stable? (Since the use case isn't BitTorrent, I mean) I don't mind using lower level APIs or hooking onto other bits of existing code in your library.

@atomashpolskiy
Copy link
Owner

atomashpolskiy commented Oct 20, 2017

Unfortunately, I'm afraid, that you'll need to look somewhere else for this. This project is in a very early stage and does not employ NAT traversal, as it requires a huge amount of effort to implement and test and does not bring much to the table in the scope of BitTorrent (in my opinion). Regarding Bt, it relies on direct socket-to-socket TCP connections, no fancy stuff.

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

2 participants