blob: 0ebcf2f51d6b4ee5f5660e9174fde45072513cc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import SwiftUI
@Observable final class Tracker {
let address: String
let port: Int
init(address: String, port: Int = HotlinePorts.DefaultTrackerPort) {
self.address = address
self.port = port
}
static func parseTrackerAddressAndPort(_ address: String) -> (String, Int) {
let url = URL(string: "hotlinetracker://\(address)")
let port = url?.port ?? HotlinePorts.DefaultTrackerPort
let host = url?.host(percentEncoded: false) ?? ""
return (host.lowercased().trimmingCharacters(in: .whitespacesAndNewlines), port)
}
}
|