← User Guide · Back to README · Contributing →
Far-NetBox uses a layered plugin architecture specific to Far Manager integration. Code flows from the Plugin Layer through Core Protocols to Base Foundation classes, with third-party libraries providing protocol implementations.
src/
├── NetBox/ # Plugin Layer — Far Manager API entry point
│ ├── plugin.cpp # PluginMain, GetPluginInfo, OpenPlugin
│ ├── plugin.hpp
│ └── menu.hpp # Menu definitions
├── core/ # Core Layer — Protocol implementations
│ ├── SecureShell.h # SFTP/SCP via PuTTY
│ ├── FTP.h # FTP via FileZilla
│ ├── WebDAV.h # WebDAV via neon
│ ├── S3.h # S3 via libs3
│ └── CustomFileSystem.h # Abstract base for protocols
├── filezilla/ # FileZilla engine (FTP/FTPS)
├── base/ # Base Layer — Foundation classes
│ ├── UnicodeString.h
│ ├── Classes.h
│ └── Exceptions.h
├── nbcore/ # Core utilities (strings, memory, logging)
├── include/ # Public headers (nbtypes.h, rtti.hpp)
├── PluginSDK/ # Far3 plugin SDK headers
├── resource/ # Resources (.rc, .lng, licenses)
└── windows/ # Windows-specific code (GUI, dialogs)
Plugin Layer (NetBox/)
↓
Core Layer (core/)
↓
Base Layer (base/, nbcore/)
↓
Third-Party (libs/)
| Direction | Allowed | Rule |
|---|---|---|
| Plugin → Core | Yes | Plugin calls protocol implementations |
| Core → Base | Yes | Protocols use foundation classes |
| Core → Third-Party | Yes | Protocols wrap library implementations |
| Plugin → Third-Party | No | Must go through Core |
| Base → Core | No | Foundation must be independent |
void WINAPI GetPluginInfoW(PluginInfo *Info);
HANDLE WINAPI OpenPluginW(const OpenInfo *Info);
void WINAPI ClosePluginW(HANDLE Handle, int ExitCode);Far Manager loads NetBox.dll and calls these entry points. The plugin registers menu items, handles panel events, and manages session lifecycle.
All protocol implementations inherit from TCustomFileSystem:
class TCustomFileSystem
{
public:
virtual bool Connect() = 0;
virtual void Disconnect() = 0;
virtual void FindFirst(const UnicodeString & Path, TFindFileList & List) = 0;
virtual bool GetFile(const UnicodeString & FileName,
const UnicodeString & LocalFile, ...) = 0;
virtual bool PutFile(const UnicodeString & LocalFile,
const UnicodeString & FileName, ...) = 0;
virtual bool DeleteFile(const UnicodeString & FileName) = 0;
virtual bool MakeDirectory(const UnicodeString & DirName) = 0;
};The protocol factory creates the correct implementation at runtime:
TCustomFileSystem *CreateFileSystem(TSessionData * Data)
{
switch (Data->FSProtocol)
{
case fsSFTP: return new TSecureShell(Data);
case fsFTP: return new TFTPFileSystem(Data);
case fsWebDAV: return new TWebDAVFileSystem(Data);
case fsS3: return new TS3FileSystem(Data);
default: DebugAlwaysAssert(false); return nullptr;
}
}- RAII — Smart pointers and destructor cleanup
- No raw new/delete — Wrap allocations in helpers
- String management — Use
UnicodeStringclass - Handle cleanup — Close handles in destructors or RAII wrappers
- Exceptions — Throw from
Exceptionhierarchy (EAbort,EInOutError) - Try/catch in UI — Top-level handlers catch and display errors
- Network errors — Wrap with meaningful messages including URL/path
- Debug output — Use
FTerminal->LogEvent()for tracing
- Plugin first, core second — Far Manager API requirements must be satisfied
- Protocol abstraction — All protocols implement
TCustomFileSystem - Clean dependency flow — Plugin → Core → Base → Third-Party
- No third-party modifications — Use patches instead of direct changes
- WinXP compatibility — Avoid modern Windows APIs
- Build verification — Compile with MSVC W4 (zero warnings)
- Thread safety — Far Manager API calls from main thread only; worker threads use event-driven waits
| Artifact | Location |
|---|---|
| Plugin DLL | Far3_<platform>/Plugins/NetBox/ |
| Platform dirs | Far3_x86/, Far3_x64/, Far3_ARM64/ |
| Build dir | build-<config>/ |
NetBox optionally protects stored session passwords with a master password using AES-256-CBC encryption plus HMAC-SHA256 integrity verification. See Security Documentation for the full data flow, secure memory handling (TSecureString), thread-safe session counters, rate limiting, and recryption behavior.
Key components:
| Component | Location | Purpose |
|---|---|---|
TSecureString |
src/base/SecureString.cpp |
Secure memory buffer with VirtualLock + SecureZeroMemory |
| Master password state | src/windows/WinConfiguration.cpp |
Verifier, session counter, rate limiting |
| AES-256 crypto | src/core/Cryptography.cpp |
Encrypt/decrypt + verifier generation |
- Contributing — Code conventions and development workflow
- OpenSSL Sync Report — OpenSSL 3 synchronization details
- User Guide — Protocol descriptions and features