functorrent.git
9 years agoconvert bitfield from a peer into piece list
Ramakrishnan Muthukrishnan [Sat, 16 May 2015 16:41:22 +0000 (22:11 +0530)]
convert bitfield from a peer into piece list

9 years agoREADME: add a link to the official spec
Ramakrishnan Muthukrishnan [Sat, 16 May 2015 06:46:32 +0000 (12:16 +0530)]
README: add a link to the official spec

9 years agoremove the debug prints
Ramakrishnan Muthukrishnan [Sat, 16 May 2015 06:45:57 +0000 (12:15 +0530)]
remove the debug prints

9 years agoreceive the full handshake msg from peer
Ramakrishnan Muthukrishnan [Thu, 7 May 2015 05:53:17 +0000 (11:23 +0530)]
receive the full handshake msg from peer

9 years agocleanup unused imports/functions
Ramakrishnan Muthukrishnan [Thu, 7 May 2015 05:52:14 +0000 (11:22 +0530)]
cleanup unused imports/functions

Cleanup the debug identifiers/prints.

9 years agomore debugging prints
Ramakrishnan Muthukrishnan [Wed, 6 May 2015 17:58:11 +0000 (23:28 +0530)]
more debugging prints

9 years agoWIP: receive msgs from a connected peer and print them
Ramakrishnan Muthukrishnan [Wed, 6 May 2015 17:33:53 +0000 (23:03 +0530)]
WIP: receive msgs from a connected peer and print them

Something wierd going on. Getting an incorrect length prefix.

9 years agoadd a simple message loop to print out received msgs
Ramakrishnan Muthukrishnan [Wed, 6 May 2015 09:47:19 +0000 (15:17 +0530)]
add a simple message loop to print out received msgs

This is just to study what messages come after the handshake.

9 years agoread bytes off the handle and parse a message
Ramakrishnan Muthukrishnan [Wed, 6 May 2015 08:38:04 +0000 (14:08 +0530)]
read bytes off the handle and parse a message

9 years agorename shadowing identifiers
Ramakrishnan Muthukrishnan [Tue, 5 May 2015 16:54:48 +0000 (22:24 +0530)]
rename shadowing identifiers

9 years agoWIP: deserialize peer messages
Ramakrishnan Muthukrishnan [Tue, 5 May 2015 16:41:13 +0000 (22:11 +0530)]
WIP: deserialize peer messages

serialize/deserialize is implemented as instances of Data.Binary
which allows us to just do get/put.

9 years agoWIP: Peer protocol message marshalling
Ramakrishnan Muthukrishnan [Mon, 4 May 2015 16:59:58 +0000 (22:29 +0530)]
WIP: Peer protocol message marshalling

9 years agoRemove the redundant withSocketsDo call wrapping simpleHTTP
Ramakrishnan Muthukrishnan [Sun, 3 May 2015 09:14:58 +0000 (14:44 +0530)]
Remove the redundant withSocketsDo call wrapping simpleHTTP

simpleHTTP calls withSocketsDo deep inside, so no need to wrap
it outside.

9 years agoremove hardcoded Peer
Ramakrishnan Muthukrishnan [Fri, 1 May 2015 15:38:49 +0000 (21:08 +0530)]
remove hardcoded Peer

Works fine for the Ubuntu torrent file, but not for the Debian
torrent file.

9 years agoPeer constructor also takes the peerid argument now: experimental
Ramakrishnan Muthukrishnan [Fri, 1 May 2015 15:19:17 +0000 (20:49 +0530)]
Peer constructor also takes the peerid argument now: experimental

9 years agoWIP: peer handshake
Ramakrishnan Muthukrishnan [Fri, 1 May 2015 10:20:21 +0000 (15:50 +0530)]
WIP: peer handshake

9 years agowrap network calls with withSocketsDo for multiplatform initialization
Ramakrishnan Muthukrishnan [Thu, 30 Apr 2015 11:29:59 +0000 (16:59 +0530)]
wrap network calls with withSocketsDo for multiplatform initialization

9 years agoWIP: FuncTorrent as a nix package
Ramakrishnan Muthukrishnan [Wed, 29 Apr 2015 00:08:07 +0000 (05:38 +0530)]
WIP: FuncTorrent as a nix package

9 years agoadd quickcheck as a test dependency
Ramakrishnan Muthukrishnan [Sun, 26 Apr 2015 01:49:40 +0000 (07:19 +0530)]
add quickcheck as a test dependency

9 years agoRevert "travis.yml: install "happy" which is a dependency for haskell-src-exts"
Ramakrishnan Muthukrishnan [Tue, 28 Apr 2015 07:52:46 +0000 (13:22 +0530)]
Revert "travis.yml: install "happy" which is a dependency for haskell-src-exts"

This reverts commit 5d631c39efab1fdcae829f8048be1925ccaefc39. This commit is not
required anymore, since hlint test is removed and so haskell-src-exts is not
needed.

9 years agotest: nuke hlint testsuite
Ramakrishnan Muthukrishnan [Tue, 28 Apr 2015 03:11:04 +0000 (08:41 +0530)]
test: nuke hlint testsuite

9 years agosuppress the "orphan instance of Arbitrary" warning
Ramakrishnan Muthukrishnan [Mon, 27 Apr 2015 12:51:37 +0000 (18:21 +0530)]
suppress the "orphan instance of Arbitrary" warning

9 years agoRevert "Move Arbitrary instances into another module"
Ramakrishnan Muthukrishnan [Mon, 27 Apr 2015 12:49:43 +0000 (18:19 +0530)]
Revert "Move Arbitrary instances into another module"

This reverts commit 3d5c1507b312afb8e4219dcb048db0ae2847986e.

9 years agoMove Arbitrary instances into another module
Ramakrishnan Muthukrishnan [Mon, 27 Apr 2015 12:31:18 +0000 (18:01 +0530)]
Move Arbitrary instances into another module

Suppress the orphan instance warning.

9 years agoMerge pull request #30 from jaseemabid/master
Ramakrishnan Muthukrishnan [Mon, 27 Apr 2015 10:54:55 +0000 (16:24 +0530)]
Merge pull request #30 from jaseemabid/master

Add cabal.config from stackage snapshot lts 2.5

9 years agoAdd cabal.config from stackage snapshot lts 2.5
Jaseem Abid [Mon, 27 Apr 2015 05:10:23 +0000 (10:40 +0530)]
Add cabal.config from stackage snapshot lts 2.5

Updated the README to reflect changes in build.

9 years agoREADME: a note on using nix-shell
Ramakrishnan Muthukrishnan [Sun, 26 Apr 2015 17:50:55 +0000 (23:20 +0530)]
README: a note on using nix-shell

9 years agoWIP: split tests into their own modules
Ramakrishnan Muthukrishnan [Sun, 26 Apr 2015 16:34:27 +0000 (22:04 +0530)]
WIP: split tests into their own modules

To start with, the Bencode test is now in its own module.

9 years agoQuickCheck tests now terminate successfully.
Ramakrishnan Muthukrishnan [Sun, 26 Apr 2015 12:09:01 +0000 (17:39 +0530)]
QuickCheck tests now terminate successfully.

The trick is to reduce the amount of data we generate for recursive
types. The hint is in the QuickCheck manual.

9 years agoadd QuickCheck test to the test suite.
Ramakrishnan Muthukrishnan [Sun, 26 Apr 2015 12:07:18 +0000 (17:37 +0530)]
add QuickCheck test to the test suite.

Bug: tests do not terminate because of the recursive nature of
the BVal data type.

9 years agoadd missing dependency for QuickCheck for executable
Ramakrishnan Muthukrishnan [Sun, 26 Apr 2015 06:13:47 +0000 (11:43 +0530)]
add missing dependency for QuickCheck for executable

9 years agoWIP: QuickCheck for BVal type
Ramakrishnan Muthukrishnan [Sun, 26 Apr 2015 06:10:46 +0000 (11:40 +0530)]
WIP: QuickCheck for BVal type

9 years agoRename connect to tracker
Jaseem Abid [Fri, 24 Apr 2015 13:49:32 +0000 (19:19 +0530)]
Rename connect to tracker

Bad clash with socket library!

9 years agoMove network code to own file
Jaseem Abid [Thu, 23 Apr 2015 15:26:02 +0000 (20:56 +0530)]
Move network code to own file

9 years agoREADME: add a note on nix-shell
Ramakrishnan Muthukrishnan [Fri, 24 Apr 2015 09:29:08 +0000 (14:59 +0530)]
README: add a note on nix-shell

9 years agonix-shell configuration file
Ramakrishnan Muthukrishnan [Fri, 24 Apr 2015 09:22:12 +0000 (14:52 +0530)]
nix-shell configuration file

9 years agoBencode: make encode a bit more readable
Ramakrishnan Muthukrishnan [Thu, 23 Apr 2015 07:35:34 +0000 (13:05 +0530)]
Bencode: make encode a bit more readable

9 years agoBencode: cleanup the parser a bit
Ramakrishnan Muthukrishnan [Thu, 23 Apr 2015 05:34:31 +0000 (11:04 +0530)]
Bencode: cleanup the parser a bit

There is no need to check for the spaces at the beginning every
individual parser for each type.

9 years agoFix broken test
Jaseem Abid [Sun, 19 Apr 2015 10:47:10 +0000 (16:17 +0530)]
Fix broken test

9 years agoMerge pull request #26 from jaseemabid/master
Ramakrishnan Muthukrishnan [Sat, 18 Apr 2015 09:59:30 +0000 (15:29 +0530)]
Merge pull request #26 from jaseemabid/master

Clean up tracker network code

9 years agoFix bdict encode, cleanup blist encode
Jaseem Abid [Sat, 18 Apr 2015 09:31:59 +0000 (15:01 +0530)]
Fix bdict encode, cleanup blist encode

This one took a long time to debug! Need more unit tests

9 years agoClean up tracker network code
Jaseem Abid [Sat, 11 Apr 2015 11:19:26 +0000 (16:49 +0530)]
Clean up tracker network code

- Made info_hash an attribute of meta info
- Refactored a `get` function
- Removed few more useless types
- Cleaned up log messages
- Remove unnecessary Url type
- Fix double urlEncode

TIL You should ideally always write total functions in Haskell.

9 years agoMerge pull request #25 from abhiranjankumar00/master
Jaseem Abid [Tue, 14 Apr 2015 12:49:09 +0000 (18:19 +0530)]
Merge pull request #25 from abhiranjankumar00/master

Follow up #21. Applying fmap (alternative) on getters

9 years agoFollow up #21. Applying fmap (alternative) on getters
Abhiranjan Kumar [Sun, 12 Apr 2015 21:35:51 +0000 (03:05 +0530)]
Follow up #21. Applying fmap (alternative) on getters

9 years agoMerge pull request #24 from abhiranjankumar00/master
Jaseem Abid [Sat, 11 Apr 2015 13:27:50 +0000 (18:57 +0530)]
Merge pull request #24 from abhiranjankumar00/master

Fixes #21 (creationDate now not empty)

9 years agoFixes 21
Abhiranjan Kumar [Sat, 11 Apr 2015 13:12:54 +0000 (18:42 +0530)]
Fixes 21

9 years agoSwitch to known torrent file
Jaseem Abid [Sat, 11 Apr 2015 11:05:07 +0000 (16:35 +0530)]
Switch to known torrent file

9 years agoMove things around
Jaseem Abid [Fri, 10 Apr 2015 02:06:35 +0000 (07:36 +0530)]
Move things around

- `infoHash` is part of metainfo, not tracker alone. Peers need this for
handshake

- Rename PeerResp to TrackerResponse and move to Tracker.hs

- Remove unwanted overhead like `type Port = Integer`

- Some more docs, haddock is showing them nicely

- Update tests

9 years agoMeta info tests
Jaseem Abid [Tue, 7 Apr 2015 02:02:42 +0000 (07:32 +0530)]
Meta info tests

9 years agoExpose all MetaInfo constructors
Jaseem Abid [Tue, 7 Apr 2015 01:59:01 +0000 (07:29 +0530)]
Expose all MetaInfo constructors

9 years agoUse moby_dick.torrent for testing
Jaseem Abid [Tue, 7 Apr 2015 01:35:26 +0000 (07:05 +0530)]
Use moby_dick.torrent for testing

`pieces` field of the Debian ISO is too long to put in a source file and
would cause Emacs to hang too often.

9 years agoMinor refactor maybeBstrToString
Jaseem Abid [Mon, 30 Mar 2015 16:30:13 +0000 (22:00 +0530)]
Minor refactor maybeBstrToString

Makes the function total. Also, this looks a lot like fmap!

9 years agoMerge pull request #20 from vu3rdd/12-announcelist-2
Ramakrishnan Muthukrishnan [Mon, 30 Mar 2015 10:44:23 +0000 (16:14 +0530)]
Merge pull request #20 from vu3rdd/12-announcelist-2

combine announce and announceList slots in the Metainfo record.

9 years agouse maybeToList from Data.Maybe
Ramakrishnan Muthukrishnan [Mon, 30 Mar 2015 10:07:42 +0000 (15:37 +0530)]
use maybeToList from Data.Maybe

9 years agocombine announce and announceList slots in the Metainfo record.
Ramakrishnan Muthukrishnan [Mon, 30 Mar 2015 08:57:36 +0000 (14:27 +0530)]
combine announce and announceList slots in the Metainfo record.

This eliminates the unnecessary "getter" function getTrackers
and simplifies the code a bit. Still a work in progress.

9 years agoremove an unwanted import which creeped in during merge
Ramakrishnan Muthukrishnan [Mon, 30 Mar 2015 05:08:39 +0000 (10:38 +0530)]
remove an unwanted import which creeped in during merge

9 years agoremove unnecessary parenthesis (hlint suggestion)
Ramakrishnan Muthukrishnan [Thu, 26 Mar 2015 10:58:47 +0000 (16:28 +0530)]
remove unnecessary parenthesis (hlint suggestion)

9 years agosupport for announce-list.
Ramakrishnan Muthukrishnan [Thu, 26 Mar 2015 10:48:07 +0000 (16:18 +0530)]
support for announce-list.

Some torrent files use announce-lists but then store list of lists,
each inner list containing just one string instead of list of strings.
(eg: data/ubuntu-14.10-desktop-amd64.iso.torrent stores it this way)

9 years agoHandle error cases from the tracker
Jaseem Abid [Sun, 29 Mar 2015 12:24:58 +0000 (17:54 +0530)]
Handle error cases from the tracker

Tracker might reply that the requested torrent is unavailable. Sample
response at `data/debian-7.8.0-amd64-CD-1.iso.error`.

Renamed `getPeerResponse` to `mkPeerResp` and changed it singture to
match other `mk*` functions like `mkMetaInfo`.

Added test cases

New checks made the code one more level deep. Will need a refactor with
the Either Monad.

9 years agoAdd directory & tasty as a library dependencies
Jaseem Abid [Sun, 29 Mar 2015 07:25:21 +0000 (12:55 +0530)]
Add directory & tasty as a library dependencies

9 years agoMerge pull request #19 from jaseemabid/master
Jaseem Abid [Sat, 28 Mar 2015 17:21:00 +0000 (22:51 +0530)]
Merge pull request #19 from jaseemabid/master

Cleanup a few bad types

9 years agoCleanup a few bad types
Jaseem Abid [Sat, 28 Mar 2015 11:22:02 +0000 (16:52 +0530)]
Cleanup a few bad types

1. Change type InfoDict from `Map BVal BVal` to `Map String BVal`

The keys are human readable keys like 'name', 'announce' etc and String
is the natural fit. This change also gets rid of a lot of packing
unpacking business.

Example:

    -infoHash :: Map BVal BVal -> ByteString
    -infoHash m = let info = m ! Bstr (pack "info")
    -             in (hash . pack . encode) info
    +infoHash :: InfoDict -> ByteString
    +infoHash m = hash . encode $ (m ! "info")

2. Change type of `encode` from `BVal -> String` to `BVal -> ByteString`

Encoded values might not be ASCII safe in the first place. Also, it
makes sense to be the inverse function of decode. `encode . decode` pair
might be a good candidate for Quickcheck.

Other changes are consequences of the type change. Fixed a bunch of
broken doctests in Bencode.

TIL haskell is kickass for refactoring!

9 years agoadd dependency on package "directory" to functorrent-test
Ramakrishnan Muthukrishnan [Fri, 27 Mar 2015 17:11:04 +0000 (22:41 +0530)]
add dependency on package "directory" to functorrent-test

9 years agoerror out if the input string is not a valid filepath
Ramakrishnan Muthukrishnan [Fri, 27 Mar 2015 05:50:41 +0000 (11:20 +0530)]
error out if the input string is not a valid filepath

9 years agoMerge pull request #15 from vu3rdd/14-hlint-0
Ramakrishnan Muthukrishnan [Tue, 24 Mar 2015 08:05:33 +0000 (13:35 +0530)]
Merge pull request #15 from vu3rdd/14-hlint-0

Run HLint as a test suite.

9 years agoFIlenames start with capital letters. hlint.hs -> HLint.hs
Ramakrishnan Muthukrishnan [Tue, 24 Mar 2015 08:04:10 +0000 (13:34 +0530)]
FIlenames start with capital letters. hlint.hs -> HLint.hs

9 years agotravis.yml: install "happy" which is a dependency for haskell-src-exts
Ramakrishnan Muthukrishnan [Tue, 24 Mar 2015 04:15:16 +0000 (09:45 +0530)]
travis.yml: install "happy" which is a dependency for haskell-src-exts

9 years agoRun HLint as a test suite.
Ramakrishnan Muthukrishnan [Mon, 23 Mar 2015 14:29:08 +0000 (19:59 +0530)]
Run HLint as a test suite.

9 years agoFix cabal dependencies
Jaseem Abid [Sun, 22 Mar 2015 19:42:58 +0000 (01:12 +0530)]
Fix cabal dependencies

9 years agoFix tracker response test
Jaseem Abid [Sun, 22 Mar 2015 18:00:46 +0000 (23:30 +0530)]
Fix tracker response test

9 years agoFix key error
Jaseem Abid [Sun, 22 Mar 2015 17:14:43 +0000 (22:44 +0530)]
Fix key error

9 years agoFix test which did file parsing on tracker response
Jaseem Abid [Sun, 22 Mar 2015 15:25:11 +0000 (20:55 +0530)]
Fix test which did file parsing on tracker response

Relates to #11

9 years agoREADME.md: hopefully correct image link this time
Ramakrishnan Muthukrishnan [Sun, 22 Mar 2015 02:02:04 +0000 (07:32 +0530)]
README.md: hopefully correct image link this time

9 years agoREADME.md: bang for the image link
Ramakrishnan Muthukrishnan [Sun, 22 Mar 2015 01:59:26 +0000 (07:29 +0530)]
README.md: bang for the image link

9 years agoREADME.md: messed up the markdown link syntax
Ramakrishnan Muthukrishnan [Sun, 22 Mar 2015 01:56:28 +0000 (07:26 +0530)]
README.md: messed up the markdown link syntax

9 years agoREADME -> README.md
Ramakrishnan Muthukrishnan [Sun, 22 Mar 2015 01:55:05 +0000 (07:25 +0530)]
README -> README.md

9 years agoREADME: add travis build/test status badge.
Ramakrishnan Muthukrishnan [Sun, 22 Mar 2015 01:52:02 +0000 (07:22 +0530)]
README: add travis build/test status badge.

9 years agoMerge pull request #12 from jaseemabid/master
Ramakrishnan Muthukrishnan [Sat, 21 Mar 2015 17:46:26 +0000 (23:16 +0530)]
Merge pull request #12 from jaseemabid/master

Add tests to functorrent

9 years agoAdd travis config
Jaseem Abid [Sat, 21 Mar 2015 16:47:40 +0000 (22:17 +0530)]
Add travis config

9 years agoTests for decode
Jaseem Abid [Sat, 21 Mar 2015 16:44:09 +0000 (22:14 +0530)]
Tests for decode

9 years agoRename getPeers -> peers
Jaseem Abid [Sat, 21 Mar 2015 16:36:28 +0000 (22:06 +0530)]
Rename getPeers -> peers

9 years agoRemove duplicate import
Jaseem Abid [Sat, 21 Mar 2015 15:57:57 +0000 (21:27 +0530)]
Remove duplicate import

9 years agoRemove dependency on time package
Jaseem Abid [Sat, 21 Mar 2015 14:40:22 +0000 (20:10 +0530)]
Remove dependency on time package

9 years agoMake functorrent a library and an executable
Jaseem Abid [Sat, 21 Mar 2015 14:02:57 +0000 (19:32 +0530)]
Make functorrent a library and an executable

This is a prerequisite for testing, as well as code organization.

1. `$ cabal repl` will build and import Functorrent library.
2. Making module exports explicit

9 years agoMerge pull request #10 from jaseemabid/master
Jaseem Abid [Wed, 18 Mar 2015 10:30:40 +0000 (16:00 +0530)]
Merge pull request #10 from jaseemabid/master

Make network request return ByteString

9 years agoMake network request return ByteString
Jaseem Abid [Sun, 15 Mar 2015 18:34:10 +0000 (00:04 +0530)]
Make network request return ByteString

Packing and unpacking curropted the binary data in several occations
when the network response was written to disk for caching/testing.

Add support for local caches. This aids in testing, and throttling
remote requests if the file is new enough.

Removes unwanted <$>

9 years agoMerge pull request #7 from dfordivam/master
Jaseem Abid [Mon, 2 Mar 2015 11:09:23 +0000 (16:39 +0530)]
Merge pull request #7 from dfordivam/master

Implemented logger

9 years agoFeedback from @jaseemabid, Fixes #6
Divam [Sun, 1 Mar 2015 15:10:13 +0000 (20:40 +0530)]
Feedback from @jaseemabid, Fixes #6

9 years agoLogger implementation code. Fixes #6. Logging to file remaining
Divam [Sat, 28 Feb 2015 16:08:11 +0000 (21:38 +0530)]
Logger implementation code. Fixes #6. Logging to file remaining

9 years agoMerge pull request #1 from vu3rdd/master
Divam [Mon, 23 Feb 2015 11:01:26 +0000 (16:31 +0530)]
Merge pull request #1 from vu3rdd/master

merge from vu3rdd

9 years agoMerge pull request #5 from jaseemabid/master
Ramakrishnan Muthukrishnan [Mon, 23 Feb 2015 05:19:53 +0000 (10:49 +0530)]
Merge pull request #5 from jaseemabid/master

Make `!` inline

9 years agoMake `!` inline
Jaseem Abid [Sun, 22 Feb 2015 17:04:44 +0000 (22:34 +0530)]
Make `!` inline

9 years agoMerge pull request #4 from jaseemabid/master
Ramakrishnan Muthukrishnan [Sun, 22 Feb 2015 14:25:37 +0000 (19:55 +0530)]
Merge pull request #4 from jaseemabid/master

Absolute imports, removing qualified imports

9 years agoFix failing test
Jaseem Abid [Sat, 21 Feb 2015 18:59:06 +0000 (00:29 +0530)]
Fix failing test

9 years agoAbsolute import everywhere, cleanup
Jaseem Abid [Sat, 21 Feb 2015 18:45:57 +0000 (00:15 +0530)]
Absolute import everywhere, cleanup

9 years agoMerge pull request #3 from jaseemabid/master
Ramakrishnan Muthukrishnan [Sat, 21 Feb 2015 16:43:50 +0000 (22:13 +0530)]
Merge pull request #3 from jaseemabid/master

Derive `show` automatically for BVal

9 years agoDerive `show` automatically for BVal
Jaseem Abid [Sat, 21 Feb 2015 13:01:33 +0000 (18:31 +0530)]
Derive `show` automatically for BVal

9 years agomore refactoring: type synonym for info dictionary
Ramakrishnan Muthukrishnan [Sat, 21 Feb 2015 03:55:15 +0000 (09:25 +0530)]
more refactoring: type synonym for info dictionary

9 years agomore refactoring around infohash
Ramakrishnan Muthukrishnan [Sat, 21 Feb 2015 03:43:45 +0000 (09:13 +0530)]
more refactoring around infohash

9 years agorefactor PeerID and associated functions.
Ramakrishnan Muthukrishnan [Sat, 21 Feb 2015 02:41:42 +0000 (08:11 +0530)]
refactor PeerID and associated functions.

Until now we were hashing peer id string to get a 20-byte hash. But
that's not needed. Peer ID is just a 20-byte string that needs to be
unique per client and sent to the tracker (and peers).