Skip to content

TUIC & hysteria2 connection stays alive for a while after traffic quota is exhausted (VLESS closes immediately) #175

Description

@mgmgnca

Describe the bug
When a client's data/traffic quota (e.g. 10 MB) is fully consumed:

  • VLESS: the user is disabled in the UI, and the VPN connection closes almost immediately.
  • TUIC: the user is disabled in the UI at the same time, but the VPN connection stays alive and usable for a noticeable period afterward before it eventually drops.

Root cause (as far as I can tell)

ConnTracker (core/tracker_conn.go) tracks one ConnectionInfo per routed stream (RoutedConnection / RoutedPacketConnection), wrapping either net.Conn (TCP) or network.PacketConn (UDP), and closes those when quota enforcement triggers CloseConnByInboundUsers (or similar).

  • For VLESS, each tracked entry maps 1:1 to the client's actual TCP socket, so closing it kills the real transport connection immediately.
  • For TUIC, the client authenticates once over a single QUIC connection, and every subsequent relayed stream (Connect/Packet) multiplexes over that already-authenticated session without re-authenticating. ConnTracker only tracks/closes these individual streams, not the underlying QUIC transport connection — so the client can keep opening new streams on the same session right after enforcement runs. The connection only actually dies later, likely once the QUIC session itself times out (idle timeout / heartbeat) or a later periodic enforcement pass happens to catch it, rather than being cut off deterministically at quota-exhaustion time.

To Reproduce
Steps to reproduce the behavior:

  1. Set a 10 MB data limit on a user.
  2. Connect via VLESS, consume the 10 MB. Observe: UI shows disabled, VPN connection closes almost immediately.
  3. Repeat with TUIC for the same limit. Observe: UI shows disabled at the same time, but the VPN connection keeps working for some time before it eventually drops.
  4. Observe the delayed disconnect on TUIC compared to VLESS.

Expected behavior
Once quota enforcement disables a user, all active connections — including TUIC — should be cut off promptly and deterministically, not just after an unpredictable delay.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions