1643d71 refactor(proxy): use context cancellation for tunnel tracking
28c65b9 fix(proxy): avoid shadowing ctx variable in pipe()
d21c09c refactor(proxy): simplify tunnel tracking with mutex-only approach
5eacbb7 fix(proxy): prevent deleting wrong tunnel in defer cleanup
390b401 Merge remote-tracking branch 'upstream/dev' into proxy-context-tunnel-tracking
📊 Changes
1 file changed (+34 additions, -51 deletions)
View changed files
📝proxy/proxy.go (+34 -51)
📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description
Replace []net.Conn slice with context + atomic counter in activeTunnel
Use errgroup.WithContext for pipe() to handle goroutine lifecycle
Use context.AfterFunc to close connections on cancellation
Fix race condition by comparing tunnel pointers instead of map lookup
UpdateLocalSNIs now cancels tunnel context instead of iterating conns
This eliminates O(n) connection removal, prevents goroutine leaks, and provides cleaner cancellation semantics.
How to test?
Internal proxy usage.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/fosrl/gerbil/pull/65
**Author:** [@LaurenceJJones](https://github.com/LaurenceJJones)
**Created:** 3/13/2026
**Status:** 🔄 Open
**Base:** `dev` ← **Head:** `proxy-context-tunnel-tracking`
---
### 📝 Commits (5)
- [`1643d71`](https://github.com/fosrl/gerbil/commit/1643d71905b0013cfdcd25c3a7fb9af4c5191eaf) refactor(proxy): use context cancellation for tunnel tracking
- [`28c65b9`](https://github.com/fosrl/gerbil/commit/28c65b950c70258f67583cca7e036588f212993a) fix(proxy): avoid shadowing ctx variable in pipe()
- [`d21c09c`](https://github.com/fosrl/gerbil/commit/d21c09c84f9e8c6a06732a2ff92ad912ff17129a) refactor(proxy): simplify tunnel tracking with mutex-only approach
- [`5eacbb7`](https://github.com/fosrl/gerbil/commit/5eacbb7239c7d1ab5ad09814ef4adcc091e9ce78) fix(proxy): prevent deleting wrong tunnel in defer cleanup
- [`390b401`](https://github.com/fosrl/gerbil/commit/390b4019985c4881fea0688092583d5674455cb7) Merge remote-tracking branch 'upstream/dev' into proxy-context-tunnel-tracking
### 📊 Changes
**1 file changed** (+34 additions, -51 deletions)
<details>
<summary>View changed files</summary>
📝 `proxy/proxy.go` (+34 -51)
</details>
### 📄 Description
## Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
## Description
- Replace []net.Conn slice with context + atomic counter in activeTunnel
- Use errgroup.WithContext for pipe() to handle goroutine lifecycle
- Use context.AfterFunc to close connections on cancellation
- Fix race condition by comparing tunnel pointers instead of map lookup
- UpdateLocalSNIs now cancels tunnel context instead of iterating conns
This eliminates O(n) connection removal, prevents goroutine leaks, and provides cleaner cancellation semantics.
## How to test?
Internal proxy usage.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/fosrl/gerbil/pull/65
Author: @LaurenceJJones
Created: 3/13/2026
Status: 🔄 Open
Base:
dev← Head:proxy-context-tunnel-tracking📝 Commits (5)
1643d71refactor(proxy): use context cancellation for tunnel tracking28c65b9fix(proxy): avoid shadowing ctx variable in pipe()d21c09crefactor(proxy): simplify tunnel tracking with mutex-only approach5eacbb7fix(proxy): prevent deleting wrong tunnel in defer cleanup390b401Merge remote-tracking branch 'upstream/dev' into proxy-context-tunnel-tracking📊 Changes
1 file changed (+34 additions, -51 deletions)
View changed files
📝
proxy/proxy.go(+34 -51)📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description
This eliminates O(n) connection removal, prevents goroutine leaks, and provides cleaner cancellation semantics.
How to test?
Internal proxy usage.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.