WIP: draft validation for flags (does not compile yet)
This commit is contained in:
@@ -30,7 +30,6 @@ async fn main() -> io::Result<()> {
|
||||
client_addr,
|
||||
stream,
|
||||
);
|
||||
|
||||
tokio::spawn(async move {
|
||||
if let Err(error) = connection.run().await {
|
||||
eprintln!(
|
||||
|
||||
+15
-8
@@ -90,17 +90,24 @@ impl Header {
|
||||
///
|
||||
// Валидация Header
|
||||
pub fn validate(&self) -> Result<(), HeaderValidationError> {
|
||||
if self.version != 1 {
|
||||
return Err(
|
||||
HeaderValidationError::UnsupportedVersion(self.version)
|
||||
//Валидация version
|
||||
if self.version != 1 {
|
||||
return Err(
|
||||
HeaderValidationError::UnsupportedVersion(self.version)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if self.command != 1 {
|
||||
return Err(
|
||||
HeaderValidationError::UnsupportedCommand(self.command)
|
||||
// Валидация command
|
||||
if self.command != 1 {
|
||||
return Err(
|
||||
HeaderValidationError::UnsupportedCommand(self.command)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Валидация flags
|
||||
if !(0..7).contains(&self.flags){
|
||||
return Err(HeaderValidationError::UnsupportedCommand(self.flags));
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user