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

[Work in progress] Listen on TCP and publish ports over Upnp #42

Merged
merged 28 commits into from
Dec 6, 2023

Conversation

ikatson
Copy link
Owner

@ikatson ikatson commented Dec 5, 2023

This is quite a big change. On Hacker News Rqbit post someone noted we don't upload which isn't great for the network.

I wondered what would it take to make this work without implementing uTP protocol.

So this change changes the default behavior of "rqbit server start" to work similar to other torrent clients - to upload by default.

Here's how it works:

  • we start listening on TCP during session creation. You can turn it off with --disable-tcp-listen. There's also --tcp-listen-min(max)-port.
  • we publish the local port over Upnp for port-forwarding on the router. You can disable it with --disable-upnp
  • we pass this port to DHT when querying for peers, so that it starts announcing our address

The default listen port is 4240, it tries 20 more if it can't bind.

This actually works pretty well in the end, and the moment we publish on DHT, there's lots of peers who start connecting.

Also found bugs in upload code which recently broke, so in fact since some latest updates it likely wasn't uploading anything at all.

I was scratching my head on how to test this during dev, eventually just ran another client like this:

cargo run -- --disable-dht --disable-tcp-listen --disable-upnp --http-api-listen-addr 127.0.0.1:5000 download -o /tmp/scratch2 test.torrent --initial-peers 127.0.0.1:4240

So that one instance listens on 4240, and we force connect to it from another instance. This helped fix a couple bugs.

@ikatson ikatson merged commit 075084a into main Dec 6, 2023
1 check passed
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.

1 participant