Merge pull request #2285 from lucas-clemente/interop-key-log-files

export key log files from client and server in the interop runner
This commit is contained in:
Marten Seemann
2020-01-06 19:16:40 +07:00
committed by GitHub
2 changed files with 33 additions and 21 deletions

View File

@@ -19,6 +19,8 @@ import (
var errUnsupported = errors.New("unsupported test case")
var tlsConf *tls.Config
func main() {
logFile, err := os.Create("/logs/log.txt")
if err != nil {
@@ -28,6 +30,17 @@ func main() {
defer logFile.Close()
log.SetOutput(logFile)
keyLog, err := os.Create("/logs/keylogfile.txt")
if err != nil {
fmt.Printf("Could not create key log file: %s\n", err.Error())
os.Exit(1)
}
defer keyLog.Close()
tlsConf = &tls.Config{
InsecureSkipVerify: true,
KeyLogWriter: keyLog,
}
testcase := os.Getenv("TESTCASE")
if err := runTestcase(testcase); err != nil {
if err == errUnsupported {
@@ -45,9 +58,7 @@ func runTestcase(testcase string) error {
switch testcase {
case "http3":
r := &http3.RoundTripper{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
r := &http3.RoundTripper{TLSClientConfig: tlsConf}
defer r.Close()
return downloadFiles(r, urls)
case "handshake", "transfer", "retry":
@@ -59,9 +70,7 @@ func runTestcase(testcase string) error {
return errUnsupported
}
r := &http09.RoundTripper{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
r := &http09.RoundTripper{TLSClientConfig: tlsConf}
defer r.Close()
return downloadFiles(r, urls)
}
@@ -85,27 +94,18 @@ func runResumptionTest(urls []string) error {
if len(urls) < 2 {
return errors.New("expected at least 2 URLs")
}
csc := tls.NewLRUClientSessionCache(1)
tlsConf.ClientSessionCache = tls.NewLRUClientSessionCache(1)
// do the first transfer
r := &http09.RoundTripper{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
ClientSessionCache: csc,
},
}
r := &http09.RoundTripper{TLSClientConfig: tlsConf}
if err := downloadFiles(r, urls[:1]); err != nil {
return err
}
r.Close()
// reestablish the connection, using the session ticket that the server (hopefully provided)
r = &http09.RoundTripper{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
ClientSessionCache: csc,
},
}
r = &http09.RoundTripper{TLSClientConfig: tlsConf}
defer r.Close()
return downloadFiles(r, urls[1:])
}

View File

@@ -1,6 +1,7 @@
package main
import (
"crypto/tls"
"fmt"
"log"
"net"
@@ -13,6 +14,8 @@ import (
"github.com/lucas-clemente/quic-go/interop/http09"
)
var tlsConf *tls.Config
func main() {
logFile, err := os.Create("/logs/log.txt")
if err != nil {
@@ -22,12 +25,21 @@ func main() {
defer logFile.Close()
log.SetOutput(logFile)
keyLog, err := os.Create("/logs/keylogfile.txt")
if err != nil {
fmt.Printf("Could not create key log file: %s\n", err.Error())
os.Exit(1)
}
defer keyLog.Close()
testcase := os.Getenv("TESTCASE")
// a quic.Config that doesn't do a Retry
quicConf := &quic.Config{
AcceptToken: func(_ net.Addr, _ *quic.Token) bool { return true },
}
tlsConf = testdata.GetTLSConfig()
tlsConf.KeyLogWriter = keyLog
switch testcase {
case "versionnegotiation", "handshake", "transfer", "resumption":
@@ -53,7 +65,7 @@ func runHTTP09Server(quicConf *quic.Config) error {
server := http09.Server{
Server: &http.Server{
Addr: "0.0.0.0:443",
TLSConfig: testdata.GetTLSConfig(),
TLSConfig: tlsConf,
},
QuicConfig: quicConf,
}
@@ -65,7 +77,7 @@ func runHTTP3Server(quicConf *quic.Config) error {
server := http3.Server{
Server: &http.Server{
Addr: "0.0.0.0:443",
TLSConfig: testdata.GetTLSConfig(),
TLSConfig: tlsConf,
},
QuicConfig: quicConf,
}