|
@@ -21,7 +21,6 @@ extern crate static_assertions;
|
|
|
extern crate lazy_static;
|
|
|
|
|
|
use ::log::error;
|
|
|
-use brotli::{CompressorWriter, Decompressor};
|
|
|
use btserde::{read_from, write_to};
|
|
|
use fuse_backend_rs::abi::fuse_abi::{stat64, Attr};
|
|
|
use positioned_io::{ReadAt, Size, WriteAt};
|
|
@@ -33,7 +32,7 @@ use std::{
|
|
|
fmt::{self, Display, Formatter},
|
|
|
hash::Hash as Hashable,
|
|
|
io::{self, Read, Seek, SeekFrom, Write},
|
|
|
- net::SocketAddr,
|
|
|
+ net::IpAddr,
|
|
|
ops::{Add, Sub},
|
|
|
os::unix::prelude::MetadataExt,
|
|
|
time::{Duration, SystemTime},
|
|
@@ -953,7 +952,6 @@ pub struct BlockOpenOptions<T, C> {
|
|
|
inner: T,
|
|
|
creds: C,
|
|
|
encrypt: bool,
|
|
|
- compress: bool,
|
|
|
block_path: Option<BlockPath>,
|
|
|
}
|
|
|
|
|
@@ -963,7 +961,6 @@ impl BlockOpenOptions<(), ()> {
|
|
|
inner: (),
|
|
|
creds: (),
|
|
|
encrypt: true,
|
|
|
- compress: true,
|
|
|
block_path: Default::default(),
|
|
|
}
|
|
|
}
|
|
@@ -975,7 +972,6 @@ impl<T, C> BlockOpenOptions<T, C> {
|
|
|
inner,
|
|
|
creds: self.creds,
|
|
|
encrypt: self.encrypt,
|
|
|
- compress: self.compress,
|
|
|
block_path: self.block_path,
|
|
|
}
|
|
|
}
|
|
@@ -985,7 +981,6 @@ impl<T, C> BlockOpenOptions<T, C> {
|
|
|
inner: self.inner,
|
|
|
creds,
|
|
|
encrypt: self.encrypt,
|
|
|
- compress: self.compress,
|
|
|
block_path: self.block_path,
|
|
|
}
|
|
|
}
|
|
@@ -995,11 +990,6 @@ impl<T, C> BlockOpenOptions<T, C> {
|
|
|
self
|
|
|
}
|
|
|
|
|
|
- pub fn with_compress(mut self, compress: bool) -> Self {
|
|
|
- self.compress = compress;
|
|
|
- self
|
|
|
- }
|
|
|
-
|
|
|
pub fn with_block_path(mut self, block_path: BlockPath) -> Self {
|
|
|
self.block_path = Some(block_path);
|
|
|
self
|
|
@@ -1031,54 +1021,6 @@ impl Default for BlockOpenOptions<(), ()> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-impl<T: Write> Decompose<T> for CompressorWriter<T> {
|
|
|
- fn into_inner(self) -> T {
|
|
|
- self.into_inner()
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl<T: Read> Decompose<T> for Decompressor<T> {
|
|
|
- fn into_inner(self) -> T {
|
|
|
- self.into_inner()
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#[derive(Clone)]
|
|
|
-pub struct BrotliParams {
|
|
|
- buf_sz: usize,
|
|
|
- quality: u32,
|
|
|
- window_sz: u32,
|
|
|
-}
|
|
|
-
|
|
|
-impl BrotliParams {
|
|
|
- pub fn new(buf_sz: usize, quality: u32, window_sz: u32) -> BrotliParams {
|
|
|
- BrotliParams {
|
|
|
- buf_sz,
|
|
|
- quality,
|
|
|
- window_sz,
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl<T: Write> TryCompose<T, CompressorWriter<T>> for BrotliParams {
|
|
|
- type Error = crate::Error;
|
|
|
- fn try_compose(self, inner: T) -> Result<CompressorWriter<T>> {
|
|
|
- Ok(CompressorWriter::new(
|
|
|
- inner,
|
|
|
- self.buf_sz,
|
|
|
- self.quality,
|
|
|
- self.window_sz,
|
|
|
- ))
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl<T: Read> TryCompose<T, Decompressor<T>> for BrotliParams {
|
|
|
- type Error = crate::Error;
|
|
|
- fn try_compose(self, inner: T) -> Result<Decompressor<T>> {
|
|
|
- Ok(Decompressor::new(inner, self.buf_sz))
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
/// An envelopment of a key, which is tagged with the principal who the key is meant for.
|
|
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
|
|
|
pub struct Readcap {
|
|
@@ -1190,7 +1132,7 @@ impl Fragment {
|
|
|
/// Structure for keeping track of server information in a directory.
|
|
|
pub struct ServerRecord {
|
|
|
/// The most up-to-date address for this server.
|
|
|
- pub addr: SocketAddr,
|
|
|
+ pub addr: IpAddr,
|
|
|
/// The public credentials for this server.
|
|
|
pub pub_creds: ConcretePub,
|
|
|
}
|
|
@@ -1208,7 +1150,7 @@ pub struct AuthzAttrs {
|
|
|
|
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
|
pub struct IssuedProcRec {
|
|
|
- pub addr: SocketAddr,
|
|
|
+ pub addr: IpAddr,
|
|
|
pub pub_creds: ConcretePub,
|
|
|
pub writecap: Writecap,
|
|
|
pub authz_attrs: AuthzAttrs,
|
|
@@ -1218,7 +1160,7 @@ pub struct IssuedProcRec {
|
|
|
/// Structure stored in process blocks for keeping track of process credentials and location.
|
|
|
pub enum ProcRec {
|
|
|
Requested {
|
|
|
- addr: SocketAddr,
|
|
|
+ addr: IpAddr,
|
|
|
pub_creds: ConcretePub,
|
|
|
},
|
|
|
Valid(IssuedProcRec),
|
|
@@ -1496,45 +1438,17 @@ impl<F: FnOnce()> Drop for DropTrigger<F> {
|
|
|
#[cfg(test)]
|
|
|
mod tests {
|
|
|
use btserde::{from_vec, to_vec};
|
|
|
- use std::{
|
|
|
- fs::OpenOptions,
|
|
|
- io::{Cursor, Write},
|
|
|
- path::PathBuf,
|
|
|
- };
|
|
|
+ use std::{fs::OpenOptions, io::Write, path::PathBuf};
|
|
|
use tempdir::TempDir;
|
|
|
|
|
|
use super::*;
|
|
|
use crate::{
|
|
|
crypto::{ConcreteCreds, CredsPriv},
|
|
|
sectored_buf::SectoredBuf,
|
|
|
- test_helpers::{
|
|
|
- node_creds, read_check, root_creds, write_fill, SectoredCursor, SECTOR_SZ_DEFAULT,
|
|
|
- },
|
|
|
+ test_helpers::{node_creds, root_creds, SectoredCursor, SECTOR_SZ_DEFAULT},
|
|
|
Cursor as PioCursor,
|
|
|
};
|
|
|
|
|
|
- #[test]
|
|
|
- fn brotli_compress_decompress() {
|
|
|
- const SECT_SZ: usize = SECTOR_SZ_DEFAULT;
|
|
|
- const SECT_CT: usize = 16;
|
|
|
- let params = BrotliParams::new(SECT_SZ, 8, 20);
|
|
|
- let mut memory = Cursor::new([0u8; SECT_SZ * SECT_CT]);
|
|
|
- {
|
|
|
- let write: CompressorWriter<_> = params
|
|
|
- .clone()
|
|
|
- .try_compose(&mut memory)
|
|
|
- .expect("compose for write failed");
|
|
|
- write_fill(write, SECT_SZ, SECT_CT);
|
|
|
- }
|
|
|
- memory.seek(SeekFrom::Start(0)).expect("seek failed");
|
|
|
- {
|
|
|
- let read: Decompressor<_> = params
|
|
|
- .try_compose(&mut memory)
|
|
|
- .expect("compose for read failed");
|
|
|
- read_check(read, SECT_SZ, SECT_CT);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/// Tests that the `BlockMetaBody` struct has an updated secrets struct after it is modified
|
|
|
/// in the `access_secrets` method.
|
|
|
#[test]
|