forked from quic-go/quic-go
move function to create the TLS key log file to a separate file
This commit is contained in:
@@ -11,10 +11,12 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/http3"
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/interop/http09"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"github.com/lucas-clemente/quic-go/interop/utils"
|
||||
)
|
||||
|
||||
var errUnsupported = errors.New("unsupported test case")
|
||||
@@ -30,15 +32,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()
|
||||
}
|
||||
|
||||
tlsConf = &tls.Config{
|
||||
|
||||
@@ -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")
|
||||
|
||||
19
interop/utils/logging.go
Normal file
19
interop/utils/logging.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// GetSSLKeyLog creates a file for the TLS key log
|
||||
func GetSSLKeyLog() (io.WriteCloser, error) {
|
||||
filename := os.Getenv("SSLKEYLOGFILE")
|
||||
if len(filename) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
f, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return f, nil
|
||||
}
|
||||
Reference in New Issue
Block a user