diff --git a/cardano-diffusion/changelog.d/20260825_143837_coot_cardano_ping.md b/cardano-diffusion/changelog.d/20260825_143837_coot_cardano_ping.md new file mode 100644 index 0000000000..f6fb181fc7 --- /dev/null +++ b/cardano-diffusion/changelog.d/20260825_143837_coot_cardano_ping.md @@ -0,0 +1,29 @@ + + + +### Non-Breaking + +- Improved `cardano-diffusion:ping` output: + * don't report results, if there were none + * changed `DNSError` show instance: it's easier to read if the error is + followed by dns name, especially if there are multiple errors of the + same type, like `NameError`. + * when resolving an SRV record fails show the effective domain name, e.g. + `_cardano._tcp.domain.com` rather than `domain.com`. + + diff --git a/cardano-diffusion/ping/Cardano/Network/Ping.hs b/cardano-diffusion/ping/Cardano/Network/Ping.hs index a973b1b47c..75ccf4a265 100644 --- a/cardano-diffusion/ping/Cardano/Network/Ping.hs +++ b/cardano-diffusion/ping/Cardano/Network/Ping.hs @@ -415,7 +415,7 @@ instance Exception AddressResolutionError where displayException (NoPortNumberError addr) = "missing port number for " ++ ppSomeAddress addr displayException (DNSError addr err) - = ppSomeAddress addr ++ ": " ++ displayException err + = displayException err ++ " for " ++ ppSomeAddress addr -- | Log messages to stderr. -- @@ -912,14 +912,14 @@ resolveAddress -> IO ([Address Resolved], [AddressResolutionError]) -- 1. Resolve an SRV record - go addr@(SRV dns) = do + go (SRV dns) = do let hostname = BS.Char.pack $ case srvPrefix of [] -> dns _ -> srvPrefix ++ "." ++ dns r <- DNS.lookupRaw resolver hostname DNS.SRV case r >>= flip DNS.fromDNSMessage selectSRV of Left err -> do - let err' = DNSError (SomeAddress addr) err + let err' = DNSError (SomeAddress (SRV $ BS.Char.unpack hostname)) err traceWith stderr (AddressResolutionError err') case acceptFilePath of AddressMightBeAFilePath -> @@ -978,7 +978,7 @@ resolveAddress (ips, errs) -> do let errs' = [ DNSError (SomeAddress addr) err | err <- errs ] traverse_ (traceWith stderr . AddressResolutionError) errs' - unless pingOptsQuiet $ + unless (pingOptsQuiet || null ips) $ traceWith stderr $ DNSResolution hostname ips port return ( [ IP ip port | ip <- ips ] , errs'