mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-04-01 01:25:32 +00:00
implement session update on certificate change in runtime
This commit is contained in:
parent
f4cb0c3bcc
commit
c4c173f6cf
3 changed files with 113 additions and 36 deletions
24
src/client/session.rs
Normal file
24
src/client/session.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use super::Connection;
|
||||
use std::{cell::RefCell, collections::HashMap, rc::Rc};
|
||||
|
||||
/// Request sessions holder for `Client` object
|
||||
/// * useful to keep connections open and / or validate TLS certificate updates in runtime
|
||||
pub struct Session {
|
||||
index: RefCell<HashMap<String, Rc<Connection>>>,
|
||||
}
|
||||
|
||||
impl Session {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
index: RefCell::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(&self, request: &str) -> Option<Rc<Connection>> {
|
||||
self.index.borrow().get(request).cloned()
|
||||
}
|
||||
|
||||
pub fn update(&self, request: String, connection: Rc<Connection>) -> Option<Rc<Connection>> {
|
||||
self.index.borrow_mut().insert(request, connection)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue