mirror of
https://github.com/fafhrd91/actix-net
synced 2024-12-18 22:23:11 +01:00
34 lines
716 B
Rust
34 lines
716 B
Rust
|
use std::cell::Cell;
|
||
|
use std::net::SocketAddr;
|
||
|
use std::rc::Rc;
|
||
|
|
||
|
#[derive(Debug, Clone)]
|
||
|
pub struct ServerConfig {
|
||
|
addr: SocketAddr,
|
||
|
secure: Rc<Cell<bool>>,
|
||
|
}
|
||
|
|
||
|
impl ServerConfig {
|
||
|
pub fn new(addr: SocketAddr) -> Self {
|
||
|
ServerConfig {
|
||
|
addr,
|
||
|
secure: Rc::new(Cell::new(false)),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// Returns the address of the local half of this TCP server socket
|
||
|
pub fn local_addr(&self) -> SocketAddr {
|
||
|
self.addr
|
||
|
}
|
||
|
|
||
|
/// Returns true if connection is secure (tls enabled)
|
||
|
pub fn secure(&self) -> bool {
|
||
|
self.secure.as_ref().get()
|
||
|
}
|
||
|
|
||
|
/// Set secure flag
|
||
|
pub fn set_secure(&self) {
|
||
|
self.secure.as_ref().set(true)
|
||
|
}
|
||
|
}
|