summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Tracker/RPC
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2014-02-26 16:10:18 +0100
committerDaniel Gröber <dxld@darkboxed.org>2014-02-26 16:10:18 +0100
commit6146b69ecc0f47b1b09e0a3edfa92cb2eda61963 (patch)
tree686e6308f45146b5547228e3f4def851462feadd /src/Network/BitTorrent/Tracker/RPC
parentb041624dca8b66d89180158e28bc5d0808046023 (diff)
parent80d9b5f02c5b245717651132482f11ac66a7ef4a (diff)
Merge branch 'master' of https://github.com/cobit/bittorrent
Diffstat (limited to 'src/Network/BitTorrent/Tracker/RPC')
-rw-r--r--src/Network/BitTorrent/Tracker/RPC/UDP.hs32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/Network/BitTorrent/Tracker/RPC/UDP.hs b/src/Network/BitTorrent/Tracker/RPC/UDP.hs
index db9c32b3..b0f44ec6 100644
--- a/src/Network/BitTorrent/Tracker/RPC/UDP.hs
+++ b/src/Network/BitTorrent/Tracker/RPC/UDP.hs
@@ -60,34 +60,56 @@ import Network.BitTorrent.Tracker.Message
60-- Options 60-- Options
61-----------------------------------------------------------------------} 61-----------------------------------------------------------------------}
62 62
63-- | 'System.Timeout.timeout' specific.
63sec :: Int 64sec :: Int
64sec = 1000000 65sec = 1000000
65 66
67-- | See <http://www.bittorrent.org/beps/bep_0015.html#time-outs>
66defMinTimeout :: Int 68defMinTimeout :: Int
67defMinTimeout = 15 * sec 69defMinTimeout = 15 * sec
68 70
71-- | See <http://www.bittorrent.org/beps/bep_0015.html#time-outs>
69defMaxTimeout :: Int 72defMaxTimeout :: Int
70defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec 73defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec
71 74
75-- | See: <http://www.bittorrent.org/beps/bep_0015.html#time-outs>
72defMultiplier :: Int 76defMultiplier :: Int
73defMultiplier = 2 77defMultiplier = 2
74 78
75-- announce request packet 79-- TODO why 98?
76defMaxPacketSize :: Int 80defMaxPacketSize :: Int
77defMaxPacketSize = 98 81defMaxPacketSize = 98
78 82
83-- | Manager configuration.
79data Options = Options 84data Options = Options
80 { optMaxPacketSize :: {-# UNPACK #-} !Int 85 { -- | Max size of a /response/ packet.
81 86 --
82 -- | in seconds. 87 -- 'optMaxPacketSize' /must/ be a positive value.
88 --
89 optMaxPacketSize :: {-# UNPACK #-} !Int
90
91 -- | Starting timeout interval. If a response is not received
92 -- after 'optMinTimeout' then 'Manager' repeat RPC with timeout
93 -- interval multiplied by 'optMultiplier' and so on until
94 -- timeout interval reach 'optMaxTimeout'.
95 --
96 -- 'optMinTimeout' /must/ be a positive value.
97 --
83 , optMinTimeout :: {-# UNPACK #-} !Int 98 , optMinTimeout :: {-# UNPACK #-} !Int
84 99
85 -- | in seconds. 100 -- | After 'optMaxTimeout' reached and tracker still not
101 -- responding both 'announce' and 'scrape' functions will throw
102 -- 'TimeoutExpired' exception.
103 --
104 -- 'optMaxTimeout' /must/ be greater than 'optMinTimeout'.
105 --
86 , optMaxTimeout :: {-# UNPACK #-} !Int 106 , optMaxTimeout :: {-# UNPACK #-} !Int
87 107
108 -- | 'optMultiplier' must a positive value.
88 , optMultiplier :: {-# UNPACK #-} !Int 109 , optMultiplier :: {-# UNPACK #-} !Int
89 } deriving (Show, Eq) 110 } deriving (Show, Eq)
90 111
112-- | Options suitable for bittorrent client.
91instance Default Options where 113instance Default Options where
92 def = Options 114 def = Options
93 { optMaxPacketSize = defMaxPacketSize 115 { optMaxPacketSize = defMaxPacketSize