Skip to content

Need a way to set some state while rate limiting #5013

@sukunrt

Description

@sukunrt

I'm limiting concurrent quic connections from the same IP in go-libp2p. The way we implement the limiting is to create a resource manager scope that tracks all the connection resource usage throughout the lifetime of the connection.

I want to:

  1. On receiving ClientHello, create a scope and reject the connection without handshaking if there are too many connections from the same IP.
  2. On accepting a ClientHello, when I eventually get the quic connection from Server.Accept retrieve the scope created in 1.

I can use Config.GetConfigForClient to rate limit based on IP, but there's no way to set store the scope that I can later get back after the handshake.
I can use Server.ConnContext to store the scope in the context, but the ConnContext callback has no info about remote IP.

If we add the connection context to ClientHelloInfo it'll be enough for my usecase. This change is also backwards compatible. See #5014

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions