aboutsummaryrefslogtreecommitdiff
path: root/Hotline
diff options
context:
space:
mode:
authorDustin Mierau <mierau@users.noreply.github.com>2024-03-06 19:13:42 -0800
committerGitHub <noreply@github.com>2024-03-06 19:13:42 -0800
commit6aad4ed3d079db171564144aa69b0431f5af669d (patch)
tree772dfa5dc30df6f16cf59dfcfd868967610deac8 /Hotline
parentbd457c67bf22ea14b2e16785936cac322eebcd5a (diff)
parent4cd8123107370526a01dfa8d7d1996fe0ff04649 (diff)
Merge pull request #7 from jhalter/fix_login
Fix login/password encoding and bookmark logins
Diffstat (limited to 'Hotline')
-rw-r--r--Hotline/Hotline/HotlineProtocol.swift19
-rw-r--r--Hotline/macOS/TrackerView.swift2
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)
}
}