diff --git a/AMSMB2.podspec b/AMSMB2.podspec index c55564c..5a22b15 100644 --- a/AMSMB2.podspec +++ b/AMSMB2.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "AMSMB2" - s.version = "2.3.1" + s.version = "2.4.0" s.summary = "Swift framework to connect SMB2/3 shares" # This description is used to generate tags and improve search results. diff --git a/AMSMB2.xcodeproj/project.pbxproj b/AMSMB2.xcodeproj/project.pbxproj index d320434..5476f71 100644 --- a/AMSMB2.xcodeproj/project.pbxproj +++ b/AMSMB2.xcodeproj/project.pbxproj @@ -410,7 +410,7 @@ "@loader_path/../Frameworks", ); LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/libsmb2/lib"; - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 2.4.0; OTHER_LDFLAGS = ""; "OTHER_LDFLAGS[sdk=appletvos*]" = "-lsmb2-tvos"; "OTHER_LDFLAGS[sdk=appletvsimulator*]" = "-lsmb2-tvos"; @@ -446,7 +446,7 @@ "@loader_path/../Frameworks", ); LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/libsmb2/lib"; - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 2.4.0; "OTHER_LDFLAGS[sdk=appletvos*]" = "-lsmb2-tvos"; "OTHER_LDFLAGS[sdk=appletvsimulator*]" = "-lsmb2-tvos"; "OTHER_LDFLAGS[sdk=iphoneos*]" = "-lsmb2-ios"; diff --git a/AMSMB2/Context.swift b/AMSMB2/Context.swift index 2c04c62..a5ce85c 100644 --- a/AMSMB2/Context.swift +++ b/AMSMB2/Context.swift @@ -367,6 +367,7 @@ extension SMB2Context { } static let generic_handler: smb2_command_cb = { smb2, status, command_data, cbdata in + guard let smb2 = smb2, smb2.pointee.fd >= 0 else { return } guard let cbdata = cbdata?.bindMemory(to: CBData.self, capacity: 1).pointee else { return } if status != SMB2_STATUS_SUCCESS { cbdata.result = status diff --git a/AMSMB2Tests/AMSMB2Tests.swift b/AMSMB2Tests/AMSMB2Tests.swift index a128249..aaae3eb 100644 --- a/AMSMB2Tests/AMSMB2Tests.swift +++ b/AMSMB2Tests/AMSMB2Tests.swift @@ -16,6 +16,7 @@ class AMSMB2Tests: XCTestCase { // Put setup code here. This method is called before the invocation of each test method in the class. setenv("SMBServer", "smb://192.168.1.5/", 0) setenv("SMBShare", "Files", 0) + setenv("SMBEncrypted", "0", 0) } override func tearDown() { @@ -89,6 +90,9 @@ class AMSMB2Tests: XCTestCase { return nil } }() + lazy var encrypted: Bool = { + return ProcessInfo.processInfo.environment["SMBEncrypted"] == "1" + }() func testShareEnum() { let expectation = self.expectation(description: #function) @@ -138,7 +142,7 @@ class AMSMB2Tests: XCTestCase { let expectation = self.expectation(description: #function) let smb = AMSMB2(url: server, credential: credential)! - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.attributesOfFileSystem(forPath: "/") { result in @@ -162,7 +166,7 @@ class AMSMB2Tests: XCTestCase { let expectation = self.expectation(description: #function) let smb = AMSMB2(url: server, credential: credential)! - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.contentsOfDirectory(atPath: "/") { result in @@ -189,7 +193,7 @@ class AMSMB2Tests: XCTestCase { let expectation = self.expectation(description: #function) let smb = AMSMB2(url: server, credential: credential)! - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.contentsOfDirectory(atPath: "/") { result in @@ -224,7 +228,7 @@ class AMSMB2Tests: XCTestCase { let smb = AMSMB2(url: server, credential: credential)! smb.timeout = 20 - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.createDirectory(atPath: "testEmpty") { (error) in @@ -292,7 +296,7 @@ class AMSMB2Tests: XCTestCase { smb.removeFile(atPath: "writetest.dat", completionHandler: nil) } - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.write(data: data, toPath: "writetest.dat", progress: { (progress) -> Bool in @@ -361,7 +365,7 @@ class AMSMB2Tests: XCTestCase { smb.removeFile(atPath: file, completionHandler: nil) } - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.write(data: data, toPath: file, progress: nil) { (error) in @@ -400,7 +404,7 @@ class AMSMB2Tests: XCTestCase { smb.removeFile(atPath: "uploadtest.dat", completionHandler: nil) } - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.uploadItem(at: url, toPath: "uploadtest.dat", progress: { (progress) -> Bool in @@ -449,7 +453,7 @@ class AMSMB2Tests: XCTestCase { smb.removeFile(atPath: file, completionHandler: nil) } - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.write(stream: inputStream, toPath: file, progress: { (progress) -> Bool in @@ -492,7 +496,7 @@ class AMSMB2Tests: XCTestCase { smb.removeFile(atPath: file, completionHandler: nil) } - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.uploadItem(at: url, toPath: file, progress: nil) { (error) in @@ -537,7 +541,7 @@ class AMSMB2Tests: XCTestCase { smb.removeFile(atPath: "copyTestDest.dat", completionHandler: nil) } - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.write(data: data, toPath: "copyTest.dat", progress: nil) { (error) in @@ -575,7 +579,7 @@ class AMSMB2Tests: XCTestCase { smb.removeFile(atPath: "moveTest", completionHandler: nil) smb.removeFile(atPath: "moveTestDest", completionHandler: nil) } - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.createDirectory(atPath: "moveTest") { (error) in @@ -603,7 +607,7 @@ class AMSMB2Tests: XCTestCase { smb.removeDirectory(atPath: rootCopy, recursive: true, completionHandler: nil) } - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.createDirectory(atPath: root) { (error) in @@ -642,7 +646,7 @@ class AMSMB2Tests: XCTestCase { let smb = AMSMB2(url: server, credential: credential)! - smb.connectShare(name: share) { (error) in + smb.connectShare(name: share, encrypted: encrypted) { (error) in XCTAssertNil(error) smb.removeDirectory(atPath: "removeTest", recursive: true, completionHandler: nil)