-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
25 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
Payload_Type/thanatos/agent/thanatos/core/src/agent/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
use thanatos_protos::config::Config; | ||
|
||
use crate::errors; | ||
|
||
pub struct Agent {} | ||
|
||
impl Agent { | ||
pub fn perform_checkin(agent_config: Config) -> Result<Agent, errors::ThanatosError> { | ||
Ok(Agent {}) | ||
} | ||
|
||
pub fn run(self) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
pub mod os; | ||
pub mod time; | ||
|
||
#[cfg(target_os = "linux")] | ||
pub use os::linux::*; | ||
|
11 changes: 0 additions & 11 deletions
11
Payload_Type/thanatos/agent/thanatos/core/src/system/time.rs
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
Payload_Type/thanatos/agent/thanatos/core/src/timecheck/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use chrono::{DateTime, NaiveTime, TimeDelta, Utc}; | ||
|
||
#[inline] | ||
pub fn passed_killdate(killdate: DateTime<Utc>) -> bool { | ||
killdate >= Utc::now() | ||
} | ||
|
||
pub fn check_working_hours(start_time: TimeDelta, end_time: TimeDelta) -> Option<TimeDelta> { | ||
let current_tod = Utc::now().time().signed_duration_since(NaiveTime::MIN); | ||
|
||
if current_tod < start_time { | ||
Some(start_time - current_tod) | ||
} else if current_tod >= end_time { | ||
Some(TimeDelta::days(1) - current_tod + start_time) | ||
} else { | ||
None | ||
} | ||
} |