Skip to content

Commit

Permalink
Fix time units in example
Browse files Browse the repository at this point in the history
WithTimeout should be seconds not nanoseconds
  • Loading branch information
Sean-Der committed Jul 29, 2024
1 parent 2ed7caa commit 7139e0e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion examples/listen/cid/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"fmt"
"net"
"time"

"github.com/pion/dtls/v3"
"github.com/pion/dtls/v3/examples/util"
Expand Down Expand Up @@ -57,7 +58,7 @@ func main() {
// functions like `ConnectionState` etc.

// Perform the handshake with a 30-second timeout
ctx, cancel := context.WithTimeout(context.Background(), 30)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
dtlsConn, ok := conn.(*dtls.Conn)
if ok {
util.Check(dtlsConn.HandshakeContext(ctx))
Expand Down
3 changes: 2 additions & 1 deletion examples/listen/psk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"fmt"
"net"
"time"

"github.com/pion/dtls/v3"
"github.com/pion/dtls/v3/examples/util"
Expand Down Expand Up @@ -56,7 +57,7 @@ func main() {
// functions like `ConnectionState` etc.

// Perform the handshake with a 30-second timeout
ctx, cancel := context.WithTimeout(context.Background(), 30)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
dtlsConn, ok := conn.(*dtls.Conn)
if ok {
util.Check(dtlsConn.HandshakeContext(ctx))
Expand Down
3 changes: 2 additions & 1 deletion examples/listen/selfsign/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"crypto/tls"
"fmt"
"net"
"time"

"github.com/pion/dtls/v3"
"github.com/pion/dtls/v3/examples/util"
Expand Down Expand Up @@ -57,7 +58,7 @@ func main() {
// functions like `ConnectionState` etc.

// Perform the handshake with a 30-second timeout
ctx, cancel := context.WithTimeout(context.Background(), 30)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
dtlsConn, ok := conn.(*dtls.Conn)
if ok {
util.Check(dtlsConn.HandshakeContext(ctx))
Expand Down
2 changes: 1 addition & 1 deletion examples/listen/verify-brute-force-protection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func main() {
// *************** END Brute Force Attack protection END ***************

// Perform the handshake with a 30-second timeout
ctx, cancel := context.WithTimeout(context.Background(), 30)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
dtlsConn, ok := conn.(*dtls.Conn)
if ok {
util.Check(dtlsConn.HandshakeContext(ctx))
Expand Down
3 changes: 2 additions & 1 deletion examples/listen/verify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"crypto/x509"
"fmt"
"net"
"time"

"github.com/pion/dtls/v3"
"github.com/pion/dtls/v3/examples/util"
Expand Down Expand Up @@ -66,7 +67,7 @@ func main() {
// functions like `ConnectionState` etc.

// Perform the handshake with a 30-second timeout
ctx, cancel := context.WithTimeout(context.Background(), 30)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
dtlsConn, ok := conn.(*dtls.Conn)
if ok {
util.Check(dtlsConn.HandshakeContext(ctx))
Expand Down

0 comments on commit 7139e0e

Please sign in to comment.