• Michael Schurter's avatar
    core: add limits to unauthorized connections · e3e1f5cb
    Michael Schurter authored
    Introduce limits to prevent unauthorized users from exhausting all
    ephemeral ports on agents:
    
     * `{https,rpc}_handshake_timeout`
     * `{http,rpc}_max_conns_per_client`
    
    The handshake timeout closes connections that have not completed the TLS
    handshake by the deadline (5s by default). For RPC connections this
    timeout also separately applies to first byte being read so RPC
    connections with TLS enabled have `rpc_handshake_time * 2` as their
    deadline.
    
    The connection limit per client prevents a single remote TCP peer from
    exhausting all ephemeral ports. The default is 100, but can be lowered
    to a minimum of 26. Since streaming RPC connections create a new TCP
    connection (until MultiplexV2 is used), 20 connections are reserved for
    Raft and non-streaming RPCs to prevent connection exhaustion due to
    streaming RPCs.
    
    All limits are configurable and may be disabled by setting them to `0`.
    
    This also includes a fix that closes connections that attempt to create
    TLS RPC co...
    e3e1f5cb