@@ -257,6 +257,9 @@ data Server =
257
257
258
258
-- | Make secure connection (with TLS) to the given server
259
259
| ServerSecure ServerValidation SslKeyLog Address
260
+
261
+ -- | Make a local connection over a Unix domain socket
262
+ | ServerUnix FilePath
260
263
deriving stock (Show )
261
264
262
265
{- ------------------------------------------------------------------------------
@@ -429,6 +432,8 @@ stayConnected connParams initialServer connStateVar connOutOfScope = do
429
432
connectInsecure connParams attempt addr
430
433
ServerSecure validation sslKeyLog addr ->
431
434
connectSecure connParams attempt validation sslKeyLog addr
435
+ ServerUnix path ->
436
+ connectUnix connParams attempt path
432
437
433
438
thisReconnectPolicy <- atomically $ do
434
439
putTMVar (attemptClosed attempt) $ either Just (\ () -> Nothing ) mRes
@@ -462,21 +467,21 @@ stayConnected connParams initialServer connStateVar connOutOfScope = do
462
467
atomically $ writeTVar connStateVar $ ConnectionNotReady
463
468
loop nextServer =<< f
464
469
470
+ -- | Unix domain socket connection
471
+ connectUnix :: ConnParams -> Attempt -> FilePath -> IO ()
472
+ connectUnix connParams attempt path = do
473
+ client <- socket AF_UNIX Stream defaultProtocol
474
+ connect client $ SockAddrUnix path
475
+ connectSocket connParams attempt " localhost" client
476
+
465
477
-- | Insecure connection (no TLS)
466
478
connectInsecure :: ConnParams -> Attempt -> Address -> IO ()
467
479
connectInsecure connParams attempt addr = do
468
480
Run. runTCPClientWithSettings
469
481
runSettings
470
482
(addressHost addr)
471
- (show $ addressPort addr) $ \ sock ->
472
- bracket (HTTP2.Client. allocSimpleConfig sock writeBufferSize)
473
- HTTP2.Client. freeSimpleConfig $ \ conf ->
474
- HTTP2.Client. run clientConfig conf $ \ sendRequest _aux -> do
475
- let conn = Session. ConnectionToServer sendRequest
476
- atomically $
477
- writeTVar (attemptState attempt) $
478
- ConnectionReady (attemptClosed attempt) conn
479
- takeMVar $ attemptOutOfScope attempt
483
+ (show $ addressPort addr)
484
+ $ connectSocket connParams attempt (authority addr)
480
485
where
481
486
ConnParams {connHTTP2Settings} = connParams
482
487
@@ -485,6 +490,20 @@ connectInsecure connParams attempt addr = do
485
490
Run. settingsOpenClientSocket = openClientSocket connHTTP2Settings
486
491
}
487
492
493
+ -- | Insecure connection over the given socket
494
+ connectSocket :: ConnParams -> Attempt -> String -> Socket -> IO ()
495
+ connectSocket connParams attempt connAuthority sock = do
496
+ bracket (HTTP2.Client. allocSimpleConfig sock writeBufferSize)
497
+ HTTP2.Client. freeSimpleConfig $ \ conf ->
498
+ HTTP2.Client. run clientConfig conf $ \ sendRequest _aux -> do
499
+ let conn = Session. ConnectionToServer sendRequest
500
+ atomically $
501
+ writeTVar (attemptState attempt) $
502
+ ConnectionReady (attemptClosed attempt) conn
503
+ takeMVar $ attemptOutOfScope attempt
504
+ where
505
+ ConnParams {connHTTP2Settings} = connParams
506
+
488
507
settings :: HTTP2.Client. Settings
489
508
settings = HTTP2.Client. defaultSettings {
490
509
HTTP2.Client. maxConcurrentStreams =
@@ -498,7 +517,7 @@ connectInsecure connParams attempt addr = do
498
517
clientConfig :: HTTP2.Client. ClientConfig
499
518
clientConfig = overrideRateLimits connParams $
500
519
HTTP2.Client. defaultClientConfig {
501
- HTTP2.Client. authority = authority addr
520
+ HTTP2.Client. authority = connAuthority
502
521
, HTTP2.Client. settings = settings
503
522
, HTTP2.Client. connectionWindowSize =
504
523
fromIntegral $
0 commit comments