[PR #3460] [MERGED] xtcp: when connection timeout occurs, support fallback to STCP #4753

Closed
opened 2026-05-05 14:48:04 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/3460
Author: @fatedier
Created: 5/29/2023
Status: Merged
Merged: 5/30/2023
Merged by: @fatedier

Base: devHead: fallback


📝 Commits (1)

  • bbbbd24 xtcp: when connection timeout occurs, support fallback to STCP

📊 Changes

16 files changed (+230 additions, -68 deletions)

View changed files

📝 client/service.go (+4 -2)
📝 client/visitor/stcp.go (+19 -5)
📝 client/visitor/sudp.go (+1 -0)
📝 client/visitor/visitor.go (+20 -0)
📝 client/visitor/visitor_manager.go (+24 -12)
📝 client/visitor/xtcp.go (+51 -9)
📝 cmd/frpc/sub/root.go (+3 -3)
📝 conf/frpc_full.ini (+6 -0)
📝 pkg/config/client_test.go (+4 -3)
📝 pkg/config/visitor.go (+19 -9)
📝 pkg/config/visitor_test.go (+4 -3)
📝 pkg/nathole/analysis.go (+15 -15)
📝 pkg/nathole/classify.go (+6 -5)
📝 pkg/nathole/nathole.go (+1 -1)
📝 test/e2e/basic/basic.go (+1 -1)
test/e2e/basic/xtcp.go (+52 -0)

📄 Description

Summary

🤖 Generated by Copilot at 0d7862a

This pull request adds a new feature of visitor-to-visitor connection redirection and fallback for STCP and XTCP proxies. It also fixes some bugs and improves the performance and reliability of the NAT hole punching process. It refactors some code, adds comments and documentation, and updates the configuration and test files accordingly.

WHY

Walkthrough

🤖 Generated by Copilot at 0d7862a

  • Add a feature of not binding to the port and only receiving connections redirected from other visitors for stcp and xtcp visitors (link, link, link, link, link, link)
  • Add a feature of falling back to another visitor if the tunnel opening fails within a timeout for xtcp visitors (link, link, link, link, link, link, link, link, link, link)
  • Add a feature of transferring connections from other visitors to the visitor and a function to do so in the visitor manager (link, link, link, link, link, link, link, link, link, link)
  • Fix a bug that causes false positive detection of regular ports change and affects the hole punching process for xtcp visitors (link, link)
  • Improve the success rate and performance of the hole punching process for xtcp visitors by changing the send delays and ports range numbers (link, link, link)
  • Avoid resource leaks and ensure graceful shutdown by closing the internal listener and the base listener for sudp and stcp visitors and closing all the visitors and the stop channel in the visitor manager (link, link)
  • Avoid concurrent access and nil pointer errors by adding a mutex lock and a condition to check if the cancel function is not nil before calling it in the xtcp visitor (link)
  • Avoid timeout errors and flaky tests by changing the request timeout from 5 to 10 seconds in the basic test case (link)
  • Add a new test case for the feature of falling back to another visitor if the tunnel opening fails within a timeout in the test/e2e/basic/xtcp.go file (link)
  • Improve the code style and readability by removing empty lines in the pkg/config/visitor.go file (link, link)

🔄 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/fatedier/frp/pull/3460 **Author:** [@fatedier](https://github.com/fatedier) **Created:** 5/29/2023 **Status:** ✅ Merged **Merged:** 5/30/2023 **Merged by:** [@fatedier](https://github.com/fatedier) **Base:** `dev` ← **Head:** `fallback` --- ### 📝 Commits (1) - [`bbbbd24`](https://github.com/fatedier/frp/commit/bbbbd24a3ccbe786a0df886fa15dd0d016b4e0d9) xtcp: when connection timeout occurs, support fallback to STCP ### 📊 Changes **16 files changed** (+230 additions, -68 deletions) <details> <summary>View changed files</summary> 📝 `client/service.go` (+4 -2) 📝 `client/visitor/stcp.go` (+19 -5) 📝 `client/visitor/sudp.go` (+1 -0) 📝 `client/visitor/visitor.go` (+20 -0) 📝 `client/visitor/visitor_manager.go` (+24 -12) 📝 `client/visitor/xtcp.go` (+51 -9) 📝 `cmd/frpc/sub/root.go` (+3 -3) 📝 `conf/frpc_full.ini` (+6 -0) 📝 `pkg/config/client_test.go` (+4 -3) 📝 `pkg/config/visitor.go` (+19 -9) 📝 `pkg/config/visitor_test.go` (+4 -3) 📝 `pkg/nathole/analysis.go` (+15 -15) 📝 `pkg/nathole/classify.go` (+6 -5) 📝 `pkg/nathole/nathole.go` (+1 -1) 📝 `test/e2e/basic/basic.go` (+1 -1) ➕ `test/e2e/basic/xtcp.go` (+52 -0) </details> ### 📄 Description ### Summary <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at 0d7862a</samp> This pull request adds a new feature of visitor-to-visitor connection redirection and fallback for STCP and XTCP proxies. It also fixes some bugs and improves the performance and reliability of the NAT hole punching process. It refactors some code, adds comments and documentation, and updates the configuration and test files accordingly. ### WHY <!-- author to complete --> ### Walkthrough <!-- copilot:walkthrough --> ### <samp>🤖 Generated by Copilot at 0d7862a</samp> * Add a feature of not binding to the port and only receiving connections redirected from other visitors for stcp and xtcp visitors ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-47736b3efa64378c562de79bf84ff718399cdc5e41d69f3986661c57262695bfL38-R51), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-ab3060623fd2bc094ac0766bc594d8ab3b4de37fb944ad03c80bb25af0c9e486L62-R70), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-12bf97fbdf713937ce234cefa7dd9244ac8f86ca1c32e8b5af7aa8232bef5983R340-R341), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-12bf97fbdf713937ce234cefa7dd9244ac8f86ca1c32e8b5af7aa8232bef5983R360-R361), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-6ee1be2917f26b793160747c763b3b1600cee8faf4985e9147810f2e085428ebL52-R55), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-6ee1be2917f26b793160747c763b3b1600cee8faf4985e9147810f2e085428ebL137-R144)) * Add a feature of falling back to another visitor if the tunnel opening fails within a timeout for xtcp visitors ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-ab3060623fd2bc094ac0766bc594d8ab3b4de37fb944ad03c80bb25af0c9e486L142-R165), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-ab3060623fd2bc094ac0766bc594d8ab3b4de37fb944ad03c80bb25af0c9e486L148-R190), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-ab3060623fd2bc094ac0766bc594d8ab3b4de37fb944ad03c80bb25af0c9e486L174-R214), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-ab3060623fd2bc094ac0766bc594d8ab3b4de37fb944ad03c80bb25af0c9e486R228-R229), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-12bf97fbdf713937ce234cefa7dd9244ac8f86ca1c32e8b5af7aa8232bef5983R370-R371), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-b1a1396357f897f16a777d4b67e3b5e0b84766e9cf8a6a8d978df2cc72ca115cL664-R667), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-6ee1be2917f26b793160747c763b3b1600cee8faf4985e9147810f2e085428ebL66-R74), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-6ee1be2917f26b793160747c763b3b1600cee8faf4985e9147810f2e085428ebL271-R278), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-6ee1be2917f26b793160747c763b3b1600cee8faf4985e9147810f2e085428ebR300-R302), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-a8c5c4f05278dbcedb060efa40217e0412e893822a53cfe6fd144cc81a0be764R1-R52)) * Add a feature of transferring connections from other visitors to the visitor and a function to do so in the visitor manager ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-47736b3efa64378c562de79bf84ff718399cdc5e41d69f3986661c57262695bfL59-R73), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-abbc6c05d8cef7aefa7cbc0547129ce17a8fbdbc91fb00ee62c7b87a10f4ace3R31), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-abbc6c05d8cef7aefa7cbc0547129ce17a8fbdbc91fb00ee62c7b87a10f4ace3R40), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-abbc6c05d8cef7aefa7cbc0547129ce17a8fbdbc91fb00ee62c7b87a10f4ace3L44-R50), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-abbc6c05d8cef7aefa7cbc0547129ce17a8fbdbc91fb00ee62c7b87a10f4ace3L72-R97), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-85182a35b298e78d303ed36cccd8234812f942d76792932999d640e1948fc696R19), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-85182a35b298e78d303ed36cccd8234812f942d76792932999d640e1948fc696L37-R38), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-85182a35b298e78d303ed36cccd8234812f942d76792932999d640e1948fc696L86-R104), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-85182a35b298e78d303ed36cccd8234812f942d76792932999d640e1948fc696L142-R164), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-ab3060623fd2bc094ac0766bc594d8ab3b4de37fb944ad03c80bb25af0c9e486L92-R110)) * Fix a bug that causes false positive detection of regular ports change and affects the hole punching process for xtcp visitors ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-60e3e39f57fb49d2af363f6207f5364964bef106e4c8c1fc71718d947a813941L88-L92), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-60e3e39f57fb49d2af363f6207f5364964bef106e4c8c1fc71718d947a813941R102-R107)) * Improve the success rate and performance of the hole punching process for xtcp visitors by changing the send delays and ports range numbers ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-9edd9ae649401607046f55d682d6afb7fc0d915dc2d2d306bd6dc5f1d2c7d52dL66-R79), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-9edd9ae649401607046f55d682d6afb7fc0d915dc2d2d306bd6dc5f1d2c7d52dL101-R115), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-93ecd74b16624b460b1da47b7e21f0fa2fd4c7ed6098412049beaa66760c0627L387-R387)) * Avoid resource leaks and ensure graceful shutdown by closing the internal listener and the base listener for sudp and stcp visitors and closing all the visitors and the stop channel in the visitor manager ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-d02ddc4b655b53c915b7f4fb430bd05a97df1799ac1d281e654cb457373b5f58R257), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-85182a35b298e78d303ed36cccd8234812f942d76792932999d640e1948fc696L142-R164)) * Avoid concurrent access and nil pointer errors by adding a mutex lock and a condition to check if the cancel function is not nil before calling it in the xtcp visitor ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-ab3060623fd2bc094ac0766bc594d8ab3b4de37fb944ad03c80bb25af0c9e486L77-R85)) * Avoid timeout errors and flaky tests by changing the request timeout from 5 to 10 seconds in the basic test case ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-198c426913c63e51585ac1793ca15e8e195cf8a0a72ba93e9b12d2f6acd9fa44L379-R379)) * Add a new test case for the feature of falling back to another visitor if the tunnel opening fails within a timeout in the `test/e2e/basic/xtcp.go` file ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-a8c5c4f05278dbcedb060efa40217e0412e893822a53cfe6fd144cc81a0be764R1-R52)) * Improve the code style and readability by removing empty lines in the `pkg/config/visitor.go` file ([link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-6ee1be2917f26b793160747c763b3b1600cee8faf4985e9147810f2e085428ebL158), [link](https://github.com/fatedier/frp/pull/3460/files?diff=unified&w=0#diff-6ee1be2917f26b793160747c763b3b1600cee8faf4985e9147810f2e085428ebL172)) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 14:48:04 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#4753
No description provided.