Tutorial here: http://allenkim67.github.io/programming/2016/05/04/how-to-make-your-own-bittorrent-client.html
allenkim67 / allen-torrent Goto Github PK
View Code? Open in Web Editor NEWLearn to build a bittorrent client in node.js
Learn to build a bittorrent client in node.js
Hi Allen, i wanted to use allen-torrent as a quick way to download torrents after i have searched a few torrent APIs as part of a school project, however there is no documentation (granted this, i assume was a tut).
When i try:
node index.js path/to/file-torrent
It just hangs, no information before the hang either. I am quite sure i added all the npm dependencies. Why does it just hang?
Line 73 in c7c204d
As per the spec doc,
https://wiki.theory.org/BitTorrentSpecification#Messages
The size of bitfield message is variable, depending upon length of bitfield.
fix :
const buf = Buffer.alloc(bitfield.length + 1 + 4);
I could not install bignum package on MacOS Catalina;
I tried
npm install --save bignum, and,
npm install -g --save bignum
global download is working but after calling node index.js, the program is failing due to bignum.
I think that, in the isHandshake() method, the correct condition check for the "pstr" field is supposed to be:
message.toString('utf8', 1, 1 + message.readUInt8(0)) === "BitTorrent protocol"
instead of:
message.toString('utf8', 1) === "BitTorrent protocol"
,
because, otherwise, we're comparing <info_hash><peer_id> to "BitTorrent protocol" !
get peers ip and port from tracker ,
if other peers are behind Nat , does it can tcp connect directly to them ?
if not , how to solve it ?
Can anyone show me the step, how to get this project running on my computer?
What are the steps to get this web-torrent open in my browser?
basically, i am a total newbie so how to deploy this project?
As soon as I run,
node index.js torr.torrent
(torr.torrent is the name of the torrent and its in the root of the project)
everything just hangs.
I don't even get an output for the connected peers.
Also, the torrent I'm using has a lot of peers and it works fine when I use BitTorrent.
Hey Allen,
Even after trying multiple healthy torrents (with UDP trackers), when I run index.js, it hangs and doesn't proceed.
I debugged a little and noticed that the socket.on('message', ...) is not being run at all, meaning that the tracker is not sending a connect response.
Do you have any idea what might be the problem?
So far following the tutorial I have completed till the part where we can get Peers.
For some reason in my getPeers
function the program never goes inside socket.on("message" , (res) => {console.log("Connected")}
Here is my repo.
Any help is appreciated been stuck here for a while now.
OS: WSL Ubuntu
Node: 22.2.0
NPM: 10.7.0
When running
sudo tcpdump -i any udp -v
I am able to see that a response is coming from the tracker server
i'm receiving an error like this
Error: connect ECONNREFUSED 118.70.180.108:34105
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '118.70.180.108',
port: 34105
}
and
Error: connect ETIMEDOUT 197.185.113.183:63659
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
address: '197.185.113.183',
port: 63659
}
Excuse me, I'm having some problems with some torrents. When the download starts, the downloaded file immediately starts to grow really fast, and when it completes it final size, It got stuck in 99%. I think that I have to upload pieces that I just download to download remaining pieces.
If I try downloading this same torrent with other client it works normally.
Any idea?
Thanks.
Regards,
Line 88 in 983355b
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.