folbricht / routedns

DNS stub resolver, proxy and router with support for DoT, DoH, DoQ, and DTLS
BSD 3-Clause "New" or "Revised" License
441 stars 62 forks source link

connection timeout or keepalive #382

Open mschirrmeister opened 2 months ago

mschirrmeister commented 2 months ago

Hello,

while searching for keepalive settings or a timeout option for upstream resolvers, I found this old issue https://github.com/folbricht/routedns/issues/324 which mentions a hard coded idle timeout for TCP and DoT.

I am more interested in the setting for DoH3 and DoQ. After some testing I noticed it seems to be the following.

Is this correct? At least I see a new connection via a packet capture, when I send a request after the times above.

Besides the idle timeout, do you think a keepalive setting could be useful? Maybe with an internal logic, if there is no client query for n amount of minutes, it gets turned down anyway.

folbricht commented 2 months ago

DoQ:

I looked at the different config options for quic.

HandshakeIdleTimeout is currently set to the same value as query-timeout which defaults to 2s

    // HandshakeIdleTimeout is the idle timeout before completion of the handshake.
    // If we don't receive any packet from the peer within this time, the connection attempt is aborted.
    // Additionally, if the handshake doesn't complete in twice this time, the connection attempt is also aborted.
    // If this value is zero, the timeout is set to 5 seconds.
    HandshakeIdleTimeout time.Duration

MaxIdleTimeout is not set and not currently configurable

    // MaxIdleTimeout is the maximum duration that may pass without any incoming network activity.
    // The actual value for the idle timeout is the minimum of this value and the peer's.
    // This value only applies after the handshake has completed.
    // If the timeout is exceeded, the connection is closed.
    // If this value is zero, the timeout is set to 30 seconds.
    MaxIdleTimeout time.Duration

KeepAlivePeriod is also not set and not configurable

    // KeepAlivePeriod defines whether this peer will periodically send a packet to keep the connection alive.
    // If set to 0, then no keep alive is sent. Otherwise, the keep alive is sent on that period (or at most
    // every half of MaxIdleTimeout, whichever is smaller).
    KeepAlivePeriod time.Duration

DoH3:

Has the same settings but none are set by routedns or are configurable yet.