Add TCP connection and listener tracking maps#389
Conversation
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
TCPConnandTCPListenerstub implementations that expose addresses and otherwise returntransport.ErrNotSupported. - Added
tcpConnMapandtcpListenerMapfor 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.
d327103 to
79979b1
Compare
|
Thanks! |
New data structures for managing TCP state inside
vnet, plus the minimal type stubs they depend on.TCPConn: bare-minimum struct implementingtransport.TCPConn; holdslocAddr/remAddrand exposesLocalAddr()/RemoteAddr(). All other methods returntransport.ErrNotSupported.TCPListener: bare-minimum struct implementingtransport.TCPListener; holdslocAddrand exposesAddr(). All other methods returntransport.ErrNotSupported.tcpConnMap: thread-safe map of active TCP connections keyed by 4-tuple, withinsert,findByChunk,deleteConn,deleteByAddr, andportInUsehelpers.tcpListenerMap: thread-safe map of TCP listeners keyed by local address, withinsert,find, anddeletehelpers.Split out from #375