]> git.rkrishnan.org Git - functorrent.git/blobdiff - src/FuncTorrent/Tracker/Http.hs
WIP: UDP tracker, compiles
[functorrent.git] / src / FuncTorrent / Tracker / Http.hs
index 5caefd663acbce46cc91dc6243623790724ea79a..fe1f3e1e55ace932acc4463943ca73def0f0c31c 100644 (file)
@@ -42,8 +42,8 @@ import FuncTorrent.Bencode (BVal(..))
 import qualified FuncTorrent.FileSystem as FS (MsgChannel, Stats(..), getStats)
 import FuncTorrent.Network (sendGetRequest)
 import FuncTorrent.Peer (Peer(..))
-import FuncTorrent.Utils (splitN)
-import FuncTorrent.Tracker.Types(TState(..), TrackerResponse(..), Port, IP)
+import FuncTorrent.Utils (splitN, toIP, toPort, IP, Port)
+import FuncTorrent.Tracker.Types(TState(..), TrackerResponse(..))
 
 
 --- | URL encode hash as per RFC1738
@@ -118,14 +118,3 @@ parseTrackerResponse resp =
 makePeer :: ByteString -> Peer
 makePeer peer = Peer "" (toIP ip') (toPort port')
   where (ip', port') = splitAt 4 peer
-
-toPort :: ByteString -> Port
-toPort = read . ("0x" ++) . unpack . B16.encode
-
-toIP :: ByteString -> IP
-toIP = Data.List.intercalate "." .
-       map (show . toInt . ("0x" ++) . unpack) .
-       splitN 2 . B16.encode
-
-toInt :: String -> Integer
-toInt = read