A BitTorrent client implementation in TypeScript using Node.js.
- Decode - Decode bencoded strings
- Info - Display torrent file metadata (tracker URL, length, info hash, piece info)
- Peers - Discover peers from tracker
- Handshake - Perform BitTorrent handshake with peers
pnpm install# launch the terminal UI
pnpm dev
# display torrent file info
pnpm exec tsx app/cli.ts info sample.torrent
# discover peers from tracker
pnpm exec tsx app/cli.ts peers sample.torrent
# perform peer handshake with tracker
pnpm exec tsx app/cli.ts handshake sample.torrent <peer_ip>:<peer_port>
# download a piece from tracker
pnpm exec tsx app/cli.ts download_piece -o /tmp/test-piece sample.torrent <piece_index>
# download a complete file from tracker
pnpm exec tsx app/cli.ts download -o /tmp/out.test sample.torrent# run application in cli mode
pnpm exec tsx app/cli.ts <cmd>
# run the complete test suite
npm testapp/main.ts- TUI entry pointapp/cli.ts- CLI entry pointapp/cmds/- CLI commandsapp/core/- Core torrent logicapp/utils/- Utilities (bencode, buffer)app/ui/- UI components (TUI)
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (git switch -c feature/amazing-feature)
- Make your changes
- Add tests for new functionality
- Ensure all tests pass (npm test)
- Commit your changes
- Push to the feature branch
- Open a pull request