Nixers project: Bittorrent library - Community & Forums Related Discussions
Laserswald
(09-10-2017, 02:36 PM)z3bra Wrote: We reached a milestone here! libgbt can up/download torrents, with multiple peers. It can accept new connections as well (when seeding only for now).
Basic functionality being there, let's fuck it up and rewrite some bits! Here is what I'm not happy with, or what I want to add/improve:

z3bra,

Do you have a test suite set up? It would make things (like fucking up the API to make it easier to use) a little bit safer.

I can help with writing those tests if you like; when it comes to small C projects I would usually go for just some executable that links to the library and calls assert() a bunch.
z3bra
It had tests at first, for internal functions (bencoding related mostly). Now that only the API is accessible I don't see the point for tests. What would the test do? Download a file, and checksum it? you'd depend on access to the network here. Another idea would be to use a local tracker, spawned for the tests. Not really helpful either...

I wanted to have tests at first, but the simplest way to test is to do it manually at this point.

But I must admit I suck at writing tests, so if you have an idea, please speak up! :)
josuah
Thanks again for opening your thoughts on this project to the community.

(06-08-2017, 06:40 PM)z3bra Wrote: This would also use a shitons on inodes, but that's not the biggest issue.

Code:
$ doas find / -type f -exec du -k {} + | sort -n | awk '
    {
        current++;
        expected += $1 / 8 + 1;  # with 8 kB per block
    }

    END {
        print("current: " current);
        print("expected: " expected);
        print("ratio: " expected / current);
    }
'
current: 332455
expected: 8928090
ratio: 26.855

About 27 times more inodes in my case.

Code:
$ df -kih
Filesystem     Size    Used   Avail Capacity iused   ifree  %iused  Mounted on
/dev/sd0k      298G   60.2G    223G    21%  160449 19580221    1%   /home

8928090 / 19580221 = 46%
currently used space = 21%

With a size of 8kB per block, with my current setup, I would run out of inodes before I run out of space. You are right. :-)
z3bra
hello there!

I'm bringing back to life this old thread. Due to the lack of interest in the original project (and seeing the mess I created...), I decided to rewrite this project from scratch, by using another approach: http://git.z3bra.org/libeech/log.html

It now uses poll() instead of select(), and make use of callbacks functions to receive messages.
The bencoding part has also been fully reimplement to be heapless (so not a single malloc() call!)

As I write this, the lib can connect to a peer, request pieces and write them to a cache file.
To put it simply, I can download a file via BitTorrent!

I'm now reaching some important steps in the implementation, regarding management of cache files, choosing to store things in memory or on the disk, and more importantly, how to communicate with multiple peers at once!

I'm looking for help in networking programming in C, or any idea regarding torrent download/upload algorithms.

Who's interested?




Members  |  Stats  |  Night Mode  |  Help