MCPcopy Create free account
hub / github.com/3rdparty/libprocess / launch_client

Method launch_client

include/process/ssl/gtest.hpp:342–380  ·  view source on GitHub ↗

* Launches a test SSL client as a subprocess connecting to the * server. * * The subprocess calls the 'ssl-client' binary with the provided * environment. * * @param environment The SSL environment variables to launch the * SSL client subprocess with. * @param use_ssl_socket Whether the SSL client will try to connect * using an SSL socket or a POLL socket. * @

Source from the content-addressed store, hash-verified

340 * @return Subprocess if successful otherwise an Error.
341 */
342 Try<process::Subprocess> launch_client(
343 const std::map<std::string, std::string>& environment,
344 const Option<std::string>& hostname,
345 const net::IP& ip,
346 uint16_t port,
347 bool use_ssl_socket)
348 {
349 // Set up arguments to be passed to the 'client-ssl' binary.
350 std::vector<std::string> argv = {
351 "ssl-client",
352 "--use_ssl=" + stringify(use_ssl_socket),
353 "--server=" + stringify(ip),
354 "--port=" + stringify(port),
355 "--data=" + data};
356
357 if (hostname.isSome()) {
358 argv.push_back("--server_hostname=" + hostname.get());
359 }
360
361 Result<std::string> path = os::realpath(BUILD_DIR);
362 if (!path.isSome()) {
363 return Error("Could not establish build directory path");
364 }
365
366 // Explicitly set `LIBPROCESS_IP` in the subprocess to the same IP that was
367 // used to generate the hostname for SSL certificates. This ensures that
368 // certificate verification can succeed.
369 std::map<std::string, std::string> full_environment(environment);
370 full_environment["LIBPROCESS_IP"] = stringify(process::address().ip);
371
372 return process::subprocess(
373 path::join(path.get(), "ssl-client"),
374 argv,
375 process::Subprocess::PIPE(),
376 process::Subprocess::PIPE(),
377 process::Subprocess::FD(STDERR_FILENO),
378 nullptr,
379 full_environment);
380 }
381
382 /**
383 * Launches a test SSL client as a subprocess connecting to the

Callers

nothing calls this directly

Calls 4

addressFunction · 0.50
subprocessFunction · 0.50
getMethod · 0.45
addressMethod · 0.45

Tested by

no test coverage detected