Issue tokens to initialize VNC connections

This commit is contained in:
2023-10-18 12:27:50 +02:00
parent 3042bbdac6
commit 4f75cd918d
10 changed files with 173 additions and 2 deletions

View File

@ -1,2 +1,4 @@
pub mod files_utils;
pub mod rand_utils;
pub mod time_utils;
pub mod url_utils;

View 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
}

View 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()
}