From 94d19e19725905c3d10acd28cce78268a53d5ff6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Thu, 29 Sep 2022 20:42:57 +0200
Subject: [PATCH] hydra: fix localhost detection when protocol prefix are used

---
 src/hydra-queue-runner/state.hh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh
index 47e74f55..55c99afc 100644
--- a/src/hydra-queue-runner/state.hh
+++ b/src/hydra-queue-runner/state.hh
@@ -6,6 +6,7 @@
 #include <map>
 #include <memory>
 #include <queue>
+#include <regex>
 
 #include <prometheus/counter.h>
 #include <prometheus/gauge.h>
@@ -293,7 +294,8 @@ struct Machine
 
     bool isLocalhost()
     {
-        return sshName == "localhost";
+        std::regex r("^(ssh://|ssh-ng://)?localhost$");
+        return std::regex_search(sshName, r);
     }
 };