| 97 | } |
| 98 | |
| 99 | bool Connection::connect_remote() |
| 100 | { |
| 101 | auto argv_opt = connect_argv_.gen(argv_replace_); |
| 102 | if (!argv_opt) { |
| 103 | return false; |
| 104 | } |
| 105 | |
| 106 | using namespace std::chrono_literals; |
| 107 | auto output_opt = startup_and_read_pipe(*argv_opt, 60s); |
| 108 | if (!output_opt) { |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | constexpr std::array<std::string_view, 4> kErrorFlag = { "error", "cannot", "refused", "unable to connect" }; |
| 113 | for (const auto& flag : kErrorFlag) { |
| 114 | if (output_opt->find(flag) != std::string::npos) { |
| 115 | LogInfo << "unable to connect"; |
| 116 | return false; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | LogInfo << "connected"; |
| 121 | return true; |
| 122 | } |
| 123 | |
| 124 | bool Connection::start_monitor() |
| 125 | { |