Fix conflict between quic drop and udp port filter

This commit is contained in:
Vadim Vetrov
2024-12-27 19:31:19 +03:00
parent 123c87a24d
commit bc345ed6d4

34
quic.c
View File

@@ -43,7 +43,7 @@ int quic_parse_data(uint8_t *raw_payload, uint32_t raw_payload_len,
uint32_t left_len = raw_payload_len - sizeof(struct quic_lhdr); uint32_t left_len = raw_payload_len - sizeof(struct quic_lhdr);
uint8_t *cur_rawptr = raw_payload + sizeof(struct quic_lhdr); uint8_t *cur_rawptr = raw_payload + sizeof(struct quic_lhdr);
if (!nqch->fixed) { if (!nqch->fixed) {
lgtrace_addp("quic fixed uset"); lgtrace_addp("quic fixed unset");
return -EPROTO; return -EPROTO;
} }
@@ -281,28 +281,30 @@ int detect_udp_filtered(const struct section_config_t *section,
&quic_raw_payload, &quic_raw_plen); &quic_raw_payload, &quic_raw_plen);
if (ret < 0) { if (ret < 0) {
lgtrace_addp("undefined type"); lgtrace_addp("QUIC undefined type");
goto skip; goto match_port;
} }
lgtrace_addp("QUIC detected"); lgtrace_addp("QUIC detected");
goto approve; uint8_t qtype = qch->type;
if (qch->version == QUIC_V1)
qtype = quic_convtype_v1(qtype);
else if (qch->version == QUIC_V2)
qtype = quic_convtype_v2(qtype);
// uint8_t qtype = qch->type; if (qtype != QUIC_INITIAL_TYPE) {
// if (qch->version == QUIC_V1) lgtrace_addp("QUIC message type: %d", qtype);
// qtype = quic_convtype_v1(qtype); goto match_port;
// else if (qch->version == QUIC_V2) }
// qtype = quic_convtype_v2(qtype);
// lgtrace_addp("QUIC initial message");
// if (qtype != QUIC_INITIAL_TYPE) {
// lgtrace_addp("quic message type: %d", qtype); goto approve;
// goto accept_quic;
// }
//
// lgtrace_addp("quic initial message");
} }
match_port:
for (int i = 0; i < section->udp_dport_range_len; i++) { for (int i = 0; i < section->udp_dport_range_len; i++) {
struct udp_dport_range crange = section->udp_dport_range[i]; struct udp_dport_range crange = section->udp_dport_range[i];
if (udp_dport >= crange.start && udp_dport <= crange.end) { if (udp_dport >= crange.start && udp_dport <= crange.end) {