You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
506 B
Go
30 lines
506 B
Go
2 years ago
|
package flow
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
"os"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
// Wireshark 解析 https 设置
|
||
|
var tlsKeyLogWriter io.Writer
|
||
|
var tlsKeyLogOnce sync.Once
|
||
|
|
||
|
func GetTlsKeyLogWriter() io.Writer {
|
||
|
tlsKeyLogOnce.Do(func() {
|
||
|
logfile := os.Getenv("SSLKEYLOGFILE")
|
||
|
if logfile == "" {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
writer, err := os.OpenFile(logfile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
|
||
|
if err != nil {
|
||
|
log.WithField("in", "GetTlsKeyLogWriter").Debug(err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
tlsKeyLogWriter = writer
|
||
|
})
|
||
|
return tlsKeyLogWriter
|
||
|
}
|