Expand description
§gosh-lan-transfer
A Rust library for peer-to-peer file transfers over LAN, VPN, or Tailscale networks.
This crate provides the core transfer engine without any GUI dependencies, making it suitable for use in CLI tools, desktop applications, or as a library.
§Features
- Send and receive files between peers
- Automatic peer discovery via hostname resolution
- Trust-based auto-acceptance for known hosts
- Progress tracking via events
- No cloud dependencies - all transfers are direct peer-to-peer
§Example
ⓘ
use gosh_lan_transfer::{GoshTransferEngine, EngineConfig, callback_handler, EngineEvent};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create configuration
let config = EngineConfig::builder()
.device_name("My Device")
.download_dir("/tmp/downloads")
.build();
// Create event handler
let handler = callback_handler(|event| {
if let EngineEvent::TransferProgress(p) = event {
let percent = (p.bytes_transferred * 100) / p.total_bytes;
println!("Progress: {}%", percent);
}
});
// Create engine
let mut engine = GoshTransferEngine::new(config, handler);
// Start server to receive files
let handle = engine.start_server().await?;
// Send files to a peer
engine.send_files("192.168.1.100", 53317, vec!["/path/to/file.txt".into()]).await?;
Ok(())
}Re-exports§
pub use protocol::EngineEvent;pub use protocol::PeerInfo;pub use protocol::PendingTransfer;pub use protocol::TransferApprovalStatus;pub use protocol::TransferDecision;pub use protocol::TransferDirection;pub use protocol::TransferFile;pub use protocol::TransferProgress;pub use protocol::TransferRequest;pub use protocol::TransferResponse;pub use protocol::TransferStatus;pub use events::callback_handler;pub use events::channel_handler;pub use events::noop_handler;pub use events::CallbackEventHandler;pub use events::ChannelEventHandler;pub use events::EventHandler;pub use events::NoopEventHandler;pub use client::get_network_interfaces;pub use client::TransferClient;pub use config::EngineConfig;pub use config::EngineConfigBuilder;pub use error::EngineError;pub use error::EngineResult;pub use favorites::FavoritesPersistence;pub use favorites::InMemoryFavorites;pub use history::HistoryPersistence;pub use history::InMemoryHistory;pub use server::ServerHandle;pub use server::ServerState;pub use types::Favorite;pub use types::NetworkInterface;pub use types::ResolveResult;pub use types::TransferRecord;
Modules§
- client
- config
- error
- events
- Event handling infrastructure for gosh-lan-transfer
- favorites
- history
- protocol
- Protocol types for gosh-lan-transfer
- server
- types
- Domain types for gosh-lan-transfer
Structs§
- Gosh
Transfer Engine - The main engine that coordinates all file transfer operations