This commit is contained in:
parent
90eedbf86e
commit
614b4b5e43
|
@ -6,6 +6,7 @@ host="olympus.vpn.huizinga.dev"
|
||||||
port=8883
|
port=8883
|
||||||
username="mqtt"
|
username="mqtt"
|
||||||
password="${MQTT_PASSWORD}"
|
password="${MQTT_PASSWORD}"
|
||||||
|
tls=true
|
||||||
|
|
||||||
[ntfy]
|
[ntfy]
|
||||||
topic = "${NTFY_TOPIC}"
|
topic = "${NTFY_TOPIC}"
|
||||||
|
|
|
@ -6,6 +6,7 @@ host="olympus.lan.huizinga.dev"
|
||||||
port=8883
|
port=8883
|
||||||
username="mqtt"
|
username="mqtt"
|
||||||
password="${MQTT_PASSWORD}"
|
password="${MQTT_PASSWORD}"
|
||||||
|
tls=true
|
||||||
|
|
||||||
[ntfy]
|
[ntfy]
|
||||||
topic = "${NTFY_TOPIC}"
|
topic = "${NTFY_TOPIC}"
|
||||||
|
|
|
@ -34,6 +34,8 @@ pub struct MqttConfig {
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub password: String,
|
pub password: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub tls: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|
|
@ -64,7 +64,10 @@ async fn app() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut mqttoptions = MqttOptions::new("rust-test", mqtt.host, mqtt.port);
|
let mut mqttoptions = MqttOptions::new("rust-test", mqtt.host, mqtt.port);
|
||||||
mqttoptions.set_credentials(mqtt.username, mqtt.password);
|
mqttoptions.set_credentials(mqtt.username, mqtt.password);
|
||||||
mqttoptions.set_keep_alive(Duration::from_secs(5));
|
mqttoptions.set_keep_alive(Duration::from_secs(5));
|
||||||
mqttoptions.set_transport(Transport::tls_with_default_config());
|
|
||||||
|
if mqtt.tls {
|
||||||
|
mqttoptions.set_transport(Transport::tls_with_default_config());
|
||||||
|
}
|
||||||
|
|
||||||
// Create a mqtt client and wrap the eventloop
|
// Create a mqtt client and wrap the eventloop
|
||||||
let (client, eventloop) = AsyncClient::new(mqttoptions, 10);
|
let (client, eventloop) = AsyncClient::new(mqttoptions, 10);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user