introduce Transport.ConnContext, use client's context on the connection (#4507)

* introduce Transport.ConnContext, use client's context on the connection

* panic if ConnContext returns nil
This commit is contained in:
Marten Seemann
2024-05-27 12:30:19 +08:00
committed by GitHub
parent e2fbf3cdcd
commit 0d1e27d77c
15 changed files with 260 additions and 97 deletions

View File

@@ -1,6 +1,7 @@
package main
import (
"context"
"crypto/tls"
"log"
"net"
@@ -49,11 +50,11 @@ func main() {
protocol.Version1,
)
if err := client.StartHandshake(); err != nil {
if err := client.StartHandshake(context.Background()); err != nil {
log.Fatal(err)
}
if err := server.StartHandshake(); err != nil {
if err := server.StartHandshake(context.Background()); err != nil {
log.Fatal(err)
}

View File

@@ -1,6 +1,7 @@
package handshake
import (
"context"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
@@ -286,7 +287,7 @@ func runHandshake(runConfig [confLen]byte, messageConfig uint8, clientConf *tls.
utils.DefaultLogger.WithPrefix("client"),
protocol.Version1,
)
if err := client.StartHandshake(); err != nil {
if err := client.StartHandshake(context.Background()); err != nil {
log.Fatal(err)
}
defer client.Close()
@@ -303,7 +304,7 @@ func runHandshake(runConfig [confLen]byte, messageConfig uint8, clientConf *tls.
utils.DefaultLogger.WithPrefix("server"),
protocol.Version1,
)
if err := server.StartHandshake(); err != nil {
if err := server.StartHandshake(context.Background()); err != nil {
log.Fatal(err)
}
defer server.Close()