fix transport (treat "" as eof, remove threadId), upgrade TLS to 1.6.0 (#401)

This commit is contained in:
Evgeny Poberezkin
2022-06-16 08:49:07 +01:00
committed by GitHub
parent 0a71822dd0
commit 5ccebaeb21
5 changed files with 21 additions and 21 deletions
+2 -2
View File
@@ -48,7 +48,7 @@ dependencies:
- iso8601-time == 0.1.*
- memory == 0.15.*
- mtl == 2.2.*
- network == 3.1.2.*
- network >= 3.1.2.7 && < 3.2
- network-transport == 0.5.*
- optparse-applicative >= 0.15 && < 0.17
- QuickCheck == 2.14.*
@@ -61,7 +61,7 @@ dependencies:
- text == 1.2.*
- time == 1.9.*
- time-manager == 0.0.*
- tls >= 1.5.7 && < 1.6
- tls >= 1.6.0 && < 1.7
- transformers == 0.5.*
- unliftio == 0.2.*
- unliftio-core == 0.2.*
+10 -10
View File
@@ -116,7 +116,7 @@ library
, iso8601-time ==0.1.*
, memory ==0.15.*
, mtl ==2.2.*
, network ==3.1.2.*
, network >=3.1.2.7 && <3.2
, network-transport ==0.5.*
, optparse-applicative >=0.15 && <0.17
, process ==1.6.*
@@ -128,7 +128,7 @@ library
, text ==1.2.*
, time ==1.9.*
, time-manager ==0.0.*
, tls >=1.5.7 && <1.6
, tls >=1.6.0 && <1.7
, transformers ==0.5.*
, unliftio ==0.2.*
, unliftio-core ==0.2.*
@@ -175,7 +175,7 @@ executable ntf-server
, iso8601-time ==0.1.*
, memory ==0.15.*
, mtl ==2.2.*
, network ==3.1.2.*
, network >=3.1.2.7 && <3.2
, network-transport ==0.5.*
, optparse-applicative >=0.15 && <0.17
, process ==1.6.*
@@ -188,7 +188,7 @@ executable ntf-server
, text ==1.2.*
, time ==1.9.*
, time-manager ==0.0.*
, tls >=1.5.7 && <1.6
, tls >=1.6.0 && <1.7
, transformers ==0.5.*
, unliftio ==0.2.*
, unliftio-core ==0.2.*
@@ -235,7 +235,7 @@ executable smp-agent
, iso8601-time ==0.1.*
, memory ==0.15.*
, mtl ==2.2.*
, network ==3.1.2.*
, network >=3.1.2.7 && <3.2
, network-transport ==0.5.*
, optparse-applicative >=0.15 && <0.17
, process ==1.6.*
@@ -248,7 +248,7 @@ executable smp-agent
, text ==1.2.*
, time ==1.9.*
, time-manager ==0.0.*
, tls >=1.5.7 && <1.6
, tls >=1.6.0 && <1.7
, transformers ==0.5.*
, unliftio ==0.2.*
, unliftio-core ==0.2.*
@@ -295,7 +295,7 @@ executable smp-server
, iso8601-time ==0.1.*
, memory ==0.15.*
, mtl ==2.2.*
, network ==3.1.2.*
, network >=3.1.2.7 && <3.2
, network-transport ==0.5.*
, optparse-applicative >=0.15 && <0.17
, process ==1.6.*
@@ -308,7 +308,7 @@ executable smp-server
, text ==1.2.*
, time ==1.9.*
, time-manager ==0.0.*
, tls >=1.5.7 && <1.6
, tls >=1.6.0 && <1.7
, transformers ==0.5.*
, unliftio ==0.2.*
, unliftio-core ==0.2.*
@@ -374,7 +374,7 @@ test-suite smp-server-test
, iso8601-time ==0.1.*
, memory ==0.15.*
, mtl ==2.2.*
, network ==3.1.2.*
, network >=3.1.2.7 && <3.2
, network-transport ==0.5.*
, optparse-applicative >=0.15 && <0.17
, process ==1.6.*
@@ -388,7 +388,7 @@ test-suite smp-server-test
, time ==1.9.*
, time-manager ==0.0.*
, timeit ==2.0.*
, tls >=1.5.7 && <1.6
, tls >=1.6.0 && <1.7
, transformers ==0.5.*
, unliftio ==0.2.*
, unliftio-core ==0.2.*
+5 -4
View File
@@ -214,10 +214,11 @@ instance Transport TLS where
readChunks :: ByteString -> IO ByteString
readChunks b
| B.length b >= n = pure b
| otherwise = readChunks . (b <>) =<< T.recvData tlsContext `E.catch` handleEOF
handleEOF = \case
T.Error_EOF -> E.throwIO TEBadBlock
e -> E.throwIO e
| otherwise =
T.recvData tlsContext >>= \case
-- https://hackage.haskell.org/package/tls-1.6.0/docs/Network-TLS.html#v:recvData
"" -> ioe_EOF
s -> readChunks $ b <> s
cPut :: TLS -> ByteString -> IO ()
cPut tls = T.sendData (tlsContext tls) . BL.fromStrict
+2 -1
View File
@@ -55,7 +55,8 @@ runTCPServer started port server = do
$ \sock -> forever . E.bracketOnError (accept sock) (close . fst) $ \(conn, _peer) -> do
-- catchAll_ is needed here in case the connection was closed earlier
cId <- atomically $ stateTVar clientId $ \cId -> (cId + 1, cId + 1)
tId <- mkWeakThreadId =<< forkFinally (server conn) (const $ gracefulClose conn 5000 `catchAll_` atomically (TM.delete cId clients))
let closeConn _ = atomically (TM.delete cId clients) >> gracefulClose conn 5000 `catchAll_` pure ()
tId <- mkWeakThreadId =<< server conn `forkFinally` closeConn
atomically $ TM.insert cId tId clients
closeServer :: TMVar Bool -> TMap Int (Weak ThreadId) -> Socket -> IO ()
+2 -4
View File
@@ -17,7 +17,7 @@
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-18.21
resolver: lts-18.28
# User packages to be built.
# Various formats can be used as shown in the example below.
@@ -38,8 +38,7 @@ extra-deps:
- cryptostore-0.2.1.0@sha256:9896e2984f36a1c8790f057fd5ce3da4cbcaf8aa73eb2d9277916886978c5b19,3881
- network-3.1.2.7@sha256:e3d78b13db9512aeb106e44a334ab42b7aa48d26c097299084084cb8be5c5568,4888
- simple-logger-0.1.0@sha256:be8ede4bd251a9cac776533bae7fb643369ebd826eb948a9a18df1a8dd252ff8,1079
- tls-1.5.7@sha256:1cc30253a9696b65a9cafc0317fbf09f7dcea15e3a145ed6c9c0e28c632fa23a,6991
# below dependancies are to update Aeson to 2.0.3
- tls-1.6.0@sha256:7ae39373fd2de27fb80e90f76d22aeeb9a074a0ddd120cbd02c9c52f516a9e55,6987 # below dependancies are to update Aeson to 2.0.3
- OneTuple-0.3.1@sha256:a848c096c9d29e82ffdd30a9998aa2931cbccb3a1bc137539d80f6174d31603e,2262
- attoparsec-0.14.4@sha256:79584bdada8b730cb5138fca8c35c76fbef75fc1d1e01e6b1d815a5ee9843191,5810
- hashable-1.4.0.2@sha256:0cddd0229d1aac305ea0404409c0bbfab81f075817bd74b8b2929eff58333e55,5005
@@ -53,7 +52,6 @@ extra-deps:
# commit: f6cc753611f80af300401cfae63846e9d7c40d9e
# subdirs:
# - core
# Override default flag values for local packages and extra-deps
# flags: {}