Better Connection handling and some ideas

This commit is contained in:
Gregor Reitzenstein 2020-05-10 17:23:43 +02:00
parent 2c321d77b4
commit 8b4296e749
5 changed files with 42 additions and 1 deletions

View File

@ -1,4 +1,5 @@
fn main() {
::capnpc::CompilerCommand::new().file("schema/connection.capnp").run().unwrap();
::capnpc::CompilerCommand::new().file("schema/api.capnp").run().unwrap();
::capnpc::CompilerCommand::new().file("schema/auth.capnp").run().unwrap();
}

34
connection-state.dot Normal file
View File

@ -0,0 +1,34 @@
strict digraph connection {
Establish [label="TCP/SCTP connection established"];
Closed [label="TCP/SCTP connection closed"];
Establish -> Open [label=open];
Open -> Closed [label=close];
Open -> SASL [label=auth];
SASL -> SASL [label=step];
// Authentication fails
SASL -> Closed [label=fails];
// Authentication succeeds
SASL -> Authenticated [label=successful];
Open -> STARTTLS [label=starttls];
// TLS wrapping succeeds
STARTTLS -> Encrypted [label=successful];
// TLS wrapping fails
STARTTLS -> Closed [label=fails];
Authenticated -> SASL_TLS [label=starttls];
SASL_TLS -> Closed [label=fails];
SASL_TLS -> AuthEnc [label=successful];
Encrypted -> TLS_SASL [label=auth];
TLS_SASL -> TLS_SASL [label=step];
TLS_SASL -> Closed [label=fails];
TLS_SASL -> AuthEnc [label=successful];
// Only authenticated connections may open RPC. For "unauth", use the `Anonymous` SASL method.
AuthEnc -> RPC [label=bootstrap];
Authenticated -> RPC [label=bootstrap];
}

2
schema

@ -1 +1 @@
Subproject commit 16a4aba76abc2667cce80d2937ca923bce225817
Subproject commit 120ee4ea804a2da703a61f2a7e0d011a69140aa4

4
src/connection.rs Normal file
View File

@ -0,0 +1,4 @@
pub mod gen {
include!(concat!(env!("OUT_DIR"), "/schema/connection_capnp.rs"));
}

View File

@ -12,6 +12,7 @@ mod api;
mod config;
mod error;
mod machine;
mod connection;
use signal_hook::iterator::Signals;
@ -43,6 +44,7 @@ use error::Error;
// `crate::<file>_capnp` hierarchy.
use api::gen as api_capnp;
use auth::gen as auth_capnp;
use connection::gen as connection_capnp;
// Returning a `Result` from `main` allows us to use the `?` shorthand.
// In the case of an Err it will be printed using `fmt::Debug`