summaryrefslogtreecommitdiffhomepage
path: root/HTTP
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-27 13:13:05 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-27 13:13:05 -0400
commitf59cf47cb7f78bda459672c0cab485dad3ff40e0 (patch)
treec4ba8a9e70c93486bac0679362c44d648bb05a91 /HTTP
parent8fe65bd0f70c1cd2fc83469f401c987d69eb4370 (diff)
downloadkeysafe-f59cf47cb7f78bda459672c0cab485dad3ff40e0.tar.gz
Server: Round number of objects down to the nearest thousand, to avoid leaking too much data about when objects are uploaded to servers.
Diffstat (limited to 'HTTP')
-rw-r--r--HTTP/Server.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/HTTP/Server.hs b/HTTP/Server.hs
index f2ecfa8..886fe6f 100644
--- a/HTTP/Server.hs
+++ b/HTTP/Server.hs
@@ -96,8 +96,13 @@ validObjectsize o = any (sz ==) knownObjectSizes
sz = B.length (fromStorableObject o)
countObjects :: ServerState -> Maybe ProofOfWork -> Handler (POWGuarded CountResult)
-countObjects st pow = rateLimit (rateLimiter st) (logger st) pow NoPOWIdent $
- liftIO $ countShares $ storage st
+countObjects st pow = rateLimit (rateLimiter st) (logger st) pow NoPOWIdent $ do
+ v <- liftIO $ countShares $ storage st
+ case v of
+ CountResult n -> return $
+ -- Round down to avoid leaking too much detail.
+ CountResult ((n `div` 1000) * 1000)
+ CountFailure s -> return (CountFailure s)
-- | 1 is a dummy value; the server does not know the actual share numbers.
dummyShareNum :: ShareNum