43 lines
1.0 KiB
Swift
43 lines
1.0 KiB
Swift
|
|
import Foundation
|
||
|
|
|
||
|
|
enum NASProtocol: String, Codable, CaseIterable {
|
||
|
|
case smb = "SMB"
|
||
|
|
case sftp = "SFTP"
|
||
|
|
|
||
|
|
var defaultPort: Int {
|
||
|
|
switch self {
|
||
|
|
case .smb: return 445
|
||
|
|
case .sftp: return 22
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
struct NASConnection: Codable, Identifiable, Equatable {
|
||
|
|
var id: UUID = UUID()
|
||
|
|
var host: String
|
||
|
|
var port: Int
|
||
|
|
var nasProtocol: NASProtocol
|
||
|
|
var username: String
|
||
|
|
var password: String
|
||
|
|
var remotePath: String
|
||
|
|
var displayName: String
|
||
|
|
|
||
|
|
init(
|
||
|
|
host: String,
|
||
|
|
port: Int? = nil,
|
||
|
|
nasProtocol: NASProtocol = .smb,
|
||
|
|
username: String,
|
||
|
|
password: String,
|
||
|
|
remotePath: String = "/",
|
||
|
|
displayName: String = ""
|
||
|
|
) {
|
||
|
|
self.host = host
|
||
|
|
self.port = port ?? nasProtocol.defaultPort
|
||
|
|
self.nasProtocol = nasProtocol
|
||
|
|
self.username = username
|
||
|
|
self.password = password
|
||
|
|
self.remotePath = remotePath
|
||
|
|
self.displayName = displayName.isEmpty ? host : displayName
|
||
|
|
}
|
||
|
|
}
|