|
|
@ -1,6 +1,7 @@ |
|
|
|
package quic |
|
|
|
package quic |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"context" |
|
|
|
"crypto" |
|
|
|
"crypto" |
|
|
|
"crypto/aes" |
|
|
|
"crypto/aes" |
|
|
|
"crypto/tls" |
|
|
|
"crypto/tls" |
|
|
@ -46,7 +47,18 @@ var ( |
|
|
|
errNotQuicInitial = errors.New("not initial packet") |
|
|
|
errNotQuicInitial = errors.New("not initial packet") |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func SniffQUIC(b []byte) (*SniffHeader, error) { |
|
|
|
func SniffQUIC(b []byte) (resultReturn *SniffHeader, errorReturn error) { |
|
|
|
|
|
|
|
// In extremely rare cases, this sniffer may cause slice error
|
|
|
|
|
|
|
|
// and we set recover() here to prevent crash.
|
|
|
|
|
|
|
|
// TODO: Thoroughly fix this panic
|
|
|
|
|
|
|
|
defer func() { |
|
|
|
|
|
|
|
if r := recover(); r != nil { |
|
|
|
|
|
|
|
errors.LogError(context.Background(), "Failed to sniff QUIC: ", r) |
|
|
|
|
|
|
|
resultReturn = nil |
|
|
|
|
|
|
|
errorReturn = common.ErrNoClue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
// Crypto data separated across packets
|
|
|
|
// Crypto data separated across packets
|
|
|
|
cryptoLen := 0 |
|
|
|
cryptoLen := 0 |
|
|
|
cryptoData := bytespool.Alloc(int32(len(b))) |
|
|
|
cryptoData := bytespool.Alloc(int32(len(b))) |
|
|
|