Commit 3f23c157 authored by Thomas Gatzweiler's avatar Thomas Gatzweiler
Browse files

Fix sequence counting bug

parent 4a0d5a42
......@@ -86,7 +86,7 @@ impl<'a> Connection {
trace!("Packet {} received: {:?}", self.seq.0, packet);
self.process(packet)?;
self.seq.0.wrapping_add(1);
self.seq.0 = self.seq.0.wrapping_add(1);
}
}
......@@ -107,7 +107,7 @@ impl<'a> Connection {
packet.write_to(&mut self.stream)?;
}
self.seq.1.wrapping_add(1);
self.seq.1 = self.seq.1.wrapping_add(1);
if let Some((_, ref mut mac)) = self.mac {
let mut sig = vec![0; mac.size()];
......
......@@ -21,27 +21,22 @@ impl Server {
}
pub fn run(&self) -> io::Result<()> {
let listener = TcpListener::bind(
(&*self.config.host, self.config.port),
).expect(&*format!(
"sshd: failed to bind to {}:{}",
self.config.as_ref().host,
self.config.as_ref().port
));
let listener =
TcpListener::bind((&*self.config.host, self.config.port))?;
loop {
let (mut stream, addr) = listener.accept().expect(&*format!(
"sshd: failed to establish incoming connection"
));
let (mut stream, addr) = listener.accept()?;
println!("Incoming connection from {}", addr);
debug!("Incoming connection from {}", addr);
let mut read_stream = stream.try_clone()?;
let mut connection = Connection::new(
ConnectionType::Server(self.config.clone()),
Box::new(stream.try_clone().unwrap()),
Box::new(stream),
);
let result = connection.run(&mut stream);
let result = connection.run(&mut read_stream);
if let Some(error) = result.err() {
println!("sshd: {}", error)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment