support combineing --socket with HTTPs
authorJoey Hess <joeyh@joeyh.name>
Mon, 7 Jul 2025 20:41:19 +0000 (16:41 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 7 Jul 2025 20:41:19 +0000 (16:41 -0400)
Might be useful when proxying? Dunno.

Command/P2PHttp.hs

index 1463ec5dda3bc9c4e1719c33909f4559b06b92f8..910b0151c58cd83591ed7e25405f356be8e1539f 100644 (file)
@@ -188,13 +188,14 @@ runServer o mst = go `finally` serverShutdownCleanup mst
                                Just socketpath -> 
                                        withsocket socketpath $ \sock ->
                                                Warp.runSettingsSocket settings sock app
-                       (Just certfile, Just privatekeyfile) ->
+                       (Just certfile, Just privatekeyfile) -> do
+                               let tlssettings = Warp.tlsSettingsChain
+                                       certfile (chainFileOption o) privatekeyfile
                                case socketOption o of
-                                       Nothing -> do
-                                               let tlssettings = Warp.tlsSettingsChain
-                                                       certfile (chainFileOption o) privatekeyfile
-                                               Warp.runTLS tlssettings settings app
-                                       Just _socketpath -> giveup "HTTPS is not supported with --socket"
+                                       Nothing -> Warp.runTLS tlssettings settings app
+                                       Just socketpath -> 
+                                               withsocket socketpath $ \sock ->
+                                                       Warp.runTLSSocket tlssettings settings sock app
                        _ -> giveup "You must use both --certfile and --privatekeyfile options to enable HTTPS."
        port = maybe
                (fromIntegral defaultP2PHttpProtocolPort)