From c642a2e0ad773e580a6d6f326fba5caee72ef7b0 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sat, 14 Sep 2024 14:56:24 +0200 Subject: [PATCH] Upgrade to pion/dtls/v3 --- .vscode/settings.json | 4 +- coap-gateway/service/service.go | 20 ++++-- coap-gateway/service/session.go | 2 +- .../service/provisionCertificate_test.go | 2 +- .../service/service.go | 20 ++++-- go.mod | 15 ++--- go.sum | 65 +++++-------------- pkg/net/coap/service/service_test.go | 2 +- pkg/net/coap/service/udpServer.go | 6 +- 9 files changed, 56 insertions(+), 80 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e8ee9d754..b68a9282c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,7 +7,6 @@ "-v", "-cover", "-tags=test,test_mem", - //"-mod=vendor", ], "go.testEnvVars": { "LISTEN_FILE_CA_POOL": "${workspaceFolder}/.tmp/certs/root_ca.crt", @@ -56,7 +55,8 @@ // "GRPC_VERBOSITY":"DEBUG", // "GRPC_GO_LOG_VERBOSITY_LEVEL":99, // "GRPC_GO_LOG_SEVERITY_LEVEL":"info", - // "PION_LOG_TRACE=all" + // "PION_LOG_TRACE": "all", + // "GOFLAGS": "-mod=vendor", }, "go.testTimeout": "600s", "go.buildFlags": [ diff --git a/coap-gateway/service/service.go b/coap-gateway/service/service.go index 2fefdcc2e..beefc5bd2 100644 --- a/coap-gateway/service/service.go +++ b/coap-gateway/service/service.go @@ -12,7 +12,7 @@ import ( "time" "github.com/google/uuid" - "github.com/pion/dtls/v2" + "github.com/pion/dtls/v3" "github.com/plgd-dev/device/v2/pkg/net/coap" "github.com/plgd-dev/device/v2/schema/plgdtime" coapCodes "github.com/plgd-dev/go-coap/v3/message/codes" @@ -491,7 +491,7 @@ func defaultHandler(req *mux.Message, client *session) (*pool.Message, error) { const clientKey = "client" -func getTLSInfo(conn net.Conn, logger log.Logger) (deviceID string, validUntil time.Time) { +func getTLSInfo(ctx context.Context, conn net.Conn, logger log.Logger) (deviceID string, validUntil time.Time) { if tlsCon, ok := conn.(*tls.Conn); ok { peerCertificates := tlsCon.ConnectionState().PeerCertificates if len(peerCertificates) > 0 { @@ -506,12 +506,22 @@ func getTLSInfo(conn net.Conn, logger log.Logger) (deviceID string, validUntil t return "", time.Time{} } - tlsCon, ok := conn.(*dtls.Conn) + dtlsCon, ok := conn.(*dtls.Conn) if !ok { logger.Debugf("cannot get deviceID from certificate: unsupported connection type") return "", time.Time{} } - peerCertificates := tlsCon.ConnectionState().PeerCertificates + if err := dtlsCon.HandshakeContext(ctx); err != nil { + logger.Errorf("cannot get deviceID from certificate: handshake failed: %w", err) + return "", time.Time{} + } + + cs, ok := dtlsCon.ConnectionState() + if !ok { + logger.Debugf("cannot get deviceID from certificate: cannot get connection state") + return "", time.Time{} + } + peerCertificates := cs.PeerCertificates if len(peerCertificates) > 0 { cert, err := x509.ParseCertificate(peerCertificates[0]) if err != nil { @@ -530,7 +540,7 @@ func getTLSInfo(conn net.Conn, logger log.Logger) (deviceID string, validUntil t } func (s *Service) coapConnOnNew(coapConn mux.Conn) { - tlsDeviceID, tlsValidUntil := getTLSInfo(coapConn.NetConn(), s.logger) + tlsDeviceID, tlsValidUntil := getTLSInfo(s.ctx, coapConn.NetConn(), s.logger) client := newSession(s, coapConn, tlsDeviceID, tlsValidUntil) coapConn.SetContextValue(clientKey, client) coapConn.AddOnClose(func() { diff --git a/coap-gateway/service/session.go b/coap-gateway/service/session.go index b8123bf1d..c7bca8664 100644 --- a/coap-gateway/service/session.go +++ b/coap-gateway/service/session.go @@ -11,7 +11,7 @@ import ( "sync" "time" - "github.com/pion/dtls/v2" + "github.com/pion/dtls/v3" "github.com/plgd-dev/device/v2/schema/resources" "github.com/plgd-dev/go-coap/v3/message" "github.com/plgd-dev/go-coap/v3/message/codes" diff --git a/device-provisioning-service/service/provisionCertificate_test.go b/device-provisioning-service/service/provisionCertificate_test.go index 63e7adf8c..7bf485180 100644 --- a/device-provisioning-service/service/provisionCertificate_test.go +++ b/device-provisioning-service/service/provisionCertificate_test.go @@ -14,7 +14,7 @@ import ( "time" "github.com/google/uuid" - "github.com/pion/dtls/v2" + "github.com/pion/dtls/v3" deviceClient "github.com/plgd-dev/device/v2/client" "github.com/plgd-dev/device/v2/pkg/net/coap" "github.com/plgd-dev/device/v2/schema" diff --git a/device-provisioning-service/service/service.go b/device-provisioning-service/service/service.go index 04cf3e6bf..7d9ec3a19 100644 --- a/device-provisioning-service/service/service.go +++ b/device-provisioning-service/service/service.go @@ -9,7 +9,7 @@ import ( "net" "time" - "github.com/pion/dtls/v2" + "github.com/pion/dtls/v3" "github.com/plgd-dev/device/v2/schema/plgdtime" coapCodes "github.com/plgd-dev/go-coap/v3/message/codes" "github.com/plgd-dev/go-coap/v3/message/pool" @@ -216,7 +216,7 @@ func (RequestHandle) DefaultHandler(_ context.Context, req *mux.Message, _ *Sess const clientKey = "client" -func (server *Service) getVerifiedChain(conn net.Conn) (verifiedChains [][]*x509.Certificate) { +func (server *Service) getVerifiedChain(ctx context.Context, conn net.Conn) (verifiedChains [][]*x509.Certificate) { var certRaw []byte switch tlsCon := conn.(type) { case *tls.Conn: @@ -224,8 +224,18 @@ func (server *Service) getVerifiedChain(conn net.Conn) (verifiedChains [][]*x509 certRaw = tlsCon.ConnectionState().PeerCertificates[0].Raw } case *dtls.Conn: - if len(tlsCon.ConnectionState().PeerCertificates) > 0 { - certRaw = tlsCon.ConnectionState().PeerCertificates[0] + if err := tlsCon.HandshakeContext(ctx); err != nil { + server.logger.With(remoterAddr, conn.RemoteAddr().String()).Errorf("cannot get connection state: handshake failed: %w", err) + return nil + } + + cs, ok := tlsCon.ConnectionState() + if !ok { + server.logger.With(remoterAddr, conn.RemoteAddr().String()).Errorf("cannot get connection state") + return nil + } + if len(cs.PeerCertificates) > 0 { + certRaw = cs.PeerCertificates[0] } default: server.logger.With(remoterAddr, conn.RemoteAddr().String()).Errorf("unknown connection type: %T", conn) @@ -245,7 +255,7 @@ func (server *Service) getVerifiedChain(conn net.Conn) (verifiedChains [][]*x509 } func (server *Service) coapConnOnNew(coapConn mux.Conn) { - verifiedChains := server.getVerifiedChain(coapConn.NetConn()) + verifiedChains := server.getVerifiedChain(server.ctx, coapConn.NetConn()) session := newSession(server, coapConn, verifiedChains) coapConn.SetContextValue(clientKey, session) coapConn.AddOnClose(func() { diff --git a/go.mod b/go.mod index 63349cf85..9a5695f57 100644 --- a/go.mod +++ b/go.mod @@ -30,10 +30,10 @@ require ( github.com/lestrrat-go/jwx/v2 v2.1.1 github.com/nats-io/nats.go v1.37.0 github.com/panjf2000/ants/v2 v2.10.0 - github.com/pion/dtls/v2 v2.2.8-0.20240701035148-45e16a098c47 + github.com/pion/dtls/v3 v3.0.2 github.com/pion/logging v0.2.2 - github.com/plgd-dev/device/v2 v2.5.3-0.20240904102627-4c2719d9d856 - github.com/plgd-dev/go-coap/v3 v3.3.5-0.20240904100911-1afdeb72cb92 + github.com/plgd-dev/device/v2 v2.5.3-0.20240913103315-5b20bc19b159 + github.com/plgd-dev/go-coap/v3 v3.3.5-0.20240913102221-c784b43f59a1 github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90 github.com/pseudomuto/protoc-gen-doc v1.5.1 github.com/sirupsen/logrus v1.9.3 @@ -146,10 +146,5 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect ) -replace ( - // last version for Go 1.22 - github.com/go-json-experiment/json => github.com/go-json-experiment/json v0.0.0-20240815174924-0599f16bf0e2 - // note: github.com/pion/dtls/v2/pkg/net package is not yet available in release branches, - // so we force to the use of the pinned master branch - github.com/pion/dtls/v2 => github.com/pion/dtls/v2 v2.2.8-0.20240701035148-45e16a098c47 -) +// last version for Go 1.22 +replace github.com/go-json-experiment/json => github.com/go-json-experiment/json v0.0.0-20240815174924-0599f16bf0e2 diff --git a/go.sum b/go.sum index 2fa430fa9..c44ab0ecc 100644 --- a/go.sum +++ b/go.sum @@ -250,23 +250,28 @@ github.com/panjf2000/ants/v2 v2.10.0/go.mod h1:7ZxyxsqE4vvW0M7LSD8aI3cKwgFhBHbxn github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= -github.com/pion/dtls/v2 v2.2.8-0.20240701035148-45e16a098c47 h1:WCUn5hJZLLMoOvedDEDA/OFzaYbZy7G71mQ9h5GiQ/o= -github.com/pion/dtls/v2 v2.2.8-0.20240701035148-45e16a098c47/go.mod h1:8eXNLDNOiXaHvo/wOFnFcr/yinEimCDUQ512tlOSvPo= +github.com/pion/dtls/v2 v2.0.1-0.20200503085337-8e86b3a7d585/go.mod h1:/GahSOC8ZY/+17zkaGJIG4OUkSGAcZu/N/g3roBOCkM= +github.com/pion/dtls/v2 v2.0.10-0.20210502094952-3dc563b9aede/go.mod h1:86wv5dgx2J/z871nUR+5fTTY9tISLUlo+C5Gm86r1Hs= +github.com/pion/dtls/v3 v3.0.2 h1:425DEeJ/jfuTTghhUDW0GtYZYIwwMtnKKJNMcWccTX0= +github.com/pion/dtls/v3 v3.0.2/go.mod h1:dfIXcFkKoujDQ+jtd8M6RgqKK3DuaUilm3YatAbGp5k= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= -github.com/pion/transport/v3 v3.0.2/go.mod h1:nIToODoOlb5If2jF9y2Igfx3PFYWfuXi37m0IlWa/D0= +github.com/pion/transport v0.10.0/go.mod h1:BnHnUipd0rZQyTVB2SBGojFHT9CBt5C5TcsJSQGkvSE= +github.com/pion/transport v0.12.2/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q= +github.com/pion/transport v0.12.3/go.mod h1:OViWW9SP2peE/HbwBvARicmAVnesphkNkCVZIWJ6q9A= github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0= github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo= +github.com/pion/udp v0.1.1/go.mod h1:6AFo+CMdKQm7UiA0eUPA8/eVCTx8jBIITLZHc9DWX5M= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA= github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo= -github.com/plgd-dev/device/v2 v2.5.3-0.20240904102627-4c2719d9d856 h1:Pr2p8Jz8j5xGUzHfSZf6e+JuiK+7nIeUj6NkXGzTPck= -github.com/plgd-dev/device/v2 v2.5.3-0.20240904102627-4c2719d9d856/go.mod h1:dAg9B86I16y3OpR4bthTyG4o4hLrJ359nUZZ3QaP3mA= +github.com/plgd-dev/device/v2 v2.5.3-0.20240913103315-5b20bc19b159 h1:+FIu8q0tqxvDpolT0m3mESd0yqhW0E8jY8yonffd1ps= +github.com/plgd-dev/device/v2 v2.5.3-0.20240913103315-5b20bc19b159/go.mod h1:FEVchdsXNX3P1uuygCcwp37HMTB/MhCIm1BcsfnIgak= github.com/plgd-dev/go-coap/v2 v2.0.4-0.20200819112225-8eb712b901bc/go.mod h1:+tCi9Q78H/orWRtpVWyBgrr4vKFo2zYtbbxUllerBp4= github.com/plgd-dev/go-coap/v2 v2.4.1-0.20210517130748-95c37ac8e1fa/go.mod h1:rA7fc7ar+B/qa+Q0hRqv7yj/EMtIlmo1l7vkQGSrHPU= -github.com/plgd-dev/go-coap/v3 v3.3.5-0.20240904100911-1afdeb72cb92 h1:lYHs2T4R5UYcn0+qo2381wpZRAPnAsAZiJMFC1dWlhg= -github.com/plgd-dev/go-coap/v3 v3.3.5-0.20240904100911-1afdeb72cb92/go.mod h1:BONaewfxSezj9KR39TGHIV3viL/Diz+XVOnAzBS80Fw= +github.com/plgd-dev/go-coap/v3 v3.3.5-0.20240913102221-c784b43f59a1 h1:DDvGvKaldQrISuVBGa84E45KDDkqbeNtmUDU7Sb/5Bc= +github.com/plgd-dev/go-coap/v3 v3.3.5-0.20240913102221-c784b43f59a1/go.mod h1:Cs6sfxmF/b8ktTVfPMf6FzihFx+0mEZ/ClbFNUnnsZw= github.com/plgd-dev/kit v0.0.0-20200819113605-d5fcf3e94f63/go.mod h1:Yl9zisyXfPdtP9hTWlJqjJYXmgU/jtSDKttz9/CeD90= github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90 h1:TC1HJ/UbyflJFPvaOdGmNZ5TeFGex1/dyr9urNGLy7M= github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90/go.mod h1:Z7oKFLSGQjdi8eInxwFCs0tSApuEM1o0qNck+sJYp4M= @@ -400,15 +405,11 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -423,10 +424,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -441,16 +438,11 @@ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210502030024-e5908800b52b/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -464,10 +456,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -484,37 +473,16 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -533,9 +501,6 @@ golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/net/coap/service/service_test.go b/pkg/net/coap/service/service_test.go index 93d560629..32d000615 100644 --- a/pkg/net/coap/service/service_test.go +++ b/pkg/net/coap/service/service_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/pion/dtls/v2" + "github.com/pion/dtls/v3" coapDtls "github.com/plgd-dev/go-coap/v3/dtls" "github.com/plgd-dev/go-coap/v3/message/pool" "github.com/plgd-dev/go-coap/v3/mux" diff --git a/pkg/net/coap/service/udpServer.go b/pkg/net/coap/service/udpServer.go index d199a4c85..5ae9a9c85 100644 --- a/pkg/net/coap/service/udpServer.go +++ b/pkg/net/coap/service/udpServer.go @@ -1,11 +1,10 @@ package service import ( - "context" "crypto/tls" "fmt" - "github.com/pion/dtls/v2" + "github.com/pion/dtls/v3" coapDtlsServer "github.com/plgd-dev/go-coap/v3/dtls/server" "github.com/plgd-dev/go-coap/v3/net" "github.com/plgd-dev/go-coap/v3/options" @@ -115,9 +114,6 @@ func newDTLSListener(config Config, serviceOpts Options, fileWatcher *fsnotify.W } dtlsCfg := TLSConfigToDTLSConfig(tlsCfg) dtlsCfg.LoggerFactory = logger.DTLSLoggerFactory() - dtlsCfg.ConnectContextMaker = func() (context.Context, func()) { - return context.WithTimeout(context.Background(), config.GetTimeout()) - } listener, err := net.NewDTLSListener("udp", config.Addr, dtlsCfg) if err != nil { closeListener.Execute()