diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2014-02-26 16:10:18 +0100 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2014-02-26 16:10:18 +0100 |
commit | 6146b69ecc0f47b1b09e0a3edfa92cb2eda61963 (patch) | |
tree | 686e6308f45146b5547228e3f4def851462feadd /src/Network/BitTorrent/Tracker/RPC | |
parent | b041624dca8b66d89180158e28bc5d0808046023 (diff) | |
parent | 80d9b5f02c5b245717651132482f11ac66a7ef4a (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.hs | 32 |
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. | ||
63 | sec :: Int | 64 | sec :: Int |
64 | sec = 1000000 | 65 | sec = 1000000 |
65 | 66 | ||
67 | -- | See <http://www.bittorrent.org/beps/bep_0015.html#time-outs> | ||
66 | defMinTimeout :: Int | 68 | defMinTimeout :: Int |
67 | defMinTimeout = 15 * sec | 69 | defMinTimeout = 15 * sec |
68 | 70 | ||
71 | -- | See <http://www.bittorrent.org/beps/bep_0015.html#time-outs> | ||
69 | defMaxTimeout :: Int | 72 | defMaxTimeout :: Int |
70 | defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec | 73 | defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec |
71 | 74 | ||
75 | -- | See: <http://www.bittorrent.org/beps/bep_0015.html#time-outs> | ||
72 | defMultiplier :: Int | 76 | defMultiplier :: Int |
73 | defMultiplier = 2 | 77 | defMultiplier = 2 |
74 | 78 | ||
75 | -- announce request packet | 79 | -- TODO why 98? |
76 | defMaxPacketSize :: Int | 80 | defMaxPacketSize :: Int |
77 | defMaxPacketSize = 98 | 81 | defMaxPacketSize = 98 |
78 | 82 | ||
83 | -- | Manager configuration. | ||
79 | data Options = Options | 84 | data 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. | ||
91 | instance Default Options where | 113 | instance Default Options where |
92 | def = Options | 114 | def = Options |
93 | { optMaxPacketSize = defMaxPacketSize | 115 | { optMaxPacketSize = defMaxPacketSize |