From 606030808ee03ef5c1531367cace56d990ea4394 Mon Sep 17 00:00:00 2001 From: Johan Stenstam Date: Fri, 27 Sep 2024 14:17:14 +0200 Subject: [PATCH] foo --- go.mod | 1 + go.sum | 2 ++ main.go | 8 +++++++- slogger.sample.yaml | 27 +++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 slogger.sample.yaml diff --git a/go.mod b/go.mod index ac9d05b..fc89d4c 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.22.3 require ( github.com/dnstapir/tapir v0.0.0-20240927111630-589bd474c6e4 + github.com/google/uuid v1.4.0 github.com/gorilla/mux v1.8.1 github.com/lestrrat-go/jwx/v2 v2.0.21 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index a2c1fd5..08ba9ea 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,8 @@ github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= github.com/gookit/goutil v0.6.16 h1:9fRMCF4X9abdRD5+2HhBS/GwafjBlTUBjRtA5dgkvuw= diff --git a/main.go b/main.go index 81b0eb5..36e9a86 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "os/signal" "syscall" + "github.com/google/uuid" flag "github.com/spf13/pflag" "github.com/dnstapir/tapir" @@ -23,9 +24,14 @@ var TEMExiter = func(args ...interface{}) { os.Exit(1) } +var mqttclientid string + func main() { + mqttclientid = "tapir-slogger-" + uuid.New().String() flag.BoolVarP(&tapir.GlobalCF.Debug, "debug", "d", false, "Debug mode") flag.BoolVarP(&tapir.GlobalCF.Verbose, "verbose", "v", false, "Verbose mode") + flag.StringVarP(&mqttclientid, "client-id", "", mqttclientid, "MQTT client id, default is a random string") + flag.Parse() var cfgFile string @@ -54,7 +60,7 @@ func main() { // Initialize logger logger := NewLogger(config.LogConfig.File) - meng, err := tapir.NewMqttEngine("tapir-slogger", config.TapirConfig.MqttConfig.ClientID, tapir.TapirSub, nil, log.Default()) + meng, err := tapir.NewMqttEngine("tapir-slogger", mqttclientid, tapir.TapirSub, nil, log.Default()) if err != nil { log.Fatalf("Error initializing MQTT engine: %v", err) } diff --git a/slogger.sample.yaml b/slogger.sample.yaml new file mode 100644 index 0000000..4cab72a --- /dev/null +++ b/slogger.sample.yaml @@ -0,0 +1,27 @@ +apiserver: + addresses: [ ":8080" ] + tlsaddresses: [ ":8081" ] + +tapir: + mqtt: + server: tls://mqtt.dev.dnstapir.se:8883 + qos: 1 + clientcert: /etc/dnstapir/certs/mqttclient.crt + clientkey: /etc/dnstapir/certs/mqttclient-key.pem + cacert: /etc/dnstapir/certs/tapirCA.crt + + status: + topic: status/up/axfr/tapir-pop + validatorkey: /etc/dnstapir/certs/mqttsigner-pub.pem + + keyupload: + topic: pubkey/up/# + +certs: + cacertfile: /etc/dnstapir/certs/tapirCA.crt + tapir-slogger: + cert: /etc/dnstapir/certs/mqttclient.crt + key: /etc/dnstapir/certs/mqttclient-key.pem + +log: + file: /var/log/dnstapir/tapir-slogger.log