frp
Auto-generated from fatedier/frp by Mutable.ai Auto WikiRevise
frp | |
---|---|
GitHub Repository | |
Developer | fatedier |
Written in | Go |
Stars | 79k |
Watchers | 1.6k |
Created | 12/21/2015 |
Last updated | 04/04/2024 |
License | Apache License 2.0 |
Repository | fatedier/frp |
Auto Wiki | |
Revision | |
Software Version | 0.0.8Basic |
Generated from | Commit 590ccd |
Generated at | 04/04/2024 |
The FRP (Fast Reverse Proxy) repository provides a tool for exposing a local server behind a NAT or firewall to the internet. The core functionality of the FRP project is implemented across several directories, including the client, server, and plugin components.
The client
directory contains the implementation of the FRP client, which is responsible for establishing and maintaining the connection with the FRP server, managing the lifecycle of proxies and visitors, and handling various message types exchanged with the server. The client supports different proxy types, such as TCP, UDP, SUDP, and XTCP, and manages their lifecycle using the proxy.Manager
struct. The visitor functionality is handled by the visitor.Manager
, which manages different visitor types like STCP, XTCP, and SUDP. The client also provides an HTTP-based administrative API, allowing users to perform operations like reloading the configuration and retrieving the current status.
The server
directory contains the implementation of the FRP server, which is responsible for managing the various proxies, visitors, and the control connection with the FRP client. The server supports different proxy types, including HTTP, HTTPS, TCP, UDP, STCP, SUDP, and XTCP, and manages them using the proxy.Manager
struct. The server also handles group-related functionality, such as managing HTTP, TCP, and TCP multiplexer proxy groups, using the group
package. The server's control connection with the client is managed by the Control
struct, which handles client requests and manages the lifecycle of proxies.
The FRP project relies on several key technologies and algorithms, including:
- NAT Hole Punching: The
…/nathole
directory contains the core functionality for handling NAT (Network Address Translation) hole punching, which allows the FRP client and server to establish connections even when they are behind different NAT devices. - Authentication and Authorization: The
…/auth
directory provides the implementation of the authentication and authorization mechanisms used in the FRP project, supporting both token-based and OpenID Connect (OIDC) authentication. - Metrics and Monitoring: The
…/metrics
directory manages the metrics functionality in the FRP server, providing support for both memory-based and Prometheus-based metrics. - Configuration Management: The
…/config
directory handles the configuration management and validation logic for the FRP client and server, supporting various file formats and template rendering.
The FRP project is designed with a modular and extensible architecture, allowing for the addition of new proxy types, visitor types, and server-side plugins through well-defined interfaces and extension points.
Client FunctionalityRevise
References: client
The client
directory contains the core functionality of the FRP (Fast Reverse Proxy) client application. It is responsible for establishing and maintaining the connection with the FRP server, managing the lifecycle of proxies and visitors, and handling various message types exchanged with the server.
Proxy ManagementRevise
References: client/proxy
The …/proxy
directory contains the implementation of various proxy types used in the FRP (Fast Reverse Proxy) client. The main components in this directory are:
Visitor ManagementRevise
References: client/visitor
This subsection covers the implementation of the visitor functionality in the FRP client, including the management of different visitor types and the establishment of connections with the FRP server.
Health MonitoringRevise
References: client/health
The …/health
directory contains the implementation of the health monitoring system for the FRP client. The core component is the Monitor
struct, which is responsible for performing health checks on network endpoints and managing their status.
Event HandlingRevise
References: client/event
The event.go
file in the …/event
directory defines the core functionality for handling events in the FRP client, including the management of the lifecycle of proxies.
Control ConnectionRevise
The Control
struct in the …/control.go
file is responsible for managing the client-side functionality of the FRP application, including the following key responsibilities:
Administrative APIRevise
References: client
The admin_api.go
file in the client
directory provides an HTTP-based administrative API for the FRP client. This API allows users to perform various operations on the FRP client, such as reloading the configuration, stopping the client, and retrieving the current status and configuration.
Client ServiceRevise
References: client
The frp/client/service.go
file provides the implementation of the client service for the FRP (Fast Reverse Proxy) project. The Service
struct is the main entry point for the client service, responsible for connecting to the FRP server, managing proxy and visitor configurations, and gracefully closing the service.
Server FunctionalityRevise
References: server
The server
directory is the central hub for managing the server-side functionality of the FRP (Fast Reverse Proxy) application. It contains several sub-directories and files that collectively provide the core functionality of the FRP server.
Proxy ManagementRevise
References: server/proxy
The …/proxy
directory contains the core functionality for managing and running various types of proxy servers in the FRP (Fast Reverse Proxy) server. The main components and their responsibilities are:
Group ManagementRevise
References: server/group
The …/group
directory contains the implementation of group-related functionality in the FRP (Frp Reverse Proxy) server. This includes the management of HTTP proxy groups, TCP proxy groups, and TCP multiplexer groups.
Visitor ManagementRevise
References: server/visitor
The …/visitor
directory contains the implementation of the visitor connection manager for the FRP (Fast Reverse Proxy) server. The Manager
struct in the visitor.go
file is the primary component responsible for managing visitor listeners, which are used to handle incoming visitor connections.
Port ManagementRevise
References: server/ports
The …/ports
directory contains the implementation of the port management functionality for the FRP server. The main component in this directory is the Manager
struct, which is responsible for allocating and releasing network ports for the FRP server.
Metrics and MonitoringRevise
References: server/metrics
The …/metrics
directory contains the implementation of the server-side metrics functionality in the FRP project. This subsection covers the key components and design decisions in this implementation.
Resource ManagementRevise
References: server/controller
The ResourceController
in the …/controller
directory is the central hub for managing the various resources and controllers in the FRP server. It provides a unified interface to access and interact with the different components that handle the core functionality of the server.
Control ConnectionRevise
References: server/control.go
, server/service.go
The control.go
file in the server
package contains the implementation of the Control
struct, which is responsible for managing the control connection between the FRP server and the FRP client. The Control
struct handles various client requests, such as creating new proxies, handling ping messages, and closing proxies.
Dashboard APIRevise
References: server/dashboard_api.go
The Dashboard API in the FRP (Fast Reverse Proxy) server provides a set of endpoints for retrieving information about the server and managing its proxies. The main functionality of this API is implemented in the …/dashboard_api.go
file.
Configuration ManagementRevise
References: pkg/config
The …/config
directory in the FRP (Fast Reverse Proxy) project contains the core functionality for managing and validating the configuration of the FRP client and server. This directory is divided into several sub-directories and files, each with its own specific responsibilities.
Configuration Management OverviewRevise
References: pkg/config
The …/config
directory in the FRP (Fast Reverse Proxy) project contains the core functionality for managing and validating the configuration of the FRP client and server. This directory is divided into several sub-directories and files, each with its own specific responsibilities:
Legacy Configuration HandlingRevise
References: pkg/config/legacy
The …/legacy
directory in the FRP (Fast Reverse Proxy) project contains the implementation of the legacy configuration handling for the FRP client and server. The key functionality in this directory includes:
v1 Configuration FormatRevise
References: pkg/config/v1
, pkg/config/v1/validation
The …/v1
directory contains the configuration management and validation logic for the FRP (Fast Reverse Proxy) project. It defines the various configuration structures, including those for the client, server, proxies, and visitors, as well as the functionality to validate and complete these configurations.
Configuration UtilitiesRevise
References: pkg/config/types
The …/types
directory contains utility functions and custom data types used throughout the configuration management of the FRP (Fast Reverse Proxy) application. The main components are:
Configuration Loading and ParsingRevise
References: pkg/config/load.go
, pkg/config/load_test.go
The frp/pkg/config/load.go
file provides the core functionality for loading and parsing configuration files in various formats for the FRP (Fast Reverse Proxy) project. It supports JSON, YAML, and TOML configuration formats, as well as the legacy INI-based configuration format.
Command-line FlagsRevise
References: pkg/config/flags.go
The frp/pkg/config/flags.go
file provides functionality for registering and handling command-line flags for the FRP application. It defines several custom flag types, such as BandwidthQuantityFlag
and PortsRangeSliceFlag
, and provides functions to register flags for different components of the FRP application.
Utility FunctionsRevise
References: pkg/util
The …/util
directory contains a collection of utility functions and types that are used throughout the FRP (Fast Reverse Proxy) project. The directory is organized into several sub-directories, each providing specific functionality.
HTTP Utility FunctionsRevise
References: pkg/util/http
The …/http
directory provides utility functions for working with HTTP requests and responses in the FRP (Fast Reverse Proxy) project. The main functionality includes:
HTTP Server ImplementationRevise
References: pkg/util/http
The …/server.go
file provides an implementation of an HTTP server with support for TLS, authentication, and profiling. The core functionality is encapsulated in the Server
struct, which manages the server's lifecycle, and the RouterRegisterHelper
struct, which helps with registering routes and applying middleware.
Logging UtilityRevise
References: pkg/util/log
The …/log
directory contains the centralized and configurable logging system for the FRP project. This logging system can output logs to either the console or a rotating log file, and provides convenience functions for logging at different severity levels.
Metrics UtilitiesRevise
References: pkg/util/metric
The …/metric
directory contains several files that define different types of metrics for the Frp Reverse Proxy (FRP) project. The main components in this directory are:
Network UtilitiesRevise
References: pkg/util/net
The …/net
directory contains various utility functions and types related to network connectivity and handling in the FRP (Fast Reverse Proxy) project. The main functionalities provided in this directory include:
System CompatibilityRevise
References: pkg/util/system
The …/system
directory contains utility functions and code to address compatibility issues on different systems, particularly Android devices. The main functionality in this directory is focused on fixing issues related to timezone and DNS resolution on Android platforms.
TCP MultiplexerRevise
References: pkg/util/tcpmux
The …/tcpmux
directory contains an implementation of an HTTP CONNECT TCP multiplexer. The main functionality is provided by the HTTPConnectTCPMuxer
struct, which is responsible for handling HTTP CONNECT requests and forwarding the connection to the appropriate backend service.
General UtilitiesRevise
References: pkg/util/util
The …/util
directory contains a collection of general utility functions that are used throughout the FRP project. These utilities provide functionality for generating random IDs, calculating authentication keys, parsing range numbers, handling response errors, and other common tasks.
Logging Prefix ManagementRevise
References: pkg/util/xlog
The …/xlog
directory provides a custom logging utility for the FRP project, allowing developers to manage and display log prefixes. The core functionality is implemented in the xlog.go
file and the ctx.go
file.
Backoff StrategiesRevise
References: pkg/util/wait
The …/wait
directory provides utility functions and types for implementing backoff strategies, which are commonly used in distributed systems to handle transient failures and network issues.
Version ManagementRevise
References: pkg/util/version
The …/version.go
file defines a single variable version
that holds the current version of the FRP software. This variable is initialized to the string "0.56.0"
, which likely represents the version of the FRP software being developed.
Virtual Host (vhost) SystemRevise
References: pkg/util/vhost
The virtual host (vhost) system in the FRP project is implemented in the …/vhost
directory. This system provides an HTTP reverse proxy and an HTTPS multiplexer to handle routing of traffic based on the hostname.
PluginsRevise
References: pkg/plugin
The FRP project provides a flexible plugin system for both the client and server components, allowing developers to extend the functionality of the system.
Client-Side PluginsRevise
References: pkg/plugin/client
The …/client
directory contains the implementation of various client-side plugins for the FRP (Fast Reverse Proxy) project. These plugins allow the FRP client to handle different types of connections, such as HTTP, HTTPS, SOCKS5, and Unix domain sockets.
Server-Side PluginsRevise
References: pkg/plugin/server
The …/server
directory contains the server-side plugin functionality for the FRP (Fast Reverse Proxy) project. The main components in this directory are:
Messaging and CommunicationRevise
References: pkg/msg
The …/msg
directory contains the core message types and communication functionality for the FRP (Fast Reverse Proxy) project. It defines various message structures, such as Login
, NewProxy
, NewVisitorConn
, and others, which are used for the communication between the FRP client (frpc) and server (frps).
Metrics and MonitoringRevise
References: pkg/metrics
The …/metrics
directory provides the metrics and monitoring functionality for the FRP server. This includes the implementation of server-level and proxy-level metrics, as well as the ability to enable different metrics systems such as memory-based and Prometheus-based metrics.
Server-Side Metrics ImplementationRevise
References: pkg/metrics/aggregate
, pkg/metrics/mem
, pkg/metrics/prometheus
The …/aggregate
directory contains the implementation of the server-side metrics system for the FRP (Fast Reverse Proxy) project. The main functionality is provided by the serverMetrics
struct, which acts as a central hub for managing different metrics systems that can be enabled, such as memory-based metrics and Prometheus-based metrics.
Metrics AggregationRevise
References: pkg/metrics/aggregate/server.go
The serverMetrics
struct in the …/server.go
file acts as a central hub for managing the different metrics systems that can be enabled in the FRP project. This struct is defined and initialized in the init()
function.
Memory-Based MetricsRevise
References: pkg/metrics/mem/server.go
, pkg/metrics/mem/types.go
The …/mem
directory contains the implementation of the memory-based metrics system for the FRP (Fast Reverse Proxy) project. This subsection covers the key aspects of this implementation, including the management of server-level and proxy-level statistics, as well as the periodic clearing of offline proxy data.
Prometheus-Based MetricsRevise
References: pkg/metrics/prometheus/server.go
The frp/pkg/metrics/prometheus/server.go
file defines the Prometheus-based metrics system for the FRP server. This system exposes various metrics related to the server's operation, such as the number of clients, proxies, connections, and traffic in and out.
Token-Based AuthenticationRevise
References: pkg/auth/token.go
The TokenAuthSetterVerifier
struct in …/token.go
is responsible for managing the token-based authentication mechanism in the FRP project. This struct is used to set and verify authentication tokens in various FRP-related messages, such as Login
, Ping
, and NewWorkConn
.
OIDC AuthenticationRevise
References: pkg/auth/oidc.go
The oidc.go
file in the …/auth
directory contains the implementation of the OIDC (OpenID Connect) authentication mechanism used in the FRP (Fast Reverse Proxy) project.
Authentication InterfacesRevise
References: pkg/auth/auth.go
The auth.go
file in the …/auth
directory defines two main interfaces: Setter
and Verifier
, which are used to set and verify authentication credentials, respectively, in the FRP (Fast Reverse Proxy) project.
Legacy AuthenticationRevise
References: pkg/auth/legacy/legacy.go
The legacy.go
file in the …/legacy
package defines the configuration structures and default values for the legacy authentication methods used in the FRP (Fast Reverse Proxy) project. This includes the configuration options for both the client and server.
Simple "Always Pass" AuthenticationRevise
References: pkg/auth/pass.go
The frp/pkg/auth/pass.go
file contains an implementation of a simple "always pass" authentication mechanism for the FRP (Fast Reverse Proxy) project. This mechanism can be useful for testing or development purposes, where a simple authentication solution is required.
NAT Hole PunchingRevise
References: pkg/nathole
The core functionality for handling NAT (Network Address Translation) hole punching in the FRP project is implemented in the …/nathole
directory. This directory contains several key components that work together to provide a robust and reliable NAT hole-punching solution.
NAT Feature Analysis and RecommendationRevise
References: pkg/nathole/analysis.go
The analysis.go
file in the …/nathole
package contains the core functionality for analyzing the network address translation (NAT) features of clients and visitors, and recommending the appropriate hole-punching strategy.
NAT Feature ClassificationRevise
References: pkg/nathole/classify.go
The classify.go
file in the …/nathole
package provides functionality for classifying the NAT (Network Address Translation) type and behavior of network addresses. The main functionality is provided by the ClassifyNATFeature()
function, which takes a list of network addresses and local IP addresses, and returns a NatFeature
object with the classified NAT type and behavior.
NAT Hole-Punching ControllerRevise
References: pkg/nathole/controller.go
The Controller
struct in the …/controller.go
file is the central component responsible for managing the NAT hole-punching functionality in the FRP project. The Controller
is responsible for the following key tasks:
NAT DiscoveryRevise
References: pkg/nathole/discovery.go
The Discover()
function in the …/discovery.go
file is responsible for discovering the external IP address of the client by sending STUN requests to the provided STUN servers.
NAT Hole-Punching LogicRevise
References: pkg/nathole/nathole.go
The MakeHole()
function in the …/nathole.go
file is responsible for the core NAT hole punching logic in the FRP project. This function is called after the client and server have exchanged information about their NAT types and behaviors, and it is tasked with actually creating a hole in the NAT to establish a direct connection between the two parties.
Utility FunctionsRevise
References: pkg/nathole/utils.go
The utils.go
file in the …/nathole
directory provides various utility functions used throughout the NAT hole-punching implementation.