diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-09-27 13:13:05 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-09-27 13:13:05 -0400 |
commit | f59cf47cb7f78bda459672c0cab485dad3ff40e0 (patch) | |
tree | c4ba8a9e70c93486bac0679362c44d648bb05a91 | |
parent | 8fe65bd0f70c1cd2fc83469f401c987d69eb4370 (diff) | |
download | keysafe-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.
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | HTTP/Server.hs | 9 |
2 files changed, 9 insertions, 2 deletions
@@ -14,6 +14,8 @@ keysafe (0.20160923) UNRELEASED; urgency=medium * Server: --motd can be used to provide a Message Of The Day. * Added --check-servers mode, which is useful both at the command line to see what servers keysafe knows about, and as a cron job. + * Server: Round number of objects down to the nearest thousand, to avoid + leaking too much data about when objects are uploaded to servers. -- Joey Hess <id@joeyh.name> Fri, 23 Sep 2016 10:40:55 -0400 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 |