[PR #3381] [MERGED] frpc: support nathole discover #4735

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

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/3381
Author: @fatedier
Created: 3/30/2023
Status: Merged
Merged: 3/30/2023
Merged by: @fatedier

Base: devHead: nathole


📝 Commits (1)

  • 4d5bc76 frpc: support nathole discover

📊 Changes

13 files changed (+520 additions, -16 deletions)

View changed files

cmd/frpc/sub/nathole.go (+86 -0)
📝 conf/frpc_full.ini (+7 -0)
📝 go.mod (+4 -2)
📝 go.sum (+22 -3)
📝 pkg/config/client.go (+6 -0)
📝 pkg/config/client_test.go (+1 -0)
📝 pkg/msg/ctl.go (+4 -0)
📝 pkg/msg/msg.go (+14 -0)
pkg/nathole/classify.go (+74 -0)
pkg/nathole/discovery.go (+192 -0)
📝 pkg/nathole/nathole.go (+61 -10)
pkg/nathole/utils.go (+48 -0)
📝 server/service.go (+1 -1)

📄 Description

Summary

🤖 Generated by Copilot at 1cf2a26

This pull request adds nathole discovery, a feature that allows clients to communicate through NAT devices without port forwarding, to the frp project. It updates the dependencies, configuration, message types, and controller logic for nathole discovery. It also adds a new subcommand for frpc to discover nathole information and some utility and test functions. The main files affected are go.mod, pkg/config/client.go, pkg/msg/msg.go, pkg/nathole/nathole.go, cmd/frpc/sub/nathole.go, and server/service.go.

Walkthrough

🤖 Generated by Copilot at 1cf2a26

  • Implement a subcommand for frpc to discover nathole information by frps and stun server (link)
  • Add two new configuration options for specifying the server udp port and the stun server for nathole discovery (link, link, link, link)
  • Add two new message types and structs for nathole binding and binding response (link, link, link)
  • Add a function to pack a message into a byte slice (link)
  • Implement a controller for handling nathole messages and sessions (link, link, link, link, link, link, link, link)
  • Implement a function to classify the NAT type and behavior by given addresses (link)
  • Implement a function to discover the external addresses by frps and stun server (link)
  • Implement two utility functions for encoding and decoding nathole messages with the encryption key (link)
  • Pass the token as the encryption key to the nathole controller in server/service.go (link)
  • Update the dependencies of github.com/fatedier/golib and github.com/stretchr/testify to newer versions (link, link)
  • Add a new dependency of github.com/pion/stun for using the stun protocol for nathole discovery (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/3381 **Author:** [@fatedier](https://github.com/fatedier) **Created:** 3/30/2023 **Status:** ✅ Merged **Merged:** 3/30/2023 **Merged by:** [@fatedier](https://github.com/fatedier) **Base:** `dev` ← **Head:** `nathole` --- ### 📝 Commits (1) - [`4d5bc76`](https://github.com/fatedier/frp/commit/4d5bc7620ff413ea2cbd4726e542a7bde304be4d) frpc: support nathole discover ### 📊 Changes **13 files changed** (+520 additions, -16 deletions) <details> <summary>View changed files</summary> ➕ `cmd/frpc/sub/nathole.go` (+86 -0) 📝 `conf/frpc_full.ini` (+7 -0) 📝 `go.mod` (+4 -2) 📝 `go.sum` (+22 -3) 📝 `pkg/config/client.go` (+6 -0) 📝 `pkg/config/client_test.go` (+1 -0) 📝 `pkg/msg/ctl.go` (+4 -0) 📝 `pkg/msg/msg.go` (+14 -0) ➕ `pkg/nathole/classify.go` (+74 -0) ➕ `pkg/nathole/discovery.go` (+192 -0) 📝 `pkg/nathole/nathole.go` (+61 -10) ➕ `pkg/nathole/utils.go` (+48 -0) 📝 `server/service.go` (+1 -1) </details> ### 📄 Description ### Summary <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at 1cf2a26</samp> This pull request adds nathole discovery, a feature that allows clients to communicate through NAT devices without port forwarding, to the frp project. It updates the dependencies, configuration, message types, and controller logic for nathole discovery. It also adds a new subcommand for frpc to discover nathole information and some utility and test functions. The main files affected are `go.mod`, `pkg/config/client.go`, `pkg/msg/msg.go`, `pkg/nathole/nathole.go`, `cmd/frpc/sub/nathole.go`, and `server/service.go`. ### Walkthrough <!-- copilot:walkthrough --> ### <samp>🤖 Generated by Copilot at 1cf2a26</samp> * Implement a subcommand for frpc to discover nathole information by frps and stun server ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-5ac4ee81516dfc6b3f0a0abd3e447ee4a2d03d59a7a62be497d7dbf208c3da0dR1-R86)) * Add two new configuration options for specifying the server udp port and the stun server for nathole discovery ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-12bf97fbdf713937ce234cefa7dd9244ac8f86ca1c32e8b5af7aa8232bef5983R13-R19), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-fd40de974f57bca0b0360aa388aae106227b36be701f6c5fedbd511a6f39a062R44-R48), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-fd40de974f57bca0b0360aa388aae106227b36be701f6c5fedbd511a6f39a062R180), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-b1a1396357f897f16a777d4b67e3b5e0b84766e9cf8a6a8d978df2cc72ca115cR263)) * Add two new message types and structs for nathole binding and binding response ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-d06db243b3da859f1e0ad2aa35dcdb7d050f1d401faad8668be9ff336165b628R40-R41), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-d06db243b3da859f1e0ad2aa35dcdb7d050f1d401faad8668be9ff336165b628R63-R64), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-d06db243b3da859f1e0ad2aa35dcdb7d050f1d401faad8668be9ff336165b628R200-R209)) * Add a function to pack a message into a byte slice ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-2a399ae2c8ffc934c2fb871cec87586049daed7aedc6c278d1f4246170e8d1adR45-R48)) * Implement a controller for handling nathole messages and sessions ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-93ecd74b16624b460b1da47b7e21f0fa2fd4c7ed6098412049beaa66760c0627R1-R14), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-93ecd74b16624b460b1da47b7e21f0fa2fd4c7ed6098412049beaa66760c0627R24), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-93ecd74b16624b460b1da47b7e21f0fa2fd4c7ed6098412049beaa66760c0627R36-R40), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-93ecd74b16624b460b1da47b7e21f0fa2fd4c7ed6098412049beaa66760c0627L32-R56), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-93ecd74b16624b460b1da47b7e21f0fa2fd4c7ed6098412049beaa66760c0627L45-R69), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-93ecd74b16624b460b1da47b7e21f0fa2fd4c7ed6098412049beaa66760c0627L75-R114), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-93ecd74b16624b460b1da47b7e21f0fa2fd4c7ed6098412049beaa66760c0627L92-R120), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-93ecd74b16624b460b1da47b7e21f0fa2fd4c7ed6098412049beaa66760c0627R133-R155)) * Implement a function to classify the NAT type and behavior by given addresses ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-60e3e39f57fb49d2af363f6207f5364964bef106e4c8c1fc71718d947a813941R1-R74)) * Implement a function to discover the external addresses by frps and stun server ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-44722a17206af87db167e83e9a7dd3b726ca21e5a6b47e6e9f5103e498163013R1-R193)) * Implement two utility functions for encoding and decoding nathole messages with the encryption key ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-181aa632a4a44ec627ca2c893ab904ffbd3b63a6615f888cb6d11c8a6ec4781eR1-R48)) * Pass the token as the encryption key to the nathole controller in `server/service.go` ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-7cd1def768b5bcc52b79dd84b45271a4f4c0604d574564e6b60e8f2770691394L296-R296)) * Update the dependencies of `github.com/fatedier/golib` and `github.com/stretchr/testify` to newer versions ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6L9-R9), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6L23-R24)) * Add a new dependency of `github.com/pion/stun` for using the stun protocol for nathole discovery ([link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R18), [link](https://github.com/fatedier/frp/pull/3381/files?diff=unified&w=0#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R52)) --- <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:47:44 -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#4735
No description provided.