move function to create the TLS key log file to a separate file

This commit is contained in:
Marten Seemann
2020-02-12 11:48:31 +07:00
parent dd035c2f12
commit 89728126cc
3 changed files with 37 additions and 20 deletions

View File

@@ -3,7 +3,6 @@ package main
import (
"crypto/tls"
"fmt"
"io"
"log"
"net"
"net/http"
@@ -13,6 +12,7 @@ import (
"github.com/lucas-clemente/quic-go/http3"
"github.com/lucas-clemente/quic-go/internal/testdata"
"github.com/lucas-clemente/quic-go/interop/http09"
"github.com/lucas-clemente/quic-go/interop/utils"
)
var tlsConf *tls.Config
@@ -26,15 +26,13 @@ func main() {
defer logFile.Close()
log.SetOutput(logFile)
var keyLog io.Writer
if filename := os.Getenv("SSLKEYLOGFILE"); len(filename) > 0 {
f, err := os.Create(filename)
if err != nil {
fmt.Printf("Could not create key log file: %s\n", err.Error())
os.Exit(1)
}
defer f.Close()
keyLog = f
keyLog, err := utils.GetSSLKeyLog()
if err != nil {
fmt.Printf("Could not create key log: %s\n", err.Error())
os.Exit(1)
}
if keyLog != nil {
defer keyLog.Close()
}
testcase := os.Getenv("TESTCASE")