parseALPN extracts protocol names from ALPN extension.
(data []byte)
| 821 | |
| 822 | // parseALPN extracts protocol names from ALPN extension. |
| 823 | func parseALPN(data []byte) []string { |
| 824 | if len(data) < 2 { |
| 825 | return nil |
| 826 | } |
| 827 | |
| 828 | // List length (2 bytes) |
| 829 | offset := 2 |
| 830 | var protocols []string |
| 831 | |
| 832 | for offset < len(data) { |
| 833 | protoLen := int(data[offset]) |
| 834 | offset++ |
| 835 | if offset+protoLen > len(data) { |
| 836 | break |
| 837 | } |
| 838 | protocols = append(protocols, string(data[offset:offset+protoLen])) |
| 839 | offset += protoLen |
| 840 | } |
| 841 | |
| 842 | return protocols |
| 843 | } |
| 844 | |
| 845 | // readVarInt reads a QUIC variable-length integer. |
| 846 | func readVarInt(data []byte) (uint64, int, error) { |
no outgoing calls
no test coverage detected