diff --git a/cardano-api/src/Cardano/Api/IPC.hs b/cardano-api/src/Cardano/Api/IPC.hs index ffca3305549..4d8048bb0b5 100644 --- a/cardano-api/src/Cardano/Api/IPC.hs +++ b/cardano-api/src/Cardano/Api/IPC.hs @@ -268,6 +268,7 @@ mkVersionedProtocols networkid ptcl unversionedClients = ptclVersion NodeToClientVersionData { networkMagic = toNetworkMagic networkid + , query = False } (\_connid _ctl -> protocols (unversionedClients ptclVersion) ptclBlockVersion ptclVersion)) (Map.toList (Consensus.supportedNodeToClientVersions proxy)) diff --git a/cardano-cli/src/Cardano/CLI/Ping.hs b/cardano-cli/src/Cardano/CLI/Ping.hs index 562ec471762..f51554c53c5 100644 --- a/cardano-cli/src/Cardano/CLI/Ping.hs +++ b/cardano-cli/src/Cardano/CLI/Ping.hs @@ -50,24 +50,26 @@ maybeUnixSockEndPoint = \case UnixSockEndPoint sock -> Just sock data PingCmd = PingCmd - { pingCmdCount :: !Word32 - , pingCmdEndPoint :: !EndPoint - , pingCmdPort :: !String - , pingCmdMagic :: !Word32 - , pingCmdJson :: !Bool - , pingCmdQuiet :: !Bool + { pingCmdCount :: !Word32 + , pingCmdEndPoint :: !EndPoint + , pingCmdPort :: !String + , pingCmdMagic :: !Word32 + , pingCmdJson :: !Bool + , pingCmdQuiet :: !Bool + , pingOptsHandshakeQuery :: !Bool } deriving (Eq, Show) pingClient :: Tracer IO CNP.LogMsg -> Tracer IO String -> PingCmd -> [CNP.NodeVersion] -> AddrInfo -> IO () pingClient stdout stderr cmd = CNP.pingClient stdout stderr opts where opts = CNP.PingOpts - { CNP.pingOptsQuiet = pingCmdQuiet cmd - , CNP.pingOptsJson = pingCmdJson cmd - , CNP.pingOptsCount = pingCmdCount cmd - , CNP.pingOptsHost = maybeHostEndPoint (pingCmdEndPoint cmd) - , CNP.pingOptsUnixSock = maybeUnixSockEndPoint (pingCmdEndPoint cmd) - , CNP.pingOptsPort = pingCmdPort cmd - , CNP.pingOptsMagic = pingCmdMagic cmd + { CNP.pingOptsQuiet = pingCmdQuiet cmd + , CNP.pingOptsJson = pingCmdJson cmd + , CNP.pingOptsCount = pingCmdCount cmd + , CNP.pingOptsHost = maybeHostEndPoint (pingCmdEndPoint cmd) + , CNP.pingOptsUnixSock = maybeUnixSockEndPoint (pingCmdEndPoint cmd) + , CNP.pingOptsPort = pingCmdPort cmd + , CNP.pingOptsMagic = pingCmdMagic cmd + , CNP.pingOptsHandshakeQuery = pingOptsHandshakeQuery cmd } runPingCmd :: PingCmd -> ExceptT PingClientCmdError IO () @@ -196,3 +198,8 @@ pPing = PingCmd , Opt.help "Quiet flag, CSV/JSON only output" ] ) + <*> ( Opt.switch $ mconcat + [ Opt.long "query-versions" + , Opt.help "Query the supported protocol versions during the handshake and terminate the connection." + ] + ) diff --git a/trace-dispatcher/src/Cardano/Logging/Forwarding.hs b/trace-dispatcher/src/Cardano/Logging/Forwarding.hs index 362f4f480dc..a47f7f1a34a 100644 --- a/trace-dispatcher/src/Cardano/Logging/Forwarding.hs +++ b/trace-dispatcher/src/Cardano/Logging/Forwarding.hs @@ -30,10 +30,10 @@ import Ouroboros.Network.Protocol.Handshake.Codec (cborTermVersionData codecHandshake, noTimeLimitsHandshake) import Ouroboros.Network.Protocol.Handshake.Type (Handshake) import Ouroboros.Network.Protocol.Handshake.Version (acceptableVersion, - simpleSingletonVersions) + queryVersion, simpleSingletonVersions) import Ouroboros.Network.Snocket (Snocket, MakeBearer, localAddressFromPath, localSnocket, makeLocalBearer) -import Ouroboros.Network.Socket (AcceptedConnectionsLimit (..), +import Ouroboros.Network.Socket (AcceptedConnectionsLimit (..), HandshakeCallbacks (..), SomeResponderApplication (..), cleanNetworkMutableState, connectToNode, newNetworkMutableState, nullNetworkConnectTracers, nullNetworkServerTracers, withServerNode) @@ -187,7 +187,7 @@ doConnectToAcceptor magic snocket makeBearer configureSocket address timeLimits timeLimits (cborTermVersionDataCodec forwardingCodecCBORTerm) nullNetworkConnectTracers - acceptableVersion + (HandshakeCallbacks acceptableVersion queryVersion) (simpleSingletonVersions ForwardingV_1 (ForwardingVersionData magic) @@ -248,7 +248,7 @@ doListenToAcceptor magic snocket makeBearer configureSocket address timeLimits (codecHandshake forwardingVersionCodec) timeLimits (cborTermVersionDataCodec forwardingCodecCBORTerm) - acceptableVersion + (HandshakeCallbacks acceptableVersion queryVersion) (simpleSingletonVersions ForwardingV_1 (ForwardingVersionData magic) diff --git a/trace-dispatcher/src/Cardano/Logging/Version.hs b/trace-dispatcher/src/Cardano/Logging/Version.hs index e891ed160df..e10619d5dba 100644 --- a/trace-dispatcher/src/Cardano/Logging/Version.hs +++ b/trace-dispatcher/src/Cardano/Logging/Version.hs @@ -16,7 +16,7 @@ import qualified Codec.CBOR.Term as CBOR import Ouroboros.Network.CodecCBORTerm import Ouroboros.Network.Magic -import Ouroboros.Network.Protocol.Handshake.Version (Accept (..), Acceptable (..)) +import Ouroboros.Network.Protocol.Handshake.Version (Accept (..), Acceptable (..), Queryable (..)) data ForwardingVersion = ForwardingV_1 @@ -49,6 +49,9 @@ instance Acceptable ForwardingVersionData where ++ show local ++ " /= " ++ show remote +instance Queryable ForwardingVersionData where + queryVersion _ = False + forwardingCodecCBORTerm :: ForwardingVersion -> CodecCBORTerm Text ForwardingVersionData forwardingCodecCBORTerm _ = CodecCBORTerm { encodeTerm, decodeTerm } where