mirror of
https://gitlab.redox-os.org/CoffeeCode/redox-ssh.git
synced 2025-12-28 19:02:19 +01:00
Implement connection threads
This commit is contained in:
parent
3f23c15783
commit
712e4fd208
2 changed files with 16 additions and 11 deletions
|
|
@ -7,7 +7,7 @@ mod ed25519;
|
||||||
|
|
||||||
pub use self::ed25519::ED25519;
|
pub use self::ed25519::ED25519;
|
||||||
|
|
||||||
pub trait KeyPair {
|
pub trait KeyPair: Sync + Send {
|
||||||
fn system(&self) -> &'static CryptoSystem;
|
fn system(&self) -> &'static CryptoSystem;
|
||||||
|
|
||||||
fn has_private(&self) -> bool;
|
fn has_private(&self) -> bool;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::net::TcpListener;
|
use std::net::TcpListener;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::thread;
|
||||||
|
|
||||||
use connection::{Connection, ConnectionType};
|
use connection::{Connection, ConnectionType};
|
||||||
use public_key::KeyPair;
|
use public_key::KeyPair;
|
||||||
|
|
@ -25,21 +26,25 @@ impl Server {
|
||||||
TcpListener::bind((&*self.config.host, self.config.port))?;
|
TcpListener::bind((&*self.config.host, self.config.port))?;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let (mut stream, addr) = listener.accept()?;
|
let (stream, addr) = listener.accept()?;
|
||||||
|
let config = self.config.clone();
|
||||||
|
|
||||||
debug!("Incoming connection from {}", addr);
|
debug!("Incoming connection from {}", addr);
|
||||||
|
|
||||||
let mut read_stream = stream.try_clone()?;
|
thread::spawn(move || {
|
||||||
|
let mut read_stream = stream.try_clone().unwrap();
|
||||||
|
|
||||||
let mut connection = Connection::new(
|
let mut connection = Connection::new(
|
||||||
ConnectionType::Server(self.config.clone()),
|
ConnectionType::Server(config),
|
||||||
Box::new(stream),
|
Box::new(stream),
|
||||||
);
|
);
|
||||||
|
|
||||||
let result = connection.run(&mut read_stream);
|
let result = connection.run(&mut read_stream);
|
||||||
|
|
||||||
if let Some(error) = result.err() {
|
if let Some(error) = result.err() {
|
||||||
println!("sshd: {}", error)
|
println!("sshd: {}", error)
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue