summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/BitTorrent/Peer/Addr.hs2
-rw-r--r--src/Network/DHT/Kademlia.hs21
2 files changed, 10 insertions, 13 deletions
diff --git a/src/Network/BitTorrent/Peer/Addr.hs b/src/Network/BitTorrent/Peer/Addr.hs
index 0e6fcfb9..1c2ac2eb 100644
--- a/src/Network/BitTorrent/Peer/Addr.hs
+++ b/src/Network/BitTorrent/Peer/Addr.hs
@@ -28,7 +28,7 @@ data PeerAddr = PeerAddr {
28 peerID :: Maybe PeerID 28 peerID :: Maybe PeerID
29 , peerIP :: HostAddress 29 , peerIP :: HostAddress
30 , peerPort :: PortNumber 30 , peerPort :: PortNumber
31 } deriving Show 31 } deriving (Show, Eq)
32 32
33instance BEncodable PortNumber where 33instance BEncodable PortNumber where
34 toBEncode = toBEncode . fromEnum 34 toBEncode = toBEncode . fromEnum
diff --git a/src/Network/DHT/Kademlia.hs b/src/Network/DHT/Kademlia.hs
index d5418beb..bc03ac16 100644
--- a/src/Network/DHT/Kademlia.hs
+++ b/src/Network/DHT/Kademlia.hs
@@ -1,4 +1,3 @@
1-- TODO move to Network.DHT.Kademlia
2{-# LANGUAGE OverloadedStrings #-} 1{-# LANGUAGE OverloadedStrings #-}
3module Network.DHT.Kademlia 2module Network.DHT.Kademlia
4 ( 3 (
@@ -8,7 +7,8 @@ import Data.ByteString
8import Network 7import Network
9import Remote.KRPC 8import Remote.KRPC
10 9
11 10import Data.Kademlia.Routing.Table
11{-
12 12
13-- | Global unique identifier of the node. Size of the identifier 13-- | Global unique identifier of the node. Size of the identifier
14-- should(!) be equal to the size of DHT keys. This limitation arises 14-- should(!) be equal to the size of DHT keys. This limitation arises
@@ -32,11 +32,7 @@ type Token = ByteString
32ping :: Method NodeID NodeID 32ping :: Method NodeID NodeID
33ping = method "ping" ["id"] ["id"] 33ping = method "ping" ["id"] ["id"]
34 34
35type PeerContact = () 35
36data NodeContact = NodeContact {
37 peerContact :: PeerContact
38 , nodeID :: NodeID
39 }
40 36
41-- | Used to lookup peer ID from node ID. 37-- | Used to lookup peer ID from node ID.
42-- 38--
@@ -47,16 +43,16 @@ find_node = method "find_node" ["id", "target"] ["id", "nodes"]
47announce_peer :: Method (NodeID, InfoHash, PortNumber, Token) NodeID 43announce_peer :: Method (NodeID, InfoHash, PortNumber, Token) NodeID
48announce_peer = undefined 44announce_peer = undefined
49 45
46-- WARN is the 'system' random suitable for this?
47-- | Generate random NodeID used for the entire session.
48-- Distribution of ID's should be as uniform as possible.
49--
50genNodeID :: IO NodeID 50genNodeID :: IO NodeID
51genNodeID = undefined 51genNodeID = randomIO
52 52
53{- 53{-
54type InfoHash = Int
55type Token = Int 54type Token = Int
56 55
57ping :: Method NodeId NodeId
58ping = method "ping" ["id"] ["id"]
59
60get_peers :: Method (NodeId :*: InfoHash) (NodeId, Token, NodeAddr :|: NodeAddr) 56get_peers :: Method (NodeId :*: InfoHash) (NodeId, Token, NodeAddr :|: NodeAddr)
61get_peers = method "get_peers" 57get_peers = method "get_peers"
62 ("id", "target") 58 ("id", "target")
@@ -65,4 +61,5 @@ get_peers = method "get_peers"
65 61
66 62
67 63
64-}
68-} \ No newline at end of file 65-} \ No newline at end of file