Skip to content

Add TCP connection and listener tracking maps#389

Merged
sirzooro merged 1 commit into
pion:mainfrom
sirzooro:tcp_maps
Jul 14, 2026
Merged

Add TCP connection and listener tracking maps#389
sirzooro merged 1 commit into
pion:mainfrom
sirzooro:tcp_maps

Conversation

@sirzooro

@sirzooro sirzooro commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

New data structures for managing TCP state inside vnet, plus the minimal type stubs they depend on.

  • TCPConn: bare-minimum struct implementing transport.TCPConn; holds locAddr/remAddr and exposes LocalAddr()/RemoteAddr(). All other methods return transport.ErrNotSupported.
  • TCPListener: bare-minimum struct implementing transport.TCPListener; holds locAddr and exposes Addr(). All other methods return transport.ErrNotSupported.
  • tcpConnMap: thread-safe map of active TCP connections keyed by 4-tuple, with insert, findByChunk, deleteConn, deleteByAddr, and portInUse helpers.
  • tcpListenerMap: thread-safe map of TCP listeners keyed by local address, with insert, find, and delete helpers.
  • Full unit tests for both maps.

Split out from #375

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.40984% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.08%. Comparing base (55e2272) to head (766cdb0).

Files with missing lines Patch % Lines
vnet/tcp_conn.go 11.76% 30 Missing ⚠️
vnet/tcp_listener.go 20.00% 8 Missing ⚠️
vnet/tcp_map.go 94.96% 3 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #389      +/-   ##
==========================================
- Coverage   84.62%   84.08%   -0.54%     
==========================================
  Files          38       41       +3     
  Lines        3173     3356     +183     
==========================================
+ Hits         2685     2822     +137     
- Misses        355      395      +40     
- Partials      133      139       +6     
Flag Coverage Δ
go 84.08% <75.40%> (-0.54%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces initial TCP state-tracking primitives for vnet: minimal transport.TCPConn/transport.TCPListener stub types plus thread-safe maps to register, look up, and delete TCP listeners and active connections, along with unit tests to validate core behaviors.

Changes:

  • Added TCPConn and TCPListener stub implementations that expose addresses and otherwise return transport.ErrNotSupported.
  • Added tcpConnMap and tcpListenerMap for tracking TCP connections/listeners by address/tuple with concurrency protection.
  • Added unit tests covering insertion, lookup, deletion, and port-in-use checks.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
vnet/tcp_map.go Introduces TCP listener/connection tracking maps and lookup/delete helpers.
vnet/tcp_map_test.go Adds unit tests validating tcpListenerMap and tcpConnMap behaviors.
vnet/tcp_listener.go Adds minimal transport.TCPListener stub for vnet.
vnet/tcp_conn.go Adds minimal transport.TCPConn stub for vnet.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vnet/tcp_map.go
Comment thread vnet/tcp_map.go
Comment thread vnet/tcp_map_test.go
Comment thread vnet/tcp_conn.go Outdated
Comment thread vnet/tcp_conn.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread vnet/tcp_map.go Outdated
@sirzooro sirzooro force-pushed the tcp_maps branch 2 times, most recently from d327103 to 79979b1 Compare July 14, 2026 17:53
@sirzooro

Copy link
Copy Markdown
Contributor Author

Thanks!

@sirzooro sirzooro merged commit 0ccb39d into pion:main Jul 14, 2026
18 checks passed
@sirzooro sirzooro deleted the tcp_maps branch July 14, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants