[PR #4943] [CLOSED] Interface Binding Support for frpc #5083

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

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/4943
Author: @jeet0733
Created: 8/18/2025
Status: Closed

Base: devHead: feature/interface-binding-support


📝 Commits (1)

  • 07c8bb7 Interface Binding Support for frpc

📊 Changes

11 files changed (+434 additions, -6 deletions)

View changed files

📝 README.md (+35 -0)
📝 client/connector.go (+22 -2)
📝 conf/frpc_full_example.toml (+8 -1)
📝 conf/legacy/frpc_legacy_full.ini (+8 -1)
📝 pkg/config/flags.go (+2 -0)
📝 pkg/config/legacy/client.go (+7 -1)
📝 pkg/config/legacy/conversion.go (+1 -0)
📝 pkg/config/v1/client.go (+6 -1)
📝 pkg/config/v1/validation/client.go (+28 -0)
pkg/util/net/interface.go (+206 -0)
pkg/util/net/interface_test.go (+111 -0)

📄 Description

What does this PR do?

This PR adds network interface binding support to frpc, allowing users to specify which network interface to use when connecting to the frps server. This is particularly useful for multi-network systems or when routing traffic through specific network paths.

Changes Made

New Features

  • Interface Binding Logic (pkg/util/net/interface.go): Core functionality for resolving interface names to IP addresses and auto-detection
  • Interface Validation (pkg/util/net/interface.go): Validates interface names and IP addresses with security checks
  • Enhanced Connector (client/connector.go): Integrates interface binding with connection establishment
  • Configuration Support (pkg/config/v1/client.go): Added connectServerInterface field for TOML configuration
  • Command Line Flags (pkg/config/flags.go): Added --bind-interface and --bind-ip flags
  • Legacy Support (pkg/config/legacy/client.go): Backward compatibility with INI configuration format
  • Validation Logic (pkg/config/v1/validation/client.go): Ensures mutual exclusivity and validates interface names

Enhancements

  • Interface Name Binding: Bind to specific network interfaces (e.g., "eth0", "wlan0", "Ethernet", "Wi-Fi")
  • Cross-Platform Support: Works on Linux, macOS, and Windows
  • Protocol Compatibility: Supports TCP, WebSocket, HTTP, HTTPS, and QUIC protocols
  • Security: Loopback protection and interface name validation

Documentation

  • README.md: Added interface binding documentation and examples
  • Configuration Guide: Included examples for TOML and INI

Configuration Example

TOML Configuration

# frpc.toml
serverAddr = "x.x.x.x"
serverPort = 7000

[transport]
# Bind to specific interface
connectServerInterface = "eth0"

# Or use auto-detection
# connectServerInterface = "auto"

# Or bind to specific IP (existing feature)
# connectServerLocalIP = "192.168.1.100"

Command Line

# Bind to specific interface
./frpc --bind-interface eth0 -c frpc.toml

# Auto-detect interface
./frpc --bind-interface auto -c frpc.toml

# Bind to specific IP
./frpc --bind-ip 192.168.1.100 -c frpc.toml

Legacy INI Configuration

[common]
server_addr = x.x.x.x
server_port = 7000
connect_server_interface = eth0

Benefits

  • Multi-Network Systems: Route traffic through specific interfaces or choose optimal network paths for different scenarios
  • Backward Compatibility: Maintains existing connectServerLocalIP functionality
  • Security: Loopback protection and comprehensive input validation

Testing

All existing tests pass
Code formatting and linting checks pass
Interface name validation tests
IP address validation tests
Auto-detection functionality tests
Cross-platform compatibility verified
Race condition testing completed

Related Issues

  • Closes #4937 - Enhanced Interface Binding Support
  • Closes #3376 - Specify source interface for the client

🔄 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/4943 **Author:** [@jeet0733](https://github.com/jeet0733) **Created:** 8/18/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feature/interface-binding-support` --- ### 📝 Commits (1) - [`07c8bb7`](https://github.com/fatedier/frp/commit/07c8bb74ec8a5542ff97be7953d3d111a2e175dd) Interface Binding Support for frpc ### 📊 Changes **11 files changed** (+434 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+35 -0) 📝 `client/connector.go` (+22 -2) 📝 `conf/frpc_full_example.toml` (+8 -1) 📝 `conf/legacy/frpc_legacy_full.ini` (+8 -1) 📝 `pkg/config/flags.go` (+2 -0) 📝 `pkg/config/legacy/client.go` (+7 -1) 📝 `pkg/config/legacy/conversion.go` (+1 -0) 📝 `pkg/config/v1/client.go` (+6 -1) 📝 `pkg/config/v1/validation/client.go` (+28 -0) ➕ `pkg/util/net/interface.go` (+206 -0) ➕ `pkg/util/net/interface_test.go` (+111 -0) </details> ### 📄 Description # What does this PR do? This PR adds network interface binding support to frpc, allowing users to specify which network interface to use when connecting to the frps server. This is particularly useful for multi-network systems or when routing traffic through specific network paths. # Changes Made ## New Features - **Interface Binding Logic** (`pkg/util/net/interface.go`): Core functionality for resolving interface names to IP addresses and auto-detection - **Interface Validation** (`pkg/util/net/interface.go`): Validates interface names and IP addresses with security checks - **Enhanced Connector** (`client/connector.go`): Integrates interface binding with connection establishment - **Configuration Support** (`pkg/config/v1/client.go`): Added connectServerInterface field for TOML configuration - **Command Line Flags** (`pkg/config/flags.go`): Added `--bind-interface` and `--bind-ip` flags - **Legacy Support** (`pkg/config/legacy/client.go`): Backward compatibility with INI configuration format - **Validation Logic** (`pkg/config/v1/validation/client.go`): Ensures mutual exclusivity and validates interface names ## Enhancements - **Interface Name Binding**: Bind to specific network interfaces (e.g., "eth0", "wlan0", "Ethernet", "Wi-Fi") - **Cross-Platform Support**: Works on Linux, macOS, and Windows - **Protocol Compatibility**: Supports TCP, WebSocket, HTTP, HTTPS, and QUIC protocols - **Security**: Loopback protection and interface name validation ## Documentation - **README.md**: Added interface binding documentation and examples - **Configuration Guide**: Included examples for TOML and INI # Configuration Example ## TOML Configuration ```toml # frpc.toml serverAddr = "x.x.x.x" serverPort = 7000 [transport] # Bind to specific interface connectServerInterface = "eth0" # Or use auto-detection # connectServerInterface = "auto" # Or bind to specific IP (existing feature) # connectServerLocalIP = "192.168.1.100" ``` ## Command Line ```bash # Bind to specific interface ./frpc --bind-interface eth0 -c frpc.toml # Auto-detect interface ./frpc --bind-interface auto -c frpc.toml # Bind to specific IP ./frpc --bind-ip 192.168.1.100 -c frpc.toml ``` ## Legacy INI Configuration ```ini [common] server_addr = x.x.x.x server_port = 7000 connect_server_interface = eth0 ``` # Benefits - **Multi-Network Systems**: Route traffic through specific interfaces or choose optimal network paths for different scenarios - **Backward Compatibility**: Maintains existing connectServerLocalIP functionality - **Security**: Loopback protection and comprehensive input validation # Testing ✅ All existing tests pass ✅ Code formatting and linting checks pass ✅ Interface name validation tests ✅ IP address validation tests ✅ Auto-detection functionality tests ✅ Cross-platform compatibility verified ✅ Race condition testing completed # Related Issues - Closes #[4937](https://github.com/fatedier/frp/issues/4937) - Enhanced Interface Binding Support - Closes #[3376](https://github.com/fatedier/frp/issues/3376) - Specify source interface for the client --- <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:54:22 -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#5083
No description provided.