fix: resolve merge conflict

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2024-04-25 14:27:25 +02:00
commit e2c4540cb4
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A
3 changed files with 22 additions and 1 deletions

View File

@ -24,6 +24,7 @@ mqtt-port = {{ .PlmntConfig.MqttPort }}
mqtt-user = "{{ .PlmntConfig.MqttUser }}" mqtt-user = "{{ .PlmntConfig.MqttUser }}"
mqtt-password = "{{ .PlmntConfig.MqttPassword }}" mqtt-password = "{{ .PlmntConfig.MqttPassword }}"
claim-host = "{{ .PlmntConfig.ClaimHost }}" claim-host = "{{ .PlmntConfig.ClaimHost }}"
mqtt-tls = {{ .PlmntConfig.MqttTLS }}
` `
// Config defines Planetmint's top level configuration // Config defines Planetmint's top level configuration
@ -41,6 +42,7 @@ type Config struct {
MqttUser string `json:"mqtt-user" mapstructure:"mqtt-user"` MqttUser string `json:"mqtt-user" mapstructure:"mqtt-user"`
MqttPassword string `json:"mqtt-password" mapstructure:"mqtt-password"` MqttPassword string `json:"mqtt-password" mapstructure:"mqtt-password"`
ClaimHost string `json:"claim-host" mapstructure:"claim-host"` ClaimHost string `json:"claim-host" mapstructure:"claim-host"`
MqttTLS bool `json:"mqtt-tls" mapstructure:"mqtt-tls"`
} }
// cosmos-sdk wide global singleton // cosmos-sdk wide global singleton
@ -61,10 +63,11 @@ func DefaultConfig() *Config {
RPCWallet: "rpcwallet", RPCWallet: "rpcwallet",
ValidatorAddress: "plmnt1w5dww335zhh98pzv783hqre355ck3u4w4hjxcx", ValidatorAddress: "plmnt1w5dww335zhh98pzv783hqre355ck3u4w4hjxcx",
MqttDomain: "testnet-mqtt.rddl.io", MqttDomain: "testnet-mqtt.rddl.io",
MqttPort: 1885, MqttPort: 1886,
MqttUser: "user", MqttUser: "user",
MqttPassword: "password", MqttPassword: "password",
ClaimHost: "testnet-p2r.rddl.io", ClaimHost: "testnet-p2r.rddl.io",
MqttTLS: true,
} }
} }

View File

@ -1,6 +1,7 @@
package monitor package monitor
import ( import (
"crypto/tls"
"math/rand" "math/rand"
"net" "net"
"strconv" "strconv"
@ -51,11 +52,19 @@ func LazyLoadMonitorMQTTClient() {
conf := config.GetConfig() conf := config.GetConfig()
hostPort := net.JoinHostPort(conf.MqttDomain, strconv.FormatInt(int64(conf.MqttPort), 10)) hostPort := net.JoinHostPort(conf.MqttDomain, strconv.FormatInt(int64(conf.MqttPort), 10))
uri := "tcp://" + hostPort uri := "tcp://" + hostPort
if conf.MqttTLS {
uri = "ssl://" + hostPort
}
opts := mqtt.NewClientOptions().AddBroker(uri) opts := mqtt.NewClientOptions().AddBroker(uri)
opts.SetClientID(conf.ValidatorAddress + "-monitor") opts.SetClientID(conf.ValidatorAddress + "-monitor")
opts.SetUsername(conf.MqttUser) opts.SetUsername(conf.MqttUser)
opts.SetPassword(conf.MqttPassword) opts.SetPassword(conf.MqttPassword)
if conf.MqttTLS {
tlsConfig := &tls.Config{}
opts.SetTLSConfig(tlsConfig)
}
MonitorMQTTClient = mqtt.NewClient(opts) MonitorMQTTClient = mqtt.NewClient(opts)
} }

View File

@ -1,6 +1,7 @@
package util package util
import ( import (
"crypto/tls"
"encoding/json" "encoding/json"
"net" "net"
"strconv" "strconv"
@ -42,11 +43,19 @@ func LazyLoadMQTTClient() {
conf := config.GetConfig() conf := config.GetConfig()
hostPort := net.JoinHostPort(conf.MqttDomain, strconv.FormatInt(int64(conf.MqttPort), 10)) hostPort := net.JoinHostPort(conf.MqttDomain, strconv.FormatInt(int64(conf.MqttPort), 10))
uri := "tcp://" + hostPort uri := "tcp://" + hostPort
if conf.MqttTLS {
uri = "ssl://" + hostPort
}
opts := mqtt.NewClientOptions().AddBroker(uri) opts := mqtt.NewClientOptions().AddBroker(uri)
opts.SetClientID(conf.ValidatorAddress) opts.SetClientID(conf.ValidatorAddress)
opts.SetUsername(conf.MqttUser) opts.SetUsername(conf.MqttUser)
opts.SetPassword(conf.MqttPassword) opts.SetPassword(conf.MqttPassword)
if conf.MqttTLS {
tlsConfig := &tls.Config{}
opts.SetTLSConfig(tlsConfig)
}
MQTTClient = mqtt.NewClient(opts) MQTTClient = mqtt.NewClient(opts)
} }