]> git.gsnw.org Git - fping.git/commitdiff
Format change for handle JSON output for invalid hosts
authorGerman Service Network <support@gsnw.de>
Sat, 26 Apr 2025 09:45:02 +0000 (11:45 +0200)
committerSebastian <176771227+gsnw-sebast@users.noreply.github.com>
Sat, 12 Jul 2025 05:43:18 +0000 (07:43 +0200)
ci/test-16-json-output.pl
src/fping.c

index b6d1c2080c6c3760d812ec0cc6016d61a6238b00..16229202e78edf47d399207971a36368082ac491 100644 (file)
@@ -108,8 +108,8 @@ $cmd->stderr_is_eq("");
 {
 my $cmd = Test::Command->new(cmd => "fping -J -c 1 -q host.invalid");
 $cmd->exit_is_num(2);  # Exit code 2 indicates name resolution error
-$cmd->stdout_is_eq("");
-$cmd->stderr_like(qr/^\{"host":\s"host\.invalid", "error":\s"(?:Name or service not known|Temporary failure in name resolution|nodename nor servname provided, or not known)"\}$/);
+$cmd->stdout_like(qr/^\{"warning":\s\{"host":\s"host\.invalid",\s"message":\s"(?:Name or service not known|Temporary failure in name resolution|nodename nor servname provided, or not known)"\}\}$/);
+$cmd->stderr_is_eq("");
 }
 
 # fping -J -c 1 -q -g 127.0.0.1/30
index 97b33416d0c2d08be0cb5b2e5b9bf18734437259..6f6b3f833cf5c09e23676494e073c9f331182574 100644 (file)
@@ -3261,7 +3261,7 @@ void add_name(char *name)
 
         // Handle JSON output for invalid hosts
         if (json_flag) {
-            fprintf(stderr, "{\"host\": \"%s\", \"error\": \"%s\"}", name, gai_strerror(ret_ga));
+            fprintf(stdout, "{\"warning\": {\"host\": \"%s\", \"message\": \"%s\"}}", name, gai_strerror(ret_ga));
             return;
         }