mirror of
https://github.com/Noratrieb/cluelessh.git
synced 2026-01-16 01:15:04 +01:00
factor out auth
This commit is contained in:
parent
b0acf03502
commit
1c346659f6
7 changed files with 267 additions and 156 deletions
|
|
@ -44,8 +44,12 @@ enum ServerState {
|
|||
encryption_client_to_server: EncryptionAlgorithm,
|
||||
encryption_server_to_client: EncryptionAlgorithm,
|
||||
},
|
||||
ServiceRequest,
|
||||
Open,
|
||||
ServiceRequest {
|
||||
session_ident: [u8; 32],
|
||||
},
|
||||
Open {
|
||||
session_ident: [u8; 32],
|
||||
},
|
||||
}
|
||||
|
||||
impl ServerConnection {
|
||||
|
|
@ -289,9 +293,9 @@ impl ServerConnection {
|
|||
*encryption_server_to_client,
|
||||
true,
|
||||
);
|
||||
self.state = ServerState::ServiceRequest {};
|
||||
self.state = ServerState::ServiceRequest { session_ident: *h };
|
||||
}
|
||||
ServerState::ServiceRequest => {
|
||||
ServerState::ServiceRequest { session_ident } => {
|
||||
// TODO: this should probably move out of here? unsure.
|
||||
if packet.payload.first() != Some(&numbers::SSH_MSG_SERVICE_REQUEST) {
|
||||
return Err(peer_error!("did not send SSH_MSG_SERVICE_REQUEST"));
|
||||
|
|
@ -312,9 +316,11 @@ impl ServerConnection {
|
|||
writer.finish()
|
||||
},
|
||||
});
|
||||
self.state = ServerState::Open;
|
||||
self.state = ServerState::Open {
|
||||
session_ident: *session_ident,
|
||||
};
|
||||
}
|
||||
ServerState::Open => {
|
||||
ServerState::Open { .. } => {
|
||||
self.plaintext_packets.push_back(packet);
|
||||
}
|
||||
}
|
||||
|
|
@ -322,6 +328,13 @@ impl ServerConnection {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn is_open(&self) -> Option<[u8; 32]> {
|
||||
match self.state {
|
||||
ServerState::Open { session_ident } => Some(session_ident),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next_msg_to_send(&mut self) -> Option<Msg> {
|
||||
self.packet_transport.next_msg_to_send()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue