| 52 | namespace c2 { |
| 53 | |
| 54 | C2Agent::C2Agent(core::controller::ControllerServiceProvider* controller, |
| 55 | const std::shared_ptr<state::StateMonitor> &updateSink, |
| 56 | const std::shared_ptr<Configure> &configuration, |
| 57 | const std::shared_ptr<utils::file::FileSystem>& filesystem) |
| 58 | : heart_beat_period_(3000), |
| 59 | max_c2_responses(5), |
| 60 | update_sink_(updateSink), |
| 61 | update_service_(nullptr), |
| 62 | controller_(controller), |
| 63 | configuration_(configuration), |
| 64 | filesystem_(filesystem), |
| 65 | protocol_(nullptr), |
| 66 | logger_(logging::LoggerFactory<C2Agent>::getLogger()), |
| 67 | thread_pool_(2, false, nullptr, "C2 threadpool") { |
| 68 | allow_updates_ = true; |
| 69 | |
| 70 | manifest_sent_ = false; |
| 71 | |
| 72 | running_c2_configuration = std::make_shared<Configure>(); |
| 73 | |
| 74 | last_run_ = std::chrono::steady_clock::now(); |
| 75 | |
| 76 | if (nullptr != controller_) { |
| 77 | update_service_ = std::static_pointer_cast<controllers::UpdatePolicyControllerService>(controller_->getControllerService(UPDATE_NAME)); |
| 78 | } |
| 79 | |
| 80 | if (update_service_ == nullptr) { |
| 81 | // create a stubbed service for updating the flow identifier |
| 82 | } |
| 83 | |
| 84 | configure(configuration, false); |
| 85 | |
| 86 | functions_.emplace_back([this] {return produce();}); |
| 87 | functions_.emplace_back([this] {return consume();}); |
| 88 | } |
| 89 | |
| 90 | void C2Agent::start() { |
| 91 | if (controller_running_) { |
nothing calls this directly
no test coverage detected