2021-01-13 12:14:38 +00:00
|
|
|
use std::sync::Arc;
|
2021-01-12 13:40:33 +00:00
|
|
|
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;
|
2021-01-12 09:52:27 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut auth_control_port = TorProcess::connect(9051)
|
|
|
|
.unwrap()
|
|
|
|
.authenticate(Box::new(HashedPassword::new(String::from("examplehashedpassword"))))
|
|
|
|
.unwrap();
|
2021-01-13 06:00:00 +00:00
|
|
|
let identity = Arc::new(Identity::initialize_ephemeral_identity());
|
|
|
|
match identity.host_onion_service(&mut auth_control_port, 9878, 10029) {
|
2021-01-12 09:52:27 +00:00
|
|
|
Ok(service_id) => {
|
|
|
|
// we authenticated!
|
2021-01-13 06:00:00 +00:00
|
|
|
|
2021-01-12 09:52:27 +00:00
|
|
|
println!("Service Id: {}", service_id);
|
|
|
|
println!("Setup: {}", identity.hostname());
|
|
|
|
|
|
|
|
let service = Service::init(identity.clone());
|
|
|
|
|
2021-01-12 12:19:49 +00:00
|
|
|
let inbound_service = |conn: Connection<InboundConnection>| {
|
2021-01-12 09:52:27 +00:00
|
|
|
let mut transcript = Transcript::new_transcript("tapir-transcript");
|
|
|
|
let mut auth_app = AuthenicationApp::new(identity);
|
|
|
|
match auth_app.run_inbound(conn, &mut transcript) {
|
2021-01-12 13:40:33 +00:00
|
|
|
Ok(conn) => println!("Authenticated Inbound Connection from {}", conn.hostname()),
|
|
|
|
_ => println!("Failed Inbound Authentication"),
|
2021-01-12 09:52:27 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-12 12:19:49 +00:00
|
|
|
let mut _service = service.listen(10029, inbound_service.clone()).unwrap_or_else(|_| panic!());
|
2021-01-12 09:52:27 +00:00
|
|
|
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
Err(err) => println!("{:?}", err),
|
|
|
|
}
|
2021-01-12 13:40:33 +00:00
|
|
|
}
|