Skip to content

Commit

Permalink
Implement a basic nfs server
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus23 committed Jan 3, 2024
1 parent 126f147 commit 79e6f01
Show file tree
Hide file tree
Showing 5 changed files with 453 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ iroh-base = "0.12.0"
tokio-util = { version = "0.7.10", features = ["codec"] }
async-recursion = "1.0.5"
quick_cache = "0.4.0"
nfsserve = { git = "https://github.com/xetdata/nfsserve", revision = "46322e7823ccb3f0a2e549dfa91fbf7dada9c42a" }
quinn = "0.10.2"

# enable the "rug" feature (using GMP) for rs-wnfs, speeding up nameaccumulator operations
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod commands;
pub mod nfs;
pub mod state;
pub mod store;
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ use std::path::{Component, Path};
use anyhow::{Context as _, Result};
use appa::commands::doctor::doctor;
use appa::commands::listen_sync::{listen, sync};
use appa::nfs::AppaNfs;
use appa::state::Appa;
use futures::TryStreamExt;
use nfsserve::tcp::{NFSTcp, NFSTcpListener};
use tokio::io::AsyncWriteExt;

use clap::{Parser, Subcommand};
Expand Down Expand Up @@ -82,6 +84,8 @@ enum Commands {
#[arg(value_name = "ITEM")]
item: String,
},
/// Run an NFS server for the appa filesystem locally
Nfsserve,
}

#[tokio::main]
Expand Down Expand Up @@ -170,6 +174,16 @@ async fn main() -> Result<()> {
Commands::Sync { ticket } => {
sync(ticket).await?;
}
Commands::Nfsserve => {
const HOSTPORT: u32 = 11111;
let appa = Appa::load().await?;
let listener =
NFSTcpListener::bind(&format!("127.0.0.1:{HOSTPORT}"), AppaNfs::new(appa))
.await
.unwrap();
tracing::info!("Staring serve");
listener.handle_forever().await?;
}
}

Ok(())
Expand Down
Loading

0 comments on commit 79e6f01

Please sign in to comment.