summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/BitTorrent/Address.hs166
-rw-r--r--src/Network/BitTorrent/DHT/ContactInfo.hs182
2 files changed, 173 insertions, 175 deletions
diff --git a/src/Network/BitTorrent/Address.hs b/src/Network/BitTorrent/Address.hs
index f8f29be5..a72a8a07 100644
--- a/src/Network/BitTorrent/Address.hs
+++ b/src/Network/BitTorrent/Address.hs
@@ -1063,93 +1063,91 @@ libUserAgent = render (pPrint IlibHSbittorrent <> "/" <> pPrint version)
1063-- For torrent file 1063-- For torrent file
1064-----------------------------------------------------------------------} 1064-----------------------------------------------------------------------}
1065-- TODO collect information about createdBy torrent field 1065-- TODO collect information about createdBy torrent field
1066{- 1066-- renderImpl :: ClientImpl -> Text
1067renderImpl :: ClientImpl -> Text 1067-- renderImpl = T.pack . L.tail . show
1068renderImpl = T.pack . L.tail . show 1068--
1069 1069-- renderVersion :: Version -> Text
1070renderVersion :: Version -> Text 1070-- renderVersion = undefined
1071renderVersion = undefined 1071--
1072-- renderClientInfo :: ClientInfo -> Text
1073-- renderClientInfo ClientInfo {..} = renderImpl ciImpl <> "/" <> renderVersion ciVersion
1074--
1075-- parseClientInfo :: Text -> ClientImpl
1076-- parseClientInfo t = undefined
1072 1077
1073renderClientInfo :: ClientInfo -> Text
1074renderClientInfo ClientInfo {..} = renderImpl ciImpl <> "/" <> renderVersion ciVersion
1075 1078
1076parseClientInfo :: Text -> ClientImpl
1077parseClientInfo t = undefined
1078-}
1079{-
1080-- code used for generation; remove it later on 1079-- code used for generation; remove it later on
1081 1080--
1082mkEnumTyDef :: NM -> String 1081-- mkEnumTyDef :: NM -> String
1083mkEnumTyDef = unlines . map (" | I" ++) . nub . map snd 1082-- mkEnumTyDef = unlines . map (" | I" ++) . nub . map snd
1084 1083--
1085mkPars :: NM -> String 1084-- mkPars :: NM -> String
1086mkPars = unlines . map (\(code, impl) -> " f \"" ++ code ++ "\" = " ++ "I" ++ impl) 1085-- mkPars = unlines . map (\(code, impl) -> " f \"" ++ code ++ "\" = " ++ "I" ++ impl)
1087 1086--
1088type NM = [(String, String)] 1087-- type NM = [(String, String)]
1089nameMap :: NM 1088-- nameMap :: NM
1090nameMap = 1089-- nameMap =
1091 [ ("AG", "Ares") 1090-- [ ("AG", "Ares")
1092 , ("A~", "Ares") 1091-- , ("A~", "Ares")
1093 , ("AR", "Arctic") 1092-- , ("AR", "Arctic")
1094 , ("AV", "Avicora") 1093-- , ("AV", "Avicora")
1095 , ("AX", "BitPump") 1094-- , ("AX", "BitPump")
1096 , ("AZ", "Azureus") 1095-- , ("AZ", "Azureus")
1097 , ("BB", "BitBuddy") 1096-- , ("BB", "BitBuddy")
1098 , ("BC", "BitComet") 1097-- , ("BC", "BitComet")
1099 , ("BF", "Bitflu") 1098-- , ("BF", "Bitflu")
1100 , ("BG", "BTG") 1099-- , ("BG", "BTG")
1101 , ("BR", "BitRocket") 1100-- , ("BR", "BitRocket")
1102 , ("BS", "BTSlave") 1101-- , ("BS", "BTSlave")
1103 , ("BX", "BittorrentX") 1102-- , ("BX", "BittorrentX")
1104 , ("CD", "EnhancedCTorrent") 1103-- , ("CD", "EnhancedCTorrent")
1105 , ("CT", "CTorrent") 1104-- , ("CT", "CTorrent")
1106 , ("DE", "DelugeTorrent") 1105-- , ("DE", "DelugeTorrent")
1107 , ("DP", "PropagateDataClient") 1106-- , ("DP", "PropagateDataClient")
1108 , ("EB", "EBit") 1107-- , ("EB", "EBit")
1109 , ("ES", "ElectricSheep") 1108-- , ("ES", "ElectricSheep")
1110 , ("FT", "FoxTorrent") 1109-- , ("FT", "FoxTorrent")
1111 , ("GS", "GSTorrent") 1110-- , ("GS", "GSTorrent")
1112 , ("HL", "Halite") 1111-- , ("HL", "Halite")
1113 , ("HS", "libHSnetwork_bittorrent") 1112-- , ("HS", "libHSnetwork_bittorrent")
1114 , ("HN", "Hydranode") 1113-- , ("HN", "Hydranode")
1115 , ("KG", "KGet") 1114-- , ("KG", "KGet")
1116 , ("KT", "KTorrent") 1115-- , ("KT", "KTorrent")
1117 , ("LH", "LH_ABC") 1116-- , ("LH", "LH_ABC")
1118 , ("LP", "Lphant") 1117-- , ("LP", "Lphant")
1119 , ("LT", "Libtorrent") 1118-- , ("LT", "Libtorrent")
1120 , ("lt", "LibTorrent") 1119-- , ("lt", "LibTorrent")
1121 , ("LW", "LimeWire") 1120-- , ("LW", "LimeWire")
1122 , ("MO", "MonoTorrent") 1121-- , ("MO", "MonoTorrent")
1123 , ("MP", "MooPolice") 1122-- , ("MP", "MooPolice")
1124 , ("MR", "Miro") 1123-- , ("MR", "Miro")
1125 , ("MT", "MoonlightTorrent") 1124-- , ("MT", "MoonlightTorrent")
1126 , ("NX", "NetTransport") 1125-- , ("NX", "NetTransport")
1127 , ("PD", "Pando") 1126-- , ("PD", "Pando")
1128 , ("qB", "qBittorrent") 1127-- , ("qB", "qBittorrent")
1129 , ("QD", "QQDownload") 1128-- , ("QD", "QQDownload")
1130 , ("QT", "Qt4TorrentExample") 1129-- , ("QT", "Qt4TorrentExample")
1131 , ("RT", "Retriever") 1130-- , ("RT", "Retriever")
1132 , ("S~", "Shareaza") 1131-- , ("S~", "Shareaza")
1133 , ("SB", "Swiftbit") 1132-- , ("SB", "Swiftbit")
1134 , ("SS", "SwarmScope") 1133-- , ("SS", "SwarmScope")
1135 , ("ST", "SymTorrent") 1134-- , ("ST", "SymTorrent")
1136 , ("st", "sharktorrent") 1135-- , ("st", "sharktorrent")
1137 , ("SZ", "Shareaza") 1136-- , ("SZ", "Shareaza")
1138 , ("TN", "TorrentDotNET") 1137-- , ("TN", "TorrentDotNET")
1139 , ("TR", "Transmission") 1138-- , ("TR", "Transmission")
1140 , ("TS", "Torrentstorm") 1139-- , ("TS", "Torrentstorm")
1141 , ("TT", "TuoTu") 1140-- , ("TT", "TuoTu")
1142 , ("UL", "uLeecher") 1141-- , ("UL", "uLeecher")
1143 , ("UT", "uTorrent") 1142-- , ("UT", "uTorrent")
1144 , ("VG", "Vagaa") 1143-- , ("VG", "Vagaa")
1145 , ("WT", "BitLet") 1144-- , ("WT", "BitLet")
1146 , ("WY", "FireTorrent") 1145-- , ("WY", "FireTorrent")
1147 , ("XL", "Xunlei") 1146-- , ("XL", "Xunlei")
1148 , ("XT", "XanTorrent") 1147-- , ("XT", "XanTorrent")
1149 , ("XX", "Xtorrent") 1148-- , ("XX", "Xtorrent")
1150 , ("ZT", "ZipTorrent") 1149-- , ("ZT", "ZipTorrent")
1151 ] 1150-- ]
1152-}
1153 1151
1154-- TODO use regexps 1152-- TODO use regexps
1155 1153
diff --git a/src/Network/BitTorrent/DHT/ContactInfo.hs b/src/Network/BitTorrent/DHT/ContactInfo.hs
index 4293506d..d7c92e35 100644
--- a/src/Network/BitTorrent/DHT/ContactInfo.hs
+++ b/src/Network/BitTorrent/DHT/ContactInfo.hs
@@ -13,97 +13,97 @@ import Data.Serialize
13import Data.Torrent 13import Data.Torrent
14import Network.BitTorrent.Address 14import Network.BitTorrent.Address
15 15
16{- 16-- {-
17import Data.HashMap.Strict as HM 17-- import Data.HashMap.Strict as HM
18 18--
19import Data.Torrent.InfoHash 19-- import Data.Torrent.InfoHash
20import Network.BitTorrent.Address 20-- import Network.BitTorrent.Address
21 21--
22-- increase prefix when table is too large 22-- -- increase prefix when table is too large
23-- decrease prefix when table is too small 23-- -- decrease prefix when table is too small
24-- filter outdated peers 24-- -- filter outdated peers
25 25--
26{----------------------------------------------------------------------- 26-- {-----------------------------------------------------------------------
27-- PeerSet 27-- -- PeerSet
28-----------------------------------------------------------------------} 28-- -----------------------------------------------------------------------}
29 29--
30type PeerSet a = [(PeerAddr a, NodeInfo a, Timestamp)] 30-- type PeerSet a = [(PeerAddr a, NodeInfo a, Timestamp)]
31 31--
32-- compare PSQueue vs Ordered list 32-- -- compare PSQueue vs Ordered list
33 33--
34takeNewest :: PeerSet a -> [PeerAddr a] 34-- takeNewest :: PeerSet a -> [PeerAddr a]
35takeNewest = undefined 35-- takeNewest = undefined
36 36--
37dropOld :: Timestamp -> PeerSet a -> PeerSet a 37-- dropOld :: Timestamp -> PeerSet a -> PeerSet a
38dropOld = undefined 38-- dropOld = undefined
39 39--
40insert :: PeerAddr a -> Timestamp -> PeerSet a -> PeerSet a 40-- insert :: PeerAddr a -> Timestamp -> PeerSet a -> PeerSet a
41insert = undefined 41-- insert = undefined
42 42--
43type Mask = Int 43-- type Mask = Int
44type Size = Int 44-- type Size = Int
45type Timestamp = Int 45-- type Timestamp = Int
46 46--
47{----------------------------------------------------------------------- 47-- {-----------------------------------------------------------------------
48-- InfoHashMap 48-- -- InfoHashMap
49-----------------------------------------------------------------------} 49-- -----------------------------------------------------------------------}
50 50--
51-- compare handwritten prefix tree versus IntMap 51-- -- compare handwritten prefix tree versus IntMap
52 52--
53data Tree a 53-- data Tree a
54 = Nil 54-- = Nil
55 | Tip !InfoHash !(PeerSet a) 55-- | Tip !InfoHash !(PeerSet a)
56 | Bin !InfoHash !Mask !Size !Timestamp (Tree a) (Tree a) 56-- | Bin !InfoHash !Mask !Size !Timestamp (Tree a) (Tree a)
57 57--
58insertTree :: InfoHash -> a -> Tree a -> Tree a 58-- insertTree :: InfoHash -> a -> Tree a -> Tree a
59insertTree = undefined 59-- insertTree = undefined
60 60--
61type Prio = Int 61-- type Prio = Int
62 62--
63--shrink :: ContactInfo ip -> Int 63-- --shrink :: ContactInfo ip -> Int
64shrink Nil = Nil 64-- shrink Nil = Nil
65shrink (Tip _ _) = undefined 65-- shrink (Tip _ _) = undefined
66shrink (Bin _ _) = undefined 66-- shrink (Bin _ _) = undefined
67 67--
68{----------------------------------------------------------------------- 68-- {-----------------------------------------------------------------------
69-- InfoHashMap 69-- -- InfoHashMap
70-----------------------------------------------------------------------} 70-- -----------------------------------------------------------------------}
71 71--
72-- compare new design versus HashMap 72-- -- compare new design versus HashMap
73 73--
74data IntMap k p a 74-- data IntMap k p a
75type ContactInfo = Map InfoHash Timestamp (Set (PeerAddr IP) Timestamp) 75-- type ContactInfo = Map InfoHash Timestamp (Set (PeerAddr IP) Timestamp)
76 76--
77data ContactInfo ip = PeerStore 77-- data ContactInfo ip = PeerStore
78 { maxSize :: Int 78-- { maxSize :: Int
79 , prefixSize :: Int 79-- , prefixSize :: Int
80 , thisNodeId :: NodeId 80-- , thisNodeId :: NodeId
81 81--
82 , count :: Int -- ^ Cached size of the 'peerSet' 82-- , count :: Int -- ^ Cached size of the 'peerSet'
83 , peerSet :: HashMap InfoHash [PeerAddr ip] 83-- , peerSet :: HashMap InfoHash [PeerAddr ip]
84 } 84-- }
85 85--
86size :: ContactInfo ip -> Int 86-- size :: ContactInfo ip -> Int
87size = undefined 87-- size = undefined
88 88--
89prefixSize :: ContactInfo ip -> Int 89-- prefixSize :: ContactInfo ip -> Int
90prefixSize = undefined 90-- prefixSize = undefined
91 91--
92lookup :: InfoHash -> ContactInfo ip -> [PeerAddr ip] 92-- lookup :: InfoHash -> ContactInfo ip -> [PeerAddr ip]
93lookup = undefined 93-- lookup = undefined
94 94--
95insert :: InfoHash -> PeerAddr ip -> ContactInfo ip -> ContactInfo ip 95-- insert :: InfoHash -> PeerAddr ip -> ContactInfo ip -> ContactInfo ip
96insert = undefined 96-- insert = undefined
97 97--
98-- | Limit in size. 98-- -- | Limit in size.
99prune :: NodeId -> Int -> ContactInfo ip -> ContactInfo ip 99-- prune :: NodeId -> Int -> ContactInfo ip -> ContactInfo ip
100prune pref targetSize Nil = Nil 100-- prune pref targetSize Nil = Nil
101prune pref targetSize (Tip _ _) = undefined 101-- prune pref targetSize (Tip _ _) = undefined
102 102--
103-- | Remove expired entries. 103-- -- | Remove expired entries.
104splitGT :: Timestamp -> ContactInfo ip -> ContactInfo ip 104-- splitGT :: Timestamp -> ContactInfo ip -> ContactInfo ip
105splitGT = undefined 105-- splitGT = undefined
106-} 106-- -}
107 107
108-- | Storage used to keep track a set of known peers in client, 108-- | Storage used to keep track a set of known peers in client,
109-- tracker or DHT sessions. 109-- tracker or DHT sessions.