From cc3e72e28ebea66414507bb5136b2a2effba0298 Mon Sep 17 00:00:00 2001 From: 1998-felix Date: Fri, 15 Sep 2023 13:38:32 +0300 Subject: [PATCH] Amend server Signed-off-by: 1998-felix --- internal/server/coap/coap.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/server/coap/coap.go b/internal/server/coap/coap.go index 09bb2ffeb6f..05ab0125c4a 100644 --- a/internal/server/coap/coap.go +++ b/internal/server/coap/coap.go @@ -8,6 +8,7 @@ import ( "github.com/mainflux/mainflux/internal/server" "github.com/mainflux/mainflux/logger" + piondtls "github.com/pion/dtls/v2" gocoap "github.com/plgd-dev/go-coap/v2" "github.com/plgd-dev/go-coap/v2/mux" ) @@ -59,10 +60,9 @@ func (s *Server) Start() error { }() case enableDTLS: - s.Logger.Info(fmt.Sprintf("%s service %s server listening at %s with TLS cert %s and key %s"s.Name, s.Protocol, s.Address, s.Config.Certfile, s.config.KeyFile)) - - - go func(){ + s.Logger.Info(fmt.Sprintf("%s service %s server listening at %s with TLS cert %s and key %s", s.Name, s.Protocol, s.Address, s.Config.Certfile, s.config.KeyFile)) + + go func() { errCh <- gocoap.ListenAndServeDTLS("udp", ":5688", &piondtls.Config{ PSK: func(hint []byte) ([]byte, error) { fmt.Printf("Client's hint: %s \n", hint) @@ -71,9 +71,9 @@ func (s *Server) Start() error { PSKIdentityHint: []byte("Pion DTLS Client"), CipherSuites: []piondtls.CipherSuiteID{piondtls.TLS_PSK_WITH_AES_128_CCM_8}, }, s.handler) - - } - + + }() + default: s.Logger.Info(fmt.Sprintf("%s service %s server listening at %s without TLS", s.Name, s.Protocol, s.Address)) go func() {