Skip to content

Added TCP support to vnet#375

Open
sirzooro wants to merge 1 commit into
pion:mainfrom
sirzooro:tcp_support
Open

Added TCP support to vnet#375
sirzooro wants to merge 1 commit into
pion:mainfrom
sirzooro:tcp_support

Conversation

@sirzooro

Copy link
Copy Markdown
Contributor

Added TCP support to vnet. Github Copilot/GPT-5.2 did a good job :)

Ref: #27

@codecov

codecov Bot commented Jan 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.33209% with 191 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.37%. Comparing base (a4a04ed) to head (3120365).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
vnet/net.go 58.69% 49 Missing and 27 partials ⚠️
vnet/tcp_conn.go 79.86% 44 Missing and 15 partials ⚠️
vnet/tcp_listener.go 65.82% 16 Missing and 11 partials ⚠️
vnet/nat.go 85.59% 10 Missing and 7 partials ⚠️
vnet/tcp_map.go 90.90% 9 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #375      +/-   ##
==========================================
- Coverage   84.72%   83.37%   -1.35%     
==========================================
  Files          38       41       +3     
  Lines        3122     3831     +709     
==========================================
+ Hits         2645     3194     +549     
- Misses        347      446      +99     
- Partials      130      191      +61     
Flag Coverage Δ
go 83.37% <76.33%> (-1.35%) ⬇️

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.

Comment thread vnet/tcp_conn.go
@sirzooro sirzooro force-pushed the tcp_support branch 11 times, most recently from 25aba74 to fb434b0 Compare January 15, 2026 06:11
@sirzooro sirzooro requested a review from Copilot January 15, 2026 06:15

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 adds TCP support to the vnet package, implementing virtual TCP connections, listeners, NAT translation, and comprehensive test coverage. The implementation includes TCP connection state machine, handshake logic, data transfer with ACK mechanism, and integration with the existing virtual network infrastructure.

Changes:

  • Added TCP connection (TCPConn) and listener (TCPListener) implementations with full handshake and state management
  • Extended NAT to support TCP translation for both NAPT and 1:1 NAT modes
  • Added comprehensive test coverage for TCP functionality including connection tests, NAT behavior tests, and integration tests

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
vnet/tcp_conn.go Core TCP connection implementation with state machine, handshake, read/write operations
vnet/tcp_listener.go TCP listener implementation for accepting incoming connections
vnet/tcp_map.go Port mapping structures for TCP listeners and connections
vnet/tcp_test.go Integration test for TCP dial/listen functionality
vnet/tcp_conn_test.go Unit tests for TCP connection behavior
vnet/tcp_nat_test.go Comprehensive NAT behavior tests for TCP
vnet/tcp_map_test.go Unit tests for TCP mapping structures
vnet/net.go Extended Net to support TCP operations, added constants and routing logic
vnet/nat.go Extended NAT translator to support TCP in addition to UDP
vnet/chunk.go Enhanced TCP chunk structure with sequence/ACK numbers
vnet/net_test.go Added TCP loopback and dial tests
vnet/chunk_test.go Updated test to use tcp constant
vnet/errors.go Added nolint directive for single-use function
vnet/udpproxy_direct_test.go Updated to use network constants instead of string literals

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

Comment thread vnet/udpproxy_direct_test.go
Comment thread vnet/udpproxy_direct_test.go
Comment thread vnet/tcp_nat_test.go Outdated
Comment thread vnet/tcp_conn_test.go Outdated
Comment thread vnet/tcp_conn_test.go Outdated
Comment thread vnet/nat.go Outdated
Comment thread vnet/nat.go Outdated
@sirzooro sirzooro force-pushed the tcp_support branch 5 times, most recently from 1078635 to 29d1733 Compare January 16, 2026 07:04
@sirzooro sirzooro force-pushed the tcp_support branch 2 times, most recently from 096d660 to a8ed0a7 Compare March 25, 2026 15:23
@sirzooro sirzooro force-pushed the tcp_support branch 2 times, most recently from 8ade08d to 700841b Compare July 5, 2026 08:16
@sirzooro

sirzooro commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

I am going to split this big PR into few smaller ones, to make review easier.

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