Skip to content

Commit

Permalink
Fix cloudflare-tls usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Aug 31, 2023
1 parent 32a432d commit 631da08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ func (s *connection) ConnectionState() ConnectionState {
defer s.connStateMutex.Unlock()
cs := s.cryptoStreamHandler.ConnectionState()
s.connState.TLS = cs.ConnectionState
s.connState.ExportKeyingMaterial = cs.ConnectionState.ExportKeyingMaterial
s.connState.Used0RTT = cs.Used0RTT
return s.connState
}
Expand Down
6 changes: 5 additions & 1 deletion ech/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package quic
import (
"bytes"
"context"
stdTLS "crypto/tls"
"errors"
"fmt"
"io"
Expand All @@ -11,6 +12,7 @@ import (
"sync"
"sync/atomic"
"time"
"unsafe"

"github.com/sagernet/cloudflare-tls"
"github.com/sagernet/quic-go/congestion"
Expand Down Expand Up @@ -679,7 +681,9 @@ func (s *connection) ConnectionState() ConnectionState {
s.connStateMutex.Lock()
defer s.connStateMutex.Unlock()
cs := s.cryptoStreamHandler.ConnectionState()
s.connState.TLS = cs.ConnectionState
// s.connState.TLS = cs.ConnectionState
s.connState.TLS = *(*stdTLS.ConnectionState)(unsafe.Pointer(&cs.ConnectionState))
s.connState.ExportKeyingMaterial = cs.ConnectionState.ExportKeyingMaterial
s.connState.Used0RTT = cs.Used0RTT
return s.connState
}
Expand Down
2 changes: 2 additions & 0 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@ type ConnectionState struct {
Used0RTT bool
// Version is the QUIC version of the QUIC connection.
Version VersionNumber

ExportKeyingMaterial func(label string, context []byte, length int) ([]byte, error)
}

0 comments on commit 631da08

Please sign in to comment.