pkg/zfs/dataset/data_transfer.go
- Configuration Types
SendConfig
- Controls ZFS send operationReceiveConfig
- Controls ZFS receive operationRemoteConfig
- SSH connection parameters
- Key Functions
SendReceive()
- Main data transfer handlerGetResumeToken()
- Resume token managementbuildSSHCommand()
- SSH command constructionparseSSHOptions()
- SSH option validation
-
Command Injection Prevention
- Input validation using regex patterns
- Shell metacharacter filtering
- Path traversal prevention
- Command argument sanitization
-
SSH Security
- Whitelisted SSH options
- Private key path validation
- Host/user validation
- Connection hardening options
-
Resource Protection
- Command timeouts
- Process cleanup
- Error propagation
- Resource limits
-
Error Handling
- Detailed error context
- Command output capture
- Exit code handling
- Retry mechanism
-
Data Transfer
- Stream integrity
- Property preservation
- Resume capability
- Progress monitoring
-
Command Construction
- Proper flag ordering
- Mutually exclusive options
- Safe pipe handling
- Sudo management
-
Architecture
- Single piped command
- Direct streaming
- No temporary files
- Native ZFS features
-
Configuration
- Strong typing
- Required validations
- Clear option mapping
- Flexible properties
-
Integration
- Context support
- Logger integration
- Error wrapping
- Resource tracking
pkg/zfs/dataset/data_transfer_test.go
-
Test Categories
- Basic transfers
- Incremental transfers
- Resume operations
- Remote replication
-
Test Infrastructure
- Loop devices
- Pool management
- Dataset creation
- Cleanup handling
-
Known Issues
- Limited progress parsing
- Basic SSH options
- Simple retry logic
- Limited bandwidth control
-
Missing Features
- Compression control
- Bandwidth limiting
- Advanced resume
- Progress callbacks
-
Features
- Enhanced progress monitoring
- Better compression control
- Bandwidth management
- Advanced SSH options
-
Performance
- Stream optimization
- Resource pooling
- Connection reuse
- Parallel transfers
-
Security
- Certificate validation
- Enhanced key management
- Rate limiting
- Access control
This implementation forms the foundation for remote replication in the StrataSTOR NAS system, striving to provide enterprise-level functionality while maintaining security and reliability.