mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
update mqtt port parsing
This commit is contained in:
parent
5aaee8821c
commit
851b8ca900
1 changed files with 8 additions and 6 deletions
|
|
@ -26,17 +26,19 @@ class MqttClientProxyManager {
|
|||
var topic = "msh"
|
||||
var debugLog = false
|
||||
func connectFromConfigSettings(node: NodeInfoEntity) {
|
||||
var host = node.mqttConfig?.address ?? "mqtt.meshtastic.org"
|
||||
let originalAddress = node.mqttConfig?.address ?? "mqtt.meshtastic.org"
|
||||
let defaultServerAddress = "mqtt.meshtastic.org"
|
||||
var useSsl = node.mqttConfig?.tlsEnabled == true
|
||||
var defaultServerPort = useSsl ? 8883 : 1883
|
||||
var host = originalAddress
|
||||
if originalAddress.contains(":") {
|
||||
host = host.components(separatedBy: ":")[0]
|
||||
defaultServerPort = Int(originalAddress.components(separatedBy: ":")[1]) ?? (useSsl ? 8883 : 1883)
|
||||
}
|
||||
// Require TLS for the public Server
|
||||
if host.lowercased() == defaultServerAddress {
|
||||
useSsl = true
|
||||
}
|
||||
var defaultServerPort = useSsl ? 8883 : 1883
|
||||
if host.contains(":") {
|
||||
host = host.components(separatedBy: ":")[0]
|
||||
defaultServerPort = Int(host.components(separatedBy: ":")[1]) ?? (useSsl ? 8883 : 1883)
|
||||
defaultServerPort = 8883
|
||||
}
|
||||
let port = defaultServerPort
|
||||
let root = node.mqttConfig?.root?.count ?? 0 > 0 ? node.mqttConfig?.root : "msh"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue