diff options
Diffstat (limited to 'src/Network/BitTorrent')
-rw-r--r-- | src/Network/BitTorrent/Client/Swarm.hs | 15 | ||||
-rw-r--r-- | src/Network/BitTorrent/Tracker/Session.hs | 56 |
2 files changed, 9 insertions, 62 deletions
diff --git a/src/Network/BitTorrent/Client/Swarm.hs b/src/Network/BitTorrent/Client/Swarm.hs index 7fdd1f2f..bd48f8a4 100644 --- a/src/Network/BitTorrent/Client/Swarm.hs +++ b/src/Network/BitTorrent/Client/Swarm.hs | |||
@@ -5,6 +5,7 @@ module Network.BitTorrent.Client.Swarm | |||
5 | ) where | 5 | ) where |
6 | 6 | ||
7 | import Data.Default | 7 | import Data.Default |
8 | import Data.Maybe | ||
8 | import Network | 9 | import Network |
9 | 10 | ||
10 | import Data.Torrent | 11 | import Data.Torrent |
@@ -18,18 +19,14 @@ data Swarm = Swarm | |||
18 | { swarmTopic :: InfoHash | 19 | { swarmTopic :: InfoHash |
19 | , thisPeerId :: PeerId | 20 | , thisPeerId :: PeerId |
20 | , listenerPort :: PortNumber | 21 | , listenerPort :: PortNumber |
21 | , trackerConn :: Tracker | ||
22 | -- , infoDict :: | ||
23 | } | 22 | } |
24 | 23 | ||
25 | newLeecher :: PeerId -> PortNumber -> Torrent -> IO Swarm | 24 | newLeecher :: PeerId -> PortNumber -> Torrent -> IO Swarm |
26 | newLeecher pid port Torrent {..} = do | 25 | newLeecher pid port Torrent {..} = do |
27 | tracker <- connect undefined | ||
28 | return Swarm | 26 | return Swarm |
29 | { swarmTopic = idInfoHash tInfoDict | 27 | { swarmTopic = idInfoHash tInfoDict |
30 | , thisPeerId = pid | 28 | , thisPeerId = pid |
31 | , listenerPort = port | 29 | , listenerPort = port |
32 | , trackerConn = tracker | ||
33 | } | 30 | } |
34 | 31 | ||
35 | getAnnounceQuery :: Swarm -> AnnounceQuery | 32 | getAnnounceQuery :: Swarm -> AnnounceQuery |
@@ -45,5 +42,11 @@ getAnnounceQuery Swarm {..} = AnnounceQuery | |||
45 | 42 | ||
46 | askPeers :: Swarm -> IO [PeerAddr IP] | 43 | askPeers :: Swarm -> IO [PeerAddr IP] |
47 | askPeers s @ Swarm {..} = do | 44 | askPeers s @ Swarm {..} = do |
48 | AnnounceInfo {..} <- RPC.announce (getAnnounceQuery s) trackerConn | 45 | -- AnnounceInfo {..} <- RPC.announce (getAnnounceQuery s) trackerConn |
49 | return (getPeerList respPeers) | 46 | return [] -- (getPeerList respPeers) |
47 | |||
48 | --reannounce :: HTracker -> IO () | ||
49 | --reannounce = undefined | ||
50 | |||
51 | --forceReannounce :: HTracker -> IO () | ||
52 | --forceReannounce = undefined | ||
diff --git a/src/Network/BitTorrent/Tracker/Session.hs b/src/Network/BitTorrent/Tracker/Session.hs deleted file mode 100644 index 3cfc4b52..00000000 --- a/src/Network/BitTorrent/Tracker/Session.hs +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | module Network.BitTorrent.Tracker.Session | ||
2 | ( | ||
3 | ) where | ||
4 | |||
5 | import Data.Torrent.Progress | ||
6 | import Data.Torrent.InfoHash | ||
7 | import Network.BitTorrent.Core.PeerAddr | ||
8 | import Network.BitTorrent.Tracker.Message | ||
9 | |||
10 | data PeerInfo = PeerInfo | ||
11 | { peerId :: PeerId | ||
12 | , peerPort :: PortNumber | ||
13 | , peerIP :: Maybe HostAddress | ||
14 | } | ||
15 | |||
16 | data Session = Session | ||
17 | { sesInfoHash :: !InfoHash | ||
18 | , sesPeerInfo :: !PeerInfo | ||
19 | } | ||
20 | |||
21 | data SAnnounceQuery = SAnnounceQuery | ||
22 | { sreqProgress :: Progress | ||
23 | , sreqNumWant :: Maybe Int | ||
24 | , sreqEvent :: Maybe Event | ||
25 | } | ||
26 | |||
27 | type SAnnounceInfo = [PeerAddr] | ||
28 | |||
29 | f :: Session -> SAnnounceQuery -> AnnounceQuery | ||
30 | f Session {..} SAnnounceQuery {..} = AnnounceQuery | ||
31 | { reqInfoHash = sesInfoHash | ||
32 | , reqPeerInfo = sesPeerInfo | ||
33 | , reqProgress = sreqProgress | ||
34 | , reqNumWant = undefined | ||
35 | , reqEvent = sreqEvent | ||
36 | } | ||
37 | |||
38 | data Settings = Settings | ||
39 | |||
40 | data Manager = Manager | ||
41 | { | ||
42 | } | ||
43 | |||
44 | |||
45 | g :: Session -> AnnounceInfo -> SAnnounceInfo | ||
46 | g Session {..} SAnnounceInfo {..} = undefined | ||
47 | |||
48 | |||
49 | reannounce :: HTracker -> IO () | ||
50 | reannounce = undefined | ||
51 | |||
52 | forceReannounce :: HTracker -> IO () | ||
53 | forceReannounce = undefined | ||
54 | |||
55 | scrape :: HTracker -> IO () | ||
56 | scrape = undefined | ||