From 6ff40ec75ec736a7f1e1e98d48bf568435b581be Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Tue, 12 Jan 2021 05:40:33 -0800 Subject: [PATCH] Rename and Format --- examples/simple_client.rs | 16 ++++++++-------- examples/simple_server.rs | 24 ++++++++++-------------- src/applications/authentication_app.rs | 7 +++++-- src/connections/mod.rs | 13 ++++++------- 4 files changed, 29 insertions(+), 31 deletions(-) diff --git a/examples/simple_client.rs b/examples/simple_client.rs index 8cc86e4..a155527 100644 --- a/examples/simple_client.rs +++ b/examples/simple_client.rs @@ -1,12 +1,12 @@ -use tapir::acns::tor::authentication::HashedPassword; use ed25519_dalek::SecretKey; -use tapir::primitives::identity::Identity; -use tapir::connections::{OutboundConnection, Connection, ConnectionInterface}; -use tapir::primitives::transcript::Transcript; -use tapir::applications::authentication_app::{AuthenicationApp, AUTHENTICATION_CAPABILITY}; -use tapir::connections::service::Service; use rand::rngs::OsRng; -use tapir::acns::tor::TorProcess; +use tapir_cwtch::acns::tor::authentication::HashedPassword; +use tapir_cwtch::acns::tor::TorProcess; +use tapir_cwtch::applications::authentication_app::{AuthenicationApp, AUTHENTICATION_CAPABILITY}; +use tapir_cwtch::connections::service::Service; +use tapir_cwtch::connections::{Connection, ConnectionInterface, OutboundConnection}; +use tapir_cwtch::primitives::identity::Identity; +use tapir_cwtch::primitives::transcript::Transcript; fn main() { let mut auth_control_port = TorProcess::connect(9051) @@ -45,4 +45,4 @@ fn main() { } Err(err) => println!("{:?}", err), } -} \ No newline at end of file +} diff --git a/examples/simple_server.rs b/examples/simple_server.rs index de32021..67d9654 100644 --- a/examples/simple_server.rs +++ b/examples/simple_server.rs @@ -1,12 +1,12 @@ -use tapir::acns::tor::authentication::HashedPassword; use ed25519_dalek::SecretKey; -use tapir::primitives::identity::Identity; -use tapir::connections::{Connection, InboundConnection, ConnectionInterface}; -use tapir::primitives::transcript::Transcript; -use tapir::applications::authentication_app::AuthenicationApp; -use tapir::connections::service::Service; use rand::rngs::OsRng; -use tapir::acns::tor::TorProcess; +use tapir_cwtch::acns::tor::authentication::HashedPassword; +use tapir_cwtch::acns::tor::TorProcess; +use tapir_cwtch::applications::authentication_app::AuthenicationApp; +use tapir_cwtch::connections::service::Service; +use tapir_cwtch::connections::{Connection, ConnectionInterface, InboundConnection}; +use tapir_cwtch::primitives::identity::Identity; +use tapir_cwtch::primitives::transcript::Transcript; fn main() { let mut auth_control_port = TorProcess::connect(9051) @@ -29,12 +29,8 @@ fn main() { let mut transcript = Transcript::new_transcript("tapir-transcript"); let mut auth_app = AuthenicationApp::new(identity); match auth_app.run_inbound(conn, &mut transcript) { - Ok(conn) => { - println!("Authenticated Inbound Connection from {}", conn.hostname()) - } - _ => { - println!("Failed Inbound Authentication") - } + Ok(conn) => println!("Authenticated Inbound Connection from {}", conn.hostname()), + _ => println!("Failed Inbound Authentication"), } }; @@ -44,4 +40,4 @@ fn main() { } Err(err) => println!("{:?}", err), } -} \ No newline at end of file +} diff --git a/src/applications/authentication_app.rs b/src/applications/authentication_app.rs index 0447e11..3f4c0a9 100644 --- a/src/applications/authentication_app.rs +++ b/src/applications/authentication_app.rs @@ -1,6 +1,6 @@ use crate::applications::authentication_app::AuthenticationAppError::NotAuthenticatedError; use crate::connections::utils::public_key_to_hostname; -use crate::connections::{Connection, ConnectionInterface, InboundConnection, OutboundConnection, Capability}; +use crate::connections::{Capability, Connection, ConnectionInterface, InboundConnection, OutboundConnection}; use crate::primitives::identity::Identity; use crate::primitives::transcript::Transcript; use ed25519_dalek::PublicKey; @@ -36,7 +36,10 @@ struct AuthenticationSession { conn: Connection, } -impl AuthenticationSession where Direction:Clone { +impl AuthenticationSession +where + Direction: Clone, +{ pub fn new_outbound(conn: Connection, long_term_identity: Arc) -> AuthenticationSession { let ephemeral_identity = Identity::initialize_ephemeral_identity(); let mut auth_session = AuthenticationSession { diff --git a/src/connections/mod.rs b/src/connections/mod.rs index 77f499a..1dbdcbb 100644 --- a/src/connections/mod.rs +++ b/src/connections/mod.rs @@ -1,9 +1,9 @@ +use hashbrown::HashSet; use integer_encoding::{FixedInt, VarInt}; use secretbox::CipherType::Salsa20; use secretbox::SecretBox; use std::io::{Error, Read, Write}; use std::net::{Shutdown, TcpStream}; -use hashbrown::HashSet; /// Connections provides an interface for manage sets of connections on top of a particular /// ACN. @@ -25,13 +25,12 @@ pub struct OutboundConnection(()); #[derive(Clone, Eq, PartialEq, Hash)] pub struct Capability(pub &'static str); - pub struct Connection { conn: TcpStream, direction: Direction, key: Vec, hostname: String, - capabilities: HashSet + capabilities: HashSet, } pub trait ConnectionInterface { @@ -133,7 +132,7 @@ impl ConnectionInterface for Connection { } fn set_capability(&mut self, capability: &Capability) { - self.capabilities.insert(capability.clone()); + self.capabilities.insert(capability.clone()); } fn has_capability(&self, capability: &Capability) -> bool { @@ -151,7 +150,7 @@ where direction: InboundConnection(()), key: vec![], hostname: String::new(), - capabilities: HashSet::new() + capabilities: HashSet::new(), } } @@ -161,7 +160,7 @@ where direction: OutboundConnection(()), key: vec![], hostname: String::new(), - capabilities: HashSet::new() + capabilities: HashSet::new(), } } @@ -171,7 +170,7 @@ where direction: self.direction.clone(), key: self.key.clone(), hostname: self.hostname.clone(), - capabilities: self.capabilities.clone() + capabilities: self.capabilities.clone(), } } }