Commit graph

36 commits

Author SHA1 Message Date
Joey Hess
7390f08ef9 Use cryptohash rather than SHA for hashing.
This is a massive win on OSX, which doesn't have a sha256sum normally.

Only use external hash commands when the file is > 1 mb,
since cryptohash is quite close to them in speed.

SHA is still used to calculate HMACs. I don't quite understand
cryptohash's API for those.

Used the following benchmark to arrive at the 1 mb number.

1 mb file:

benchmarking sha256/internal
mean: 13.86696 ms, lb 13.83010 ms, ub 13.93453 ms, ci 0.950
std dev: 249.3235 us, lb 162.0448 us, ub 458.1744 us, ci 0.950
found 5 outliers among 100 samples (5.0%)
  4 (4.0%) high mild
  1 (1.0%) high severe
variance introduced by outliers: 10.415%
variance is moderately inflated by outliers

benchmarking sha256/external
mean: 14.20670 ms, lb 14.17237 ms, ub 14.27004 ms, ci 0.950
std dev: 230.5448 us, lb 150.7310 us, ub 427.6068 us, ci 0.950
found 3 outliers among 100 samples (3.0%)
  2 (2.0%) high mild
  1 (1.0%) high severe

2 mb file:

benchmarking sha256/internal
mean: 26.44270 ms, lb 26.23701 ms, ub 26.63414 ms, ci 0.950
std dev: 1.012303 ms, lb 925.8921 us, ub 1.122267 ms, ci 0.950
variance introduced by outliers: 35.540%
variance is moderately inflated by outliers

benchmarking sha256/external
mean: 26.84521 ms, lb 26.77644 ms, ub 26.91433 ms, ci 0.950
std dev: 347.7867 us, lb 210.6283 us, ub 571.3351 us, ci 0.950
found 6 outliers among 100 samples (6.0%)

import Crypto.Hash
import Data.ByteString.Lazy as L
import Criterion.Main
import Common

testfile :: FilePath
testfile = "/run/shm/data" -- on ram disk

main = defaultMain
        [ bgroup "sha256"
                [ bench "internal" $ whnfIO internal
                , bench "external" $ whnfIO external
                ]
        ]

sha256 :: L.ByteString -> Digest SHA256
sha256 = hashlazy

internal :: IO String
internal = show . sha256 <$> L.readFile testfile

external :: IO String
external = do
	s <- readProcess "sha256sum" [testfile]
        return $ fst $ separate (== ' ') s
2013-09-22 20:06:02 -04:00
Joey Hess
1198b5444d now builds with both yesod 1.2 and 1.1 2013-06-03 18:14:22 -04:00
Joey Hess
79fd677805 WIP yesod 1.2 2013-06-03 11:25:23 -04:00
Joey Hess
a48d340abd Android: Work around Android devices where the am command doesn't work. 2013-05-31 21:30:21 -04:00
Joey Hess
25a8d4b11c rename module 2013-05-12 19:19:28 -04:00
Joey Hess
f7d2523adc work around strange endianness bug in port number on Android 2013-05-02 22:38:45 -04:00
Joey Hess
abe8464026 work around getAddrInfo segfault on Android
For an unknown reason, getAddrInfo currently is segfaulting. Note that
in February, I had used warpDebug, which uses getAddrInfo, and it worked.
Don't know if my toolchain has changed and broke it, or it's due to having
a different Android device now. Anyway, work around it by hardcoding the
address to use.
2013-05-02 16:48:14 -04:00
Joey Hess
c8b74cdfd7 stop setting ai_addrconfig
This caused the code to fail on Android, which doesn't know that flag.
It seems best to let the OS default flags be used. Tested working ok on
Linux. The only difference on Linux is it might return a v4mapped ipv6
address sometimes.
2013-05-02 13:01:42 -04:00
Joey Hess
911506bc93 untested browser opening on Android
I've found multiple references to using the `am` command from the adb shell
to open a browser. So I assume it also works in a terminal emulator.
2013-04-18 12:52:55 -04:00
Joey Hess
d1c182f9e2 allow --listen to have a port specified as well as the address 2013-04-09 15:18:05 -04:00
Joey Hess
5e2e4347a3 webapp: New --listen= option allows running the webapp on one computer and connecting to it from another.
Does not yet use HTTPS. I'd need to generate a certificate, and I'm not
sure what's the best way to do that.
2013-04-08 15:04:35 -04:00
Joey Hess
01ce6849de use clientSessionBackend2 where available
avoids a warning, which says it's faster
2013-03-10 16:02:16 -04:00
Joey Hess
56830af8d8 simpler use of MIN_VERSION checks 2013-03-10 15:43:17 -04:00
Joey Hess
3e32bb41f6 webapp: Work around bug in Warp's slowloris attack prevention code, that caused regular browsers to stall when they reuse a connection after leaving it idle for 30 seconds. (See https://github.com/yesodweb/wai/issues/146) 2013-03-09 14:57:48 -04:00
Joey Hess
d7ca6fb856 webapp: Now always logs to .git/annex/daemon.log
It used to not log to daemon.log when a repository was first created, and
when starting the webapp. Now both do. Redirecting stdout and stderr to the
log is tricky when starting the webapp, because the web browser may want to
communicate with the user. (Either a console web browser, or web.browser = echo)
This is handled by restoring the original fds when running the browser.
2013-01-15 13:34:59 -04:00
Joey Hess
6f7ae84650 webapp: Use IP address, rather than localhost
since some systems may have configuration problems or other issues that
prevent web browsers from connecting to the right localhost IP for the
webapp.

Tested on both ipv4 and ipv6 localhost. Url for the latter looks like:
http://[::1]:50676
2013-01-09 23:18:00 -04:00
Joey Hess
bad9b6761d restart UI
Browser behavior is not ideal; a new tab is opened on restart.
Browsers won't let me redirect to a file:// so I cannot use the old tab.
2013-01-03 18:50:30 -04:00
Joey Hess
f87a781aa6 finished where indentation changes 2012-12-13 00:24:19 -04:00
Joey Hess
2525fefbb9 The standalone builds now unset their special path and library path variables before running the system web browser.
Should fix a crash reported on OSX.
2012-11-27 17:05:29 -04:00
Joey Hess
3af1984ed2 fix warning seen on OSX, apparently something there defines a close 2012-11-07 14:56:32 -04:00
Joey Hess
0ccfb3bbb2 let's not -DOSX, that results in unwanted mangling 2012-09-29 14:49:15 -04:00
Joey Hess
fe3009d83b retry bind
This is a workaround for bind failing with EINVAL sometimes on OSX.
I don't know why; EVINAL should mean the socket is already bound to an
address, but this is with a new socket.
2012-09-27 12:23:27 -04:00
Joey Hess
467844d7d3 prefer ipv4 localhost when both are available
The webapp can only run on one of ipv4 and ipv6, no both. Some web browsers
may not support ipv6, so ipv4 is the safe choice.

The actual problem I ran into with it only listening to ipv6 was that
Utility.Url.exists was failing to connect to it. I doubt that haskell's
HTTP library is ipv4 only. More likely, it was only trying one address,
and tried ipv4 first.
2012-09-18 17:19:41 -04:00
Joey Hess
faf3faa79d import yesod qualified
To avoid conflict with different liftIO from MonadIO (in some version of
yesod not the one I have here), and because it's generally clearer, since
this module has both Wai and Yesod stuff, to qualify them both.
2012-08-30 13:05:39 -04:00
Joey Hess
be310ac4d0 support building with yesod-default 1.1.0
Old 1.0.1 version is still supported as well. Cabal autodetects
which version is available, but in the Makefile, WITH_OLD_YESOD
has to be configured appropriately.

I have not squashed all the $newline warnings with the new Yesod.
They should go away eventually anyway as Yesod moves past that transition.
2012-08-09 13:33:04 -04:00
Joey Hess
ac71ab7bd7 avoid head 2012-08-05 15:10:26 -04:00
Joey Hess
ea05ba893c fix the auto token leak on auth error page issue permanantly 2012-07-29 12:12:14 -04:00
Joey Hess
02ec8ea012 much better webapp startup of the assistant
This avoids forking another process, avoids polling, fixes a race,
and avoids a rare forkProcess thread hang that I saw once time
when starting the webapp.
2012-07-27 15:33:24 -04:00
Joey Hess
c93b546ebd remove bogus AI_NUMERICSERV
Not needed, and causes a segfault on OSX when it tries to dereference the
NULL servicename. (Linux handles this case better.)
2012-07-27 14:06:06 -04:00
Joey Hess
2f775ef3e3 fix OSX open call 2012-07-26 12:59:40 -04:00
Joey Hess
95f4b192f0 on second thought, the session cookie is still useful to support setMessage 2012-07-26 12:41:20 -04:00
Joey Hess
cccdb44874 git annex webapp --force forces a restart of the daemon
Useful for testing..
2012-07-26 11:52:49 -04:00
Joey Hess
6cecc26206 update build deps 2012-07-26 05:13:27 -04:00
Joey Hess
9d6b59d0e2 use the secret token for authentication, and add to all dynamic urls 2012-07-26 04:50:09 -04:00
Joey Hess
b36804d648 generate random token and launch webapp using it 2012-07-26 03:38:20 -04:00
Joey Hess
32d3cffc4c run yesod, and launch webapp on startup 2012-07-25 21:26:13 -04:00