mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-27 20:52:40 +03:00
Improve QUIC sniffer
This commit is contained in:
@@ -9,16 +9,17 @@ import (
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
)
|
||||
|
||||
func STUNMessage(ctx context.Context, packet []byte) (*adapter.InboundContext, error) {
|
||||
func STUNMessage(_ context.Context, metadata *adapter.InboundContext, packet []byte) error {
|
||||
pLen := len(packet)
|
||||
if pLen < 20 {
|
||||
return nil, os.ErrInvalid
|
||||
return os.ErrInvalid
|
||||
}
|
||||
if binary.BigEndian.Uint32(packet[4:8]) != 0x2112A442 {
|
||||
return nil, os.ErrInvalid
|
||||
return os.ErrInvalid
|
||||
}
|
||||
if len(packet) < 20+int(binary.BigEndian.Uint16(packet[2:4])) {
|
||||
return nil, os.ErrInvalid
|
||||
return os.ErrInvalid
|
||||
}
|
||||
return &adapter.InboundContext{Protocol: C.ProtocolSTUN}, nil
|
||||
metadata.Protocol = C.ProtocolSTUN
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user