diff options
| -rw-r--r-- | Hotline/Hotline/HotlineProtocol.swift | 19 | ||||
| -rw-r--r-- | Hotline/macOS/TrackerView.swift | 2 |
2 files changed, 7 insertions, 14 deletions
diff --git a/Hotline/Hotline/HotlineProtocol.swift b/Hotline/Hotline/HotlineProtocol.swift index 3be58ac..f98e07b 100644 --- a/Hotline/Hotline/HotlineProtocol.swift +++ b/Hotline/Hotline/HotlineProtocol.swift @@ -474,21 +474,14 @@ struct HotlineTransactionField { } init(type: HotlineTransactionFieldType, string: String, encoding: String.Encoding = .ascii, encrypt: Bool = false) { - var stringInput = string - + var bytes = [UInt8](string.utf8) if encrypt { - stringInput = String(string.utf8.map { char in - Character(UnicodeScalar(0xFF - char)) - }) - } - - var stringData: Data? - stringData = stringInput.data(using: encoding, allowLossyConversion: true) - if stringData == nil { - stringData = Data() + bytes = string.utf8.map { char in + return 0xFF - char + } } - - self.init(type: type, dataSize: UInt16(stringData!.count), data: [UInt8](stringData!)) + + self.init(type: type, dataSize: UInt16(bytes.count), data: [UInt8](bytes)) } init(type: HotlineTransactionFieldType, string: String, encrypt: Bool) { diff --git a/Hotline/macOS/TrackerView.swift b/Hotline/macOS/TrackerView.swift index 073ecdf..a07d40c 100644 --- a/Hotline/macOS/TrackerView.swift +++ b/Hotline/macOS/TrackerView.swift @@ -158,7 +158,7 @@ struct TrackerView: View { openWindow(id: "server", value: server) } else if let bookmark = clickedItem.bookmark, bookmark.type == .server { - let server = Server(name: bookmark.name, description: nil, address: bookmark.address, port: HotlinePorts.DefaultServerPort) + let server = Server(name: bookmark.name, description: nil, address: bookmark.address, port: bookmark.port, login: bookmark.login ?? "", password: bookmark.password ?? "") openWindow(id: "server", value: server) } } |