Issue tokens to initialize VNC connections
This commit is contained in:
@ -1,2 +1,4 @@
|
||||
pub mod files_utils;
|
||||
pub mod rand_utils;
|
||||
pub mod time_utils;
|
||||
pub mod url_utils;
|
||||
|
12
virtweb_backend/src/utils/rand_utils.rs
Normal file
12
virtweb_backend/src/utils/rand_utils.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::Rng;
|
||||
|
||||
/// Generate a random string
|
||||
pub fn rand_str(len: usize) -> String {
|
||||
let s: String = rand::thread_rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(len)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
s
|
||||
}
|
15
virtweb_backend/src/utils/time_utils.rs
Normal file
15
virtweb_backend/src/utils/time_utils.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
/// Get the current time since epoch
|
||||
///
|
||||
/// ```
|
||||
/// use virtweb_backend::utils::time_utils::time;
|
||||
///
|
||||
/// let time = time();
|
||||
/// ```
|
||||
pub fn time() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs()
|
||||
}
|
Reference in New Issue
Block a user