mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 07:08:05 -05:00
p2pnet: app_version check to verify version format
This commit is contained in:
@@ -101,15 +101,21 @@ impl ProtocolVersion {
|
||||
// Version format: MAJOR.MINOR.PATCH
|
||||
let app_versions: Vec<&str> = app_version.split('.').collect();
|
||||
let verack_msg_versions: Vec<&str> = verack_msg.app.split('.').collect();
|
||||
// Check for malformed versions
|
||||
if app_versions.len() != 3 || verack_msg_versions.len() != 3 {
|
||||
error!("ProtocolVersion::send_version() [Malformed version detected. Disconnecting from channel.]");
|
||||
self.hosts.remove(&self.channel.address()).await;
|
||||
self.channel.stop().await;
|
||||
return Err(Error::ChannelStopped)
|
||||
}
|
||||
// Ignore PATCH version
|
||||
if app_versions[0] != verack_msg_versions[0] ||
|
||||
app_versions[1] != verack_msg_versions[1]
|
||||
{
|
||||
error!(
|
||||
"Wrong app version from [{}]. Disconnecting from channel.",
|
||||
"ProtocolVersion::send_version() [Wrong app version from ({}). Disconnecting from channel.]",
|
||||
self.channel.address()
|
||||
);
|
||||
|
||||
self.hosts.remove(&self.channel.address()).await;
|
||||
self.channel.stop().await;
|
||||
return Err(Error::ChannelStopped)
|
||||
|
||||
Reference in New Issue
Block a user