Add quic qlog to debug logs

This commit is contained in:
yuhan6665 2022-04-23 19:13:06 -04:00
parent 11518fe089
commit c9df755426
5 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,26 @@
package quic
import (
"fmt"
"github.com/xtls/xray-core/common/log"
)
type QlogWriter struct {
connID []byte
}
func (w *QlogWriter) Write(b []byte) (int, error) {
if len(b) > 1 { // skip line separator "0a" in qlog
log.Record(&log.GeneralMessage{
Severity: log.Severity_Debug,
Content: fmt.Sprintf("[%x] %s", w.connID, b),
})
}
return len(b), nil
}
func (w *QlogWriter) Close() error {
// Noop
return nil
}