packages feed

quic 0.0.0 → 0.0.1

raw patch · 14 files changed

+32/−24 lines, 14 files

Files

+ ChangeLog.md view
@@ -0,0 +1,8 @@+## 0.0.1++- Making Haskell servers friendly with Chrome+  [#20](https://github.com/kazu-yamamoto/quic/pull/20)++## 0.0.0++- Initial version.
Network/QUIC/Client.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE PatternSynonyms #-}- -- | This main module provides APIs for QUIC clients. --   When a new better network interface is up, --   migration is done automatically.
Network/QUIC/Client/Run.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE PatternGuards #-} {-# LANGUAGE ScopedTypeVariables #-}  module Network.QUIC.Client.Run (
Network/QUIC/Closer.hs view
@@ -93,7 +93,7 @@     loop n = do         _ <- send         getTimeMicrosecond >>= skip (Microseconds pto)-        mx <- timeout (Microseconds (pto .>>. 1)) $ recv+        mx <- timeout (Microseconds (pto .>>. 1)) recv         case mx of           Nothing -> hook           Just 0  -> return ()
Network/QUIC/Connection.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE OverloadedStrings #-}- module Network.QUIC.Connection (     module Network.QUIC.Connection.PacketNumber   , module Network.QUIC.Connection.Crypto
Network/QUIC/Connection/Migration.hs view
@@ -157,7 +157,7 @@     -- But receiver guarantees that there is at least one cidinfo.     usedCIDInfo' | cidInfoSeq usedCIDInfo >= n = usedCIDInfo                  | otherwise            = snd $ IntMap.findMin cidInfos'-    revInfos' = foldr (\k m -> Map.delete k m) revInfos dropCIDs+    revInfos' = foldr Map.delete revInfos dropCIDs     db' = db {         usedCIDInfo = usedCIDInfo'       , cidInfos    = cidInfos'
Network/QUIC/Connection/Misc.hs view
@@ -59,7 +59,7 @@     \ss@(s0:_) -> (s1:ss,s0)  clearSockets :: Connection -> IO [Socket]-clearSockets Connection{..} = atomicModifyIORef sockets $ \ss -> ([],ss)+clearSockets Connection{..} = atomicModifyIORef sockets ([],)  ---------------------------------------------------------------- @@ -141,7 +141,7 @@     writeIORef tmouter (deRefWeak wtid >>= mapM_ killThread)  replaceKillTimeouter :: Connection -> IO (IO ())-replaceKillTimeouter Connection{..} = atomicModifyIORef' tmouter $ \m -> (return (), m)+replaceKillTimeouter Connection{..} = atomicModifyIORef' tmouter (return (),)  ---------------------------------------------------------------- 
Network/QUIC/Packet/Frame.hs view
@@ -196,27 +196,30 @@  countZero :: Ptr Word8 -> Ptr Word8 -> IO Int countZero beg0 end0-  | (end0 `minusPtr` beg0) <= ali = countBy1 beg0 end0 0+  | (end0 `minusPtr` beg0) <= ali = fst <$> countBy1 beg0 end0 0   | otherwise = do     let beg1 = alignPtr beg0 ali         end1' = alignPtr end0 ali         end1 | end0 == end1' = end1'              | otherwise     = end1' `plusPtr` negate ali-    n1        <- countBy1 beg0 beg1 0-    (n2,beg2) <- countBy8 (castPtr beg1) (castPtr end1) 0-    n3        <- countBy1 (castPtr beg2) end0 0-    return (n1 + n2 + n3)+    (n1,cont1) <- countBy1 beg0 beg1 0+    if not cont1 then+        return n1+      else do+        (n2,beg2) <- countBy8 (castPtr beg1) (castPtr end1) 0+        (n3,_) <- countBy1 (castPtr beg2) end0 0+        return (n1 + n2 + n3)   where     ali = alignment (0 :: Word64)-    countBy1 :: Ptr Word8 -> Ptr Word8 -> Int -> IO Int+    countBy1 :: Ptr Word8 -> Ptr Word8 -> Int -> IO (Int,Bool)     countBy1 beg end n       | beg < end = do             ftyp <- peek beg             if ftyp == 0 then                 countBy1 (beg `plusPtr` 1) end (n + 1)               else-                return n-      | otherwise = return n+                return (n, False)+      | otherwise = return (n, True)     countBy8 :: Ptr Word64 -> Ptr Word64 -> Int -> IO (Int, Ptr Word64)     countBy8 beg end n       | beg < end = do
Network/QUIC/Receiver.hs view
@@ -183,7 +183,7 @@ processFrame _ _ Padding{} = return () processFrame conn lvl Ping = do     -- see ackEli above-    when (lvl /= RTT1Level) $ sendFrames conn lvl []+    when (lvl /= InitialLevel && lvl /= RTT1Level) $ sendFrames conn lvl [] processFrame conn lvl (Ack ackInfo ackDelay) = do     when (lvl == RTT0Level) $ closeConnection ProtocolViolation "ACK"     onAckReceived (connLDCC conn) lvl ackInfo $ milliToMicro ackDelay
Network/QUIC/Server.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE PatternSynonyms #-}- -- | This main module provides APIs for QUIC servers. module Network.QUIC.Server (   -- * Running a QUIC server
Network/QUIC/Server/Reader.hs view
@@ -200,7 +200,7 @@         logAction $ "too small " <> bhow bytes <> ", " <> bhow peersa   | ver `notElem` scVersions= do         let vers | ver == GreasingVersion = GreasingVersion2 : scVersions-                 | otherwise = GreasingVersion : scVersions+                 | otherwise              = GreasingVersion  : scVersions         bss <- encodeVersionNegotiationPacket $ VersionNegotiationPacket sCID dCID vers         send bss   | token == "" = do
Network/QUIC/Server/Run.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE PatternGuards #-} {-# LANGUAGE ScopedTypeVariables #-}  module Network.QUIC.Server.Run (
quic.cabal view
@@ -1,5 +1,5 @@ name:                quic-version:             0.0.0+version:             0.0.1 synopsis:            QUIC description:         Library for QUIC: A UDP-Based Multiplexed and Secure Transport license:             BSD3@@ -9,8 +9,8 @@ -- copyright: category:            Web build-type:          Simple--- extra-source-files:  ChangeLog.md cabal-version:       >= 1.10+extra-source-files:  ChangeLog.md extra-source-files:  cbits/*.h extra-source-files:  cbits/picotls/*.h extra-source-files:  test/servercert.pem
test/FrameSpec.hs view
@@ -46,3 +46,8 @@                 countZero (beg +. 1) (beg +. 10) `shouldReturn` 9                 countZero (beg +. 1) (beg +. 11) `shouldReturn` 10                 countZero (beg +. 2) (beg +. 3) `shouldReturn` 1+                poke (beg +. 10) (1 :: Word8)+                countZero beg end `shouldReturn` 10+                countZero (beg +. 1) end `shouldReturn` 9+                countZero (beg +. 2) end `shouldReturn` 8+                countZero (beg +. 3) end `shouldReturn` 7