Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated chrono functions #42

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Payload_Type/thanatos/thanatos/agent_code/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,16 @@ impl Agent {
if now < working_start {
// Calculate the sleep interval if the current time is before
// the working hours
let delta = Duration::seconds(working_start.timestamp() - now.timestamp());
let delta = Duration::seconds(
working_start.and_utc().timestamp() - now.and_utc().timestamp(),
);
sleep_time = delta.to_std().unwrap();
} else if now > working_end {
// Calculate the sleep interval if the current time as after the
// working hours
let next_start = working_start.checked_add_signed(Duration::days(1)).unwrap();
let delta = Duration::seconds(next_start.timestamp() - now.timestamp());
let delta =
Duration::seconds(next_start.and_utc().timestamp() - now.and_utc().timestamp());
sleep_time = delta.to_std().unwrap();
}

Expand Down
6 changes: 4 additions & 2 deletions Payload_Type/thanatos/thanatos/agent_code/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ fn run_beacon() -> Result<(), Box<dyn Error>> {

// Check the agent's working hours and don't check in if not in the configured time frame
if now < working_start {
let delta = Duration::seconds(working_start.timestamp() - now.timestamp());
let delta =
Duration::seconds(working_start.and_utc().timestamp() - now.and_utc().timestamp());
std::thread::sleep(delta.to_std()?);
} else if now > working_end {
let next_start = working_start.checked_add_signed(Duration::days(1)).unwrap();
let delta = Duration::seconds(next_start.timestamp() - now.timestamp());
let delta =
Duration::seconds(next_start.and_utc().timestamp() - now.and_utc().timestamp());
std::thread::sleep(delta.to_std()?);
}

Expand Down
Loading