Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

add support for multiaddr filtering #125

Merged
merged 1 commit into from
Mar 17, 2020
Merged

add support for multiaddr filtering #125

merged 1 commit into from
Mar 17, 2020

Conversation

marten-seemann
Copy link
Collaborator

Fixes #124.

When multiplexing incoming and outgoing connections on the same packet conn, quic-go expects the packet conns to be the same struct. Therefore, filters are applied for incoming and outgoing connections.

n, addr, rerr = c.PacketConn.ReadFrom(b)
// Short Header packet, see https://tools.ietf.org/html/draft-ietf-quic-invariants-07#section-4.2.
if n < 1 || b[0]&0x80 == 0 {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we ever read a partial packet and would that cause an issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle, yes. If the UDP packet is longer than b, ReadFrom will only read the packet up to len(b), the rest of the packet will be discarded. Since every QUIC packet is integrity protected, this doesn't lead to any problems, as the partial packet will simply end up undecryptable.
QUIC itself deals with the problem of fixed buffer sizes by communication a max_packet_size during the handshake, so the endpoint knows not to pack any packet that is larger than its peer's buffer.

@marten-seemann marten-seemann merged commit cfc4947 into master Mar 17, 2020
@marten-seemann marten-seemann deleted the filters branch March 17, 2020 09:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter inbound connections
2 participants