| 504 | */ |
| 505 | |
| 506 | void BaseRunner::connect_proxy() { |
| 507 | LOG(DEBUG) << "connecting to proxy"; |
| 508 | if (!runner_config_) { |
| 509 | LOG(DEBUG) << "no root contract"; |
| 510 | return; |
| 511 | } |
| 512 | |
| 513 | auto proxy = runner_config_->root_contract_config->get_random_proxy(); |
| 514 | if (!proxy) { |
| 515 | LOG(WARNING) << "cannot connection to a proxy: no proxies in root contract"; |
| 516 | return; |
| 517 | } |
| 518 | |
| 519 | td::IPAddress dst_addr = |
| 520 | connect_to_proxy_to_client_address_ ? proxy->address_for_clients : proxy->address_for_workers; |
| 521 | if (get_proxy_target_by_address(dst_addr)) { |
| 522 | LOG(DEBUG) << "duplicate"; |
| 523 | /* duplicate */ |
| 524 | return; |
| 525 | } |
| 526 | auto target_id = generate_unique_uint64(); |
| 527 | auto p = allocate_proxy_target(target_id, dst_addr); |
| 528 | if (!p) { |
| 529 | LOG(WARNING) << "cannot allocate proxy target"; |
| 530 | return; |
| 531 | } |
| 532 | td::actor::send_closure(client_, &TcpClient::add_outbound_address, target_id, dst_addr, remote_app_type_proxy()); |
| 533 | CHECK(proxy_targets_.emplace(target_id, std::move(p)).second); |
| 534 | LOG(INFO) << "OK, connecting to " << dst_addr; |
| 535 | } |
| 536 | |
| 537 | void BaseRunner::disconnect_proxy(TcpClient::TargetId target_id) { |
| 538 | LOG(INFO) << "disconnecting from proxy..."; |
nothing calls this directly
no test coverage detected