aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-07-22 13:06:10 +0200
committerAlex Auvolat <alex@adnab.me>2022-07-22 13:06:10 +0200
commit5da59ebec5f3072d0b6c3b1ffc90eb8923c50ad9 (patch)
treecd5c08198db5a0b8499dfb80222d82e8d0518ab2
parent9cb28c21b4a80aa9f29097f6bb1b8b6c23446ddc (diff)
downloadnetapp-5da59ebec5f3072d0b6c3b1ffc90eb8923c50ad9.tar.gz
netapp-5da59ebec5f3072d0b6c3b1ffc90eb8923c50ad9.zip
Move things around and fix error bit
-rw-r--r--src/endpoint.rs1
-rw-r--r--src/lib.rs1
-rw-r--r--src/netapp.rs8
-rw-r--r--src/recv.rs2
-rw-r--r--src/util.rs7
5 files changed, 9 insertions, 10 deletions
diff --git a/src/endpoint.rs b/src/endpoint.rs
index d8dc6c4..7088879 100644
--- a/src/endpoint.rs
+++ b/src/endpoint.rs
@@ -7,7 +7,6 @@ use async_trait::async_trait;
use crate::error::Error;
use crate::message::*;
use crate::netapp::*;
-use crate::util::*;
/// This trait should be implemented by an object of your application
/// that can handle a message of type `M`, if it wishes to handle
diff --git a/src/lib.rs b/src/lib.rs
index ce94682..bd41048 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -29,7 +29,6 @@ pub mod netapp;
pub mod peering;
pub use crate::netapp::*;
-pub use util::{NetworkKey, NodeID, NodeKey};
#[cfg(test)]
mod test;
diff --git a/src/netapp.rs b/src/netapp.rs
index 166f560..29df3b9 100644
--- a/src/netapp.rs
+++ b/src/netapp.rs
@@ -22,7 +22,13 @@ use crate::endpoint::*;
use crate::error::*;
use crate::message::*;
use crate::server::*;
-use crate::util::*;
+
+/// A node's identifier, which is also its public cryptographic key
+pub type NodeID = sodiumoxide::crypto::sign::ed25519::PublicKey;
+/// A node's secret key
+pub type NodeKey = sodiumoxide::crypto::sign::ed25519::SecretKey;
+/// A network key
+pub type NetworkKey = sodiumoxide::crypto::auth::Key;
/// Tag which is exchanged between client and server upon connection establishment
/// to check that they are running compatible versions of Netapp,
diff --git a/src/recv.rs b/src/recv.rs
index b2f5530..2be8728 100644
--- a/src/recv.rs
+++ b/src/recv.rs
@@ -75,7 +75,7 @@ pub(crate) trait RecvLoop: Sync + 'static {
let has_cont = (size & CHUNK_HAS_CONTINUATION) != 0;
let is_error = (size & ERROR_MARKER) != 0;
let packet = if is_error {
- Err(size as u8)
+ Err((size & !ERROR_MARKER) as u8)
} else {
let size = size & !CHUNK_HAS_CONTINUATION;
let mut next_slice = vec![0; size as usize];
diff --git a/src/util.rs b/src/util.rs
index 13cccb9..425d26f 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -6,12 +6,7 @@ use serde::Serialize;
use tokio::sync::watch;
-/// A node's identifier, which is also its public cryptographic key
-pub type NodeID = sodiumoxide::crypto::sign::ed25519::PublicKey;
-/// A node's secret key
-pub type NodeKey = sodiumoxide::crypto::sign::ed25519::SecretKey;
-/// A network key
-pub type NetworkKey = sodiumoxide::crypto::auth::Key;
+use crate::netapp::*;
/// Utility function: encodes any serializable value in MessagePack binary format
/// using the RMP library.