18 Commits
Author SHA1 Message Date
9seconds b6427ee321 More idiomatic Golang 2026-03-31 15:07:01 +02:00
Alexey Dolotov 4627910238 fix: use shared idle tracker for relay connections
connIdleTimeout previously set per-direction deadlines independently.
During media downloads the client→telegram direction can be idle at the
application level while telegram→client is actively streaming data.
After IdleTimeout (default 1 min) the idle direction's ReadDeadline
fires, tearing down the entire relay and breaking media transfers.

Replace the per-direction timeout with a shared atomic timestamp that
both pump goroutines update on any successful Read or Write. When a
ReadDeadline fires on the idle direction, we check the shared tracker:
if the other direction was recently active, we retry instead of closing.
The connection is only torn down when both directions are idle for the
full timeout period.

This matches the documented IdleTimeout contract: "if we have any
message which will pass to either direction, a timer is reset."

Overhead: one atomic.Int64 (8 bytes) per connection pair, one
atomic.Store (~1 ns) per Read/Write with data, zero extra goroutines.

Fixes #423
2026-03-30 10:34:16 +03:00
Alexey Dolotov f355512aa6 fix: address staticcheck lint issues
- avoid deprecated DefaultIdleTimeout, use time.Minute directly
- simplify embedded field selectors (QF1008)
2026-03-28 22:59:32 +03:00
Alexey Dolotov 836090ebdf fix: apply idle timeout to domain fronting relay connections
Domain fronting relay (for non-Telegram traffic) had no idle timeout,
causing worker pool exhaustion under traffic spikes.

The ProxyOpts.IdleTimeout field existed but was never wired into the
proxy. Now domain fronting connections are wrapped with per-read/write
deadlines reset to the configured idle timeout (default 1m), so stale
or slowloris-style connections are reaped promptly.

Fixes #378
2026-03-28 22:47:39 +03:00
9seconds cde313b359 Add support for domain fronting proxy protocol 2026-02-24 16:44:35 +01:00
9seconds e50cee5748 Do not use unnecessary lock in connRewind 2026-02-23 10:12:25 +01:00
9seconds 36dad5a2f6 Update golangci-lint 2022-08-08 15:54:38 +03:00
9seconds ffad717829 Use CloseRead and CloseWrites 2021-12-01 10:37:31 +03:00
9seconds 585ebfeb50 Update golanci-lint 2021-04-09 14:35:04 +03:00
9seconds 463af648ce Rework events 2021-04-07 14:40:54 +03:00
9seconds bef14bd009 Add support of EventDomainFronting event 2021-03-29 11:56:05 +03:00
9seconds db8614999a Rename EventTelegramTraffic back to EventTraffic 2021-03-28 21:43:25 +03:00
9seconds bc2bd4510a Rework stats 2021-03-27 22:04:30 +03:00
9seconds bddf180575 Implement domain fronting 2021-03-26 14:45:00 +03:00
9seconds a3362c7ea4 Proxy is working in a simple mode now 2021-03-23 15:14:36 +03:00
9seconds 66c45dc83b Add obfuscated2 server handshake 2021-03-23 10:27:22 +03:00
9seconds f7c33ee333 Actually embedd connStandard into connEventTraffic 2021-03-22 18:41:54 +03:00
9seconds 42160a08fe Add EventTraffic 2021-03-22 17:54:46 +03:00