| 405 | #if defined(OPENVPN_PLATFORM_WIN) |
| 406 | |
| 407 | static void start_thread(Client& client) |
| 408 | { |
| 409 | // Set Windows title bar |
| 410 | const std::string title_text = "F2:Stats F3:Reconnect F4:Stop F5:Pause"; |
| 411 | Win::Console::Title title(ClientAPI::OpenVPNClient::platform() + " " + title_text); |
| 412 | Win::Console::Input console; |
| 413 | |
| 414 | // start connect thread |
| 415 | std::unique_ptr<std::thread> thread; |
| 416 | volatile bool thread_exit = false; |
| 417 | the_client = &client; |
| 418 | thread.reset(new std::thread([&thread_exit]() { |
| 419 | worker_thread(); |
| 420 | thread_exit = true; |
| 421 | })); |
| 422 | |
| 423 | // wait for connect thread to exit, also check for keypresses |
| 424 | while (!thread_exit) |
| 425 | { |
| 426 | while (true) |
| 427 | { |
| 428 | const unsigned int c = console.get(); |
| 429 | if (!c) |
| 430 | break; |
| 431 | else if (c == 0x3C) // F2 |
| 432 | the_client->print_stats(); |
| 433 | else if (c == 0x3D) // F3 |
| 434 | the_client->reconnect(0); |
| 435 | else if (c == 0x3E) // F4 |
| 436 | the_client->stop(); |
| 437 | else if (c == 0x3F) // F5 |
| 438 | the_client->pause("user-pause"); |
| 439 | } |
| 440 | Sleep(1000); |
| 441 | } |
| 442 | |
| 443 | // wait for connect thread to exit |
| 444 | thread->join(); |
| 445 | |
| 446 | the_client = nullptr; |
| 447 | } |
| 448 | |
| 449 | #elif defined(OPENVPN_OVPNCLI_SINGLE_THREAD) |
| 450 |
no test coverage detected