-
Notifications
You must be signed in to change notification settings - Fork 212
Add opt-in DFS client support with referral resolution #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ution - Add DFS referral structures (V1-V4) and response codecs - Implement DFS path resolver with caching support - Add DFS-aware client adapter and file store factory - Implement IOCTL request builder for DFS referrals - Add comprehensive unit and integration tests - Include client usage examples and documentation
- docs/codebase-patterns.md: Architecture and code style guide - docs/dfs-usage.md: DFS client configuration and troubleshooting - docs/lab-setup.md: General SMB/DFS lab setup options - docs/lab-setup-hyperv.md: Detailed Hyper-V Windows Server lab walkthrough - scripts/test-smb-client.ps1: Basic SMB2 client test - scripts/test-smb-client-full.ps1: Comprehensive read/write/echo test - scripts/test-smb1.ps1: SMB1 legacy protocol test - ClientExamples.md: Add reference to DFS usage guide
|
Should be fully backwards-compatible / not break existing code. I tested what I could in a local environment, but I no longer have access to an enterprise environment. Note that this code was written with the help of LLMs--if that's a concern, I can just keep this in a fork. I am willing to be the maintainer for the DFS logic. |
|
Hi Jacob, I see that in addition to the code (and unit-tests) you also contributed documentation and PowerShell tests scripts that need to be run manually. Thanks! |
|
Hey Tal, Happy to give a little back to the open source community. I agree to the contribution terms. I removed the scripts and trimmed down the documentation. When I get time I'll try to make a better lab setup and do some cross-platform testing. Thanks, |
|
Thanks Jacob,
|
|
Hey Tal,
I'm honestly open to whatever you prefer. I have no concerns with you modifying the code for style or anything like that and merging it piecemeal. Or if it's easier, I can maintain a separate wrapper package that consumes SMBLibrary as a dependency, and you can keep your focus on the core SMB implementation. |
PR: Add DFS Client Support
Summary
This PR adds opt-in Distributed File System (DFS) client support to SMBLibrary, enabling automatic resolution of DFS paths to their underlying file server targets. DFS remains disabled by default to maintain full backward compatibility.
Motivation
DFS is widely used in enterprise environments to provide:
Without DFS support, clients must manually resolve DFS paths before connecting.
Changes
Core DFS Client Implementation (
SMBLibrary/Client/DFS/)DfsClientFactoryDfsClientOptionsDfsPathResolverDfsAwareClientAdapterISMBFileStorewith transparent DFS resolutionDfsSessionManagerReferralCache/DomainCacheSmb2DfsReferralTransportFSCTL_DFS_GET_REFERRALSvia SMB2DFS Protocol Types (
SMBLibrary/DFS/)ResponseGetDfsReferral— Extended to fully parse referral responses (v1–v4)RequestGetDfsReferralEx— Support forFSCTL_DFS_GET_REFERRALS_EXwith site hintsDfsReferralEntryV1–V4— Referral entry structures per MS-DFSCDfsReferralHeaderFlags,DfsReferralEntryFlags,DfsServerType— EnumsTests (
SMBLibrary.Tests/)Documentation (
docs/)dfs-usage.mdcodebase-patterns.mdlab-setup.mdlab-setup-hyperv.mdTest Scripts (
scripts/)test-smb-client.ps1— Basic SMB2 client validationtest-smb-client-full.ps1— Comprehensive read/write/echo testtest-smb1.ps1— SMB1 legacy protocol testOther Changes
ClientExamples.md— Added DFS usage exampleSMB2FileStore.cs— Minor adjustment for DFS compatibilityUsage Example
Backward Compatibility
This PR has zero impact on existing code. DFS support is entirely opt-in:
DfsClientOptions.Enableddefaults tofalseSMB2Client,SMB1Client,ISMBFileStore, and all existing interfaces remain unchangedDfsClientFactory, all existing code paths are untouchedWhat happens if you don't use DFS?
Nothing changes. Existing code like this continues to work exactly as before:
DFS is only activated when you explicitly opt in:
Design Principles
DfsClientOptions.Enabled = falsepreserves existing behaviorTesting
References