Implement SMB Oplocks Phase 3+5

Phase 3: NotificationQueue
- Add notification_tx to Connection struct
- Modify writer.rs to use tokio::select! for response + notification
- Add write_to_bytes() to OplockBreakNotification
- Support server→client async messages

Phase 5: WRITE Handler oplock break
- Get path/share_access before write
- Trigger OplockManager.break_oplock()
- Send OPLOCK_BREAK_NOTIFICATION to affected clients
- Encode and send via notification channel

All 229 tests pass.
This commit is contained in:
Warren
2026-06-21 00:35:48 +08:00
parent be9fe72742
commit 2dd50e4cb6
5 changed files with 90 additions and 14 deletions
+8 -1
View File
@@ -8,7 +8,7 @@ use std::sync::{Arc, Mutex};
use crate::proto::auth::ntlm::{Identity, NtlmServer};
use crate::proto::crypto::{PreauthIntegrity, SigningAlgo};
use crate::proto::messages::{Dialect, FileId};
use tokio::sync::RwLock;
use tokio::sync::{mpsc, RwLock};
use uuid::Uuid;
use crate::backend::Handle;
@@ -16,6 +16,9 @@ use crate::builder::Access;
use crate::path::SmbPath;
use crate::server::ShareBindings;
/// Phase 3: Notification sender type for server→client async messages.
pub type NotificationSender = mpsc::Sender<Vec<u8>>;
/// In-flight NTLM acceptor + a `is_raw_ntlmssp` flag (true = raw, false =
/// SPNEGO-wrapped). The handler hands the second-round response back in the
/// same form the client opened with.
@@ -54,6 +57,9 @@ pub struct Connection {
/// Monotonic SessionId allocator.
next_session_id: AtomicU64,
/// Phase 3: Notification sender for server→client async messages (oplock breaks).
pub notification_tx: RwLock<Option<NotificationSender>>,
}
impl Connection {
@@ -70,6 +76,7 @@ impl Connection {
pending_auths: RwLock::new(HashMap::new()),
session_preauth: RwLock::new(HashMap::new()),
next_session_id: AtomicU64::new(1),
notification_tx: RwLock::new(None),
}
}