v1

package
v0.68.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 14 Imported by: 89

Documentation

Index

Constants

View Source
const (
	PluginHTTP2HTTPS       = "http2https"
	PluginHTTPProxy        = "http_proxy"
	PluginHTTPS2HTTP       = "https2http"
	PluginHTTPS2HTTPS      = "https2https"
	PluginHTTP2HTTP        = "http2http"
	PluginSocks5           = "socks5"
	PluginStaticFile       = "static_file"
	PluginUnixDomainSocket = "unix_domain_socket"
	PluginTLS2Raw          = "tls2raw"
	PluginVirtualNet       = "virtual_net"
)
View Source
const (
	VisitorPluginVirtualNet = "virtual_net"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIMetadata

type APIMetadata struct {
	Version string `json:"version"`
}

type AuthClientConfig

type AuthClientConfig struct {
	// Method specifies what authentication method to use to
	// authenticate frpc with frps. If "token" is specified - token will be
	// read into login message. If "oidc" is specified - OIDC (Open ID Connect)
	// token will be issued using OIDC settings. By default, this value is "token".
	Method AuthMethod `json:"method,omitempty"`
	// Specify whether to include auth info in additional scope.
	// Current supported scopes are: "HeartBeats", "NewWorkConns".
	AdditionalScopes []AuthScope `json:"additionalScopes,omitempty"`
	// Token specifies the authorization token used to create keys to be sent
	// to the server. The server must have a matching token for authorization
	// to succeed.  By default, this value is "".
	Token string `json:"token,omitempty"`
	// TokenSource specifies a dynamic source for the authorization token.
	// This is mutually exclusive with Token field.
	TokenSource *ValueSource         `json:"tokenSource,omitempty"`
	OIDC        AuthOIDCClientConfig `json:"oidc,omitempty"`
}

func (*AuthClientConfig) Complete

func (c *AuthClientConfig) Complete() error

type AuthMethod

type AuthMethod string
const (
	AuthMethodToken AuthMethod = "token"
	AuthMethodOIDC  AuthMethod = "oidc"
)

type AuthOIDCClientConfig

type AuthOIDCClientConfig struct {
	// ClientID specifies the client ID to use to get a token in OIDC authentication.
	ClientID string `json:"clientID,omitempty"`
	// ClientSecret specifies the client secret to use to get a token in OIDC
	// authentication.
	ClientSecret string `json:"clientSecret,omitempty"`
	// Audience specifies the audience of the token in OIDC authentication.
	Audience string `json:"audience,omitempty"`
	// Scope specifies the scope of the token in OIDC authentication.
	Scope string `json:"scope,omitempty"`
	// TokenEndpointURL specifies the URL which implements OIDC Token Endpoint.
	// It will be used to get an OIDC token.
	TokenEndpointURL string `json:"tokenEndpointURL,omitempty"`
	// AdditionalEndpointParams specifies additional parameters to be sent
	// this field will be transfer to map[string][]string in OIDC token generator.
	AdditionalEndpointParams map[string]string `json:"additionalEndpointParams,omitempty"`

	// TrustedCaFile specifies the path to a custom CA certificate file
	// for verifying the OIDC token endpoint's TLS certificate.
	TrustedCaFile string `json:"trustedCaFile,omitempty"`
	// InsecureSkipVerify disables TLS certificate verification for the
	// OIDC token endpoint. Only use this for debugging, not recommended for production.
	InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
	// ProxyURL specifies a proxy to use when connecting to the OIDC token endpoint.
	// Supports http, https, socks5, and socks5h proxy protocols.
	// If empty, no proxy is used for OIDC connections.
	ProxyURL string `json:"proxyURL,omitempty"`

	// TokenSource specifies a custom dynamic source for the authorization token.
	// This is mutually exclusive with every other field of this structure.
	TokenSource *ValueSource `json:"tokenSource,omitempty"`
}

type AuthOIDCServerConfig

type AuthOIDCServerConfig struct {
	// Issuer specifies the issuer to verify OIDC tokens with. This issuer
	// will be used to load public keys to verify signature and will be compared
	// with the issuer claim in the OIDC token.
	Issuer string `json:"issuer,omitempty"`
	// Audience specifies the audience OIDC tokens should contain when validated.
	// If this value is empty, audience ("client ID") verification will be skipped.
	Audience string `json:"audience,omitempty"`
	// SkipExpiryCheck specifies whether to skip checking if the OIDC token is
	// expired.
	SkipExpiryCheck bool `json:"skipExpiryCheck,omitempty"`
	// SkipIssuerCheck specifies whether to skip checking if the OIDC token's
	// issuer claim matches the issuer specified in OidcIssuer.
	SkipIssuerCheck bool `json:"skipIssuerCheck,omitempty"`
}

type AuthScope

type AuthScope string
const (
	AuthScopeHeartBeats   AuthScope = "HeartBeats"
	AuthScopeNewWorkConns AuthScope = "NewWorkConns"
)

type AuthServerConfig

type AuthServerConfig struct {
	Method           AuthMethod           `json:"method,omitempty"`
	AdditionalScopes []AuthScope          `json:"additionalScopes,omitempty"`
	Token            string               `json:"token,omitempty"`
	TokenSource      *ValueSource         `json:"tokenSource,omitempty"`
	OIDC             AuthOIDCServerConfig `json:"oidc,omitempty"`
}

func (*AuthServerConfig) Complete

func (c *AuthServerConfig) Complete() error

type ClientCommonConfig

type ClientCommonConfig struct {
	APIMetadata

	Auth AuthClientConfig `json:"auth,omitempty"`
	// User specifies a prefix for proxy names to distinguish them from other
	// clients. If this value is not "", proxy names will automatically be
	// changed to "{user}.{proxy_name}".
	User string `json:"user,omitempty"`
	// ClientID uniquely identifies this frpc instance.
	ClientID string `json:"clientID,omitempty"`

	// ServerAddr specifies the address of the server to connect to. By
	// default, this value is "0.0.0.0".
	ServerAddr string `json:"serverAddr,omitempty"`
	// ServerPort specifies the port to connect to the server on. By default,
	// this value is 7000.
	ServerPort int `json:"serverPort,omitempty"`
	// STUN server to help penetrate NAT hole.
	NatHoleSTUNServer string `json:"natHoleStunServer,omitempty"`
	// DNSServer specifies a DNS server address for FRPC to use. If this value
	// is "", the default DNS will be used.
	DNSServer string `json:"dnsServer,omitempty"`
	// LoginFailExit controls whether or not the client should exit after a
	// failed login attempt. If false, the client will retry until a login
	// attempt succeeds. By default, this value is true.
	LoginFailExit *bool `json:"loginFailExit,omitempty"`
	// Start specifies a set of enabled proxies by name. If this set is empty,
	// all supplied proxies are enabled. By default, this value is an empty
	// set.
	Start []string `json:"start,omitempty"`

	Log        LogConfig             `json:"log,omitempty"`
	WebServer  WebServerConfig       `json:"webServer,omitempty"`
	Transport  ClientTransportConfig `json:"transport,omitempty"`
	VirtualNet VirtualNetConfig      `json:"virtualNet,omitempty"`

	// FeatureGates specifies a set of feature gates to enable or disable.
	// This can be used to enable alpha/beta features or disable default features.
	FeatureGates map[string]bool `json:"featureGates,omitempty"`

	// UDPPacketSize specifies the udp packet size
	// By default, this value is 1500
	UDPPacketSize int64 `json:"udpPacketSize,omitempty"`
	// Client metadata info
	Metadatas map[string]string `json:"metadatas,omitempty"`

	// Include other config files for proxies.
	IncludeConfigFiles []string `json:"includes,omitempty"`

	// Store config enables the built-in store source (not configurable via sources list).
	Store StoreConfig `json:"store,omitempty"`
}

func (*ClientCommonConfig) Complete

func (c *ClientCommonConfig) Complete() error

type ClientConfig

type ClientConfig struct {
	ClientCommonConfig

	Proxies  []TypedProxyConfig   `json:"proxies,omitempty"`
	Visitors []TypedVisitorConfig `json:"visitors,omitempty"`
}

func DecodeClientConfigJSON added in v0.68.0

func DecodeClientConfigJSON(b []byte, options DecodeOptions) (ClientConfig, error)

type ClientPluginOptions

type ClientPluginOptions interface {
	Complete()
	Clone() ClientPluginOptions
}

type ClientTransportConfig

type ClientTransportConfig struct {
	// Protocol specifies the protocol to use when interacting with the server.
	// Valid values are "tcp", "kcp", "quic", "websocket" and "wss". By default, this value
	// is "tcp".
	Protocol string `json:"protocol,omitempty"`
	// The maximum amount of time a dial to server will wait for a connect to complete.
	DialServerTimeout int64 `json:"dialServerTimeout,omitempty"`
	// DialServerKeepAlive specifies the interval between keep-alive probes for an active network connection between frpc and frps.
	// If negative, keep-alive probes are disabled.
	DialServerKeepAlive int64 `json:"dialServerKeepalive,omitempty"`
	// ConnectServerLocalIP specifies the address of the client bind when it connect to server.
	// Note: This value only use in TCP/Websocket protocol. Not support in KCP protocol.
	ConnectServerLocalIP string `json:"connectServerLocalIP,omitempty"`
	// ProxyURL specifies a proxy address to connect to the server through. If
	// this value is "", the server will be connected to directly. By default,
	// this value is read from the "http_proxy" environment variable.
	ProxyURL string `json:"proxyURL,omitempty"`
	// PoolCount specifies the number of connections the client will make to
	// the server in advance.
	PoolCount int `json:"poolCount,omitempty"`
	// TCPMux toggles TCP stream multiplexing. This allows multiple requests
	// from a client to share a single TCP connection. If this value is true,
	// the server must have TCP multiplexing enabled as well. By default, this
	// value is true.
	TCPMux *bool `json:"tcpMux,omitempty"`
	// TCPMuxKeepaliveInterval specifies the keep alive interval for TCP stream multiplier.
	// If TCPMux is true, heartbeat of application layer is unnecessary because it can only rely on heartbeat in TCPMux.
	TCPMuxKeepaliveInterval int64 `json:"tcpMuxKeepaliveInterval,omitempty"`
	// QUIC protocol options.
	QUIC QUICOptions `json:"quic,omitempty"`
	// HeartBeatInterval specifies at what interval heartbeats are sent to the
	// server, in seconds. It is not recommended to change this value. By
	// default, this value is 30. Set negative value to disable it.
	HeartbeatInterval int64 `json:"heartbeatInterval,omitempty"`
	// HeartBeatTimeout specifies the maximum allowed heartbeat response delay
	// before the connection is terminated, in seconds. It is not recommended
	// to change this value. By default, this value is 90. Set negative value to disable it.
	HeartbeatTimeout int64 `json:"heartbeatTimeout,omitempty"`
	// TLS specifies TLS settings for the connection to the server.
	TLS TLSClientConfig `json:"tls,omitempty"`
}

func (*ClientTransportConfig) Complete

func (c *ClientTransportConfig) Complete()

type DecodeOptions added in v0.68.0

type DecodeOptions struct {
	DisallowUnknownFields bool
}

type DomainConfig

type DomainConfig struct {
	CustomDomains []string `json:"customDomains,omitempty"`
	SubDomain     string   `json:"subdomain,omitempty"`
}

func (DomainConfig) Clone added in v0.68.0

func (c DomainConfig) Clone() DomainConfig

type ExecEnvVar added in v0.66.0

type ExecEnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type ExecSource added in v0.66.0

type ExecSource struct {
	Command string       `json:"command"`
	Args    []string     `json:"args,omitempty"`
	Env     []ExecEnvVar `json:"env,omitempty"`
}

ExecSource specifies how to get a value from another program launched as subprocess.

func (*ExecSource) Resolve added in v0.66.0

func (e *ExecSource) Resolve(ctx context.Context) (string, error)

Resolve reads and returns the content captured from stdout of launched subprocess.

func (*ExecSource) Validate added in v0.66.0

func (e *ExecSource) Validate() error

Validate validates the ExecSource configuration.

type FileSource added in v0.64.0

type FileSource struct {
	Path string `json:"path"`
}

FileSource specifies how to load a value from a file.

func (*FileSource) Resolve added in v0.64.0

func (f *FileSource) Resolve(_ context.Context) (string, error)

Resolve reads and returns the content from the specified file.

func (*FileSource) Validate added in v0.64.0

func (f *FileSource) Validate() error

Validate validates the FileSource configuration.

type HTTP2HTTPPluginOptions added in v0.59.0

type HTTP2HTTPPluginOptions struct {
	Type              string           `json:"type,omitempty"`
	LocalAddr         string           `json:"localAddr,omitempty"`
	HostHeaderRewrite string           `json:"hostHeaderRewrite,omitempty"`
	RequestHeaders    HeaderOperations `json:"requestHeaders,omitempty"`
}

func (*HTTP2HTTPPluginOptions) Clone added in v0.68.0

func (*HTTP2HTTPPluginOptions) Complete added in v0.59.0

func (o *HTTP2HTTPPluginOptions) Complete()

type HTTP2HTTPSPluginOptions

type HTTP2HTTPSPluginOptions struct {
	Type              string           `json:"type,omitempty"`
	LocalAddr         string           `json:"localAddr,omitempty"`
	HostHeaderRewrite string           `json:"hostHeaderRewrite,omitempty"`
	RequestHeaders    HeaderOperations `json:"requestHeaders,omitempty"`
}

func (*HTTP2HTTPSPluginOptions) Clone added in v0.68.0

func (*HTTP2HTTPSPluginOptions) Complete added in v0.59.0

func (o *HTTP2HTTPSPluginOptions) Complete()

type HTTPHeader added in v0.56.0

type HTTPHeader struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type HTTPPluginOptions

type HTTPPluginOptions struct {
	Name      string   `json:"name"`
	Addr      string   `json:"addr"`
	Path      string   `json:"path"`
	Ops       []string `json:"ops"`
	TLSVerify bool     `json:"tlsVerify,omitempty"`
}

type HTTPProxyConfig

type HTTPProxyConfig struct {
	ProxyBaseConfig
	DomainConfig

	Locations         []string         `json:"locations,omitempty"`
	HTTPUser          string           `json:"httpUser,omitempty"`
	HTTPPassword      string           `json:"httpPassword,omitempty"`
	HostHeaderRewrite string           `json:"hostHeaderRewrite,omitempty"`
	RequestHeaders    HeaderOperations `json:"requestHeaders,omitempty"`
	ResponseHeaders   HeaderOperations `json:"responseHeaders,omitempty"`
	RouteByHTTPUser   string           `json:"routeByHTTPUser,omitempty"`
}

func (*HTTPProxyConfig) Clone added in v0.68.0

func (c *HTTPProxyConfig) Clone() ProxyConfigurer

func (*HTTPProxyConfig) MarshalToMsg

func (c *HTTPProxyConfig) MarshalToMsg(m *msg.NewProxy)

func (*HTTPProxyConfig) UnmarshalFromMsg

func (c *HTTPProxyConfig) UnmarshalFromMsg(m *msg.NewProxy)

type HTTPProxyPluginOptions

type HTTPProxyPluginOptions struct {
	Type         string `json:"type,omitempty"`
	HTTPUser     string `json:"httpUser,omitempty"`
	HTTPPassword string `json:"httpPassword,omitempty"`
}

func (*HTTPProxyPluginOptions) Clone added in v0.68.0

func (*HTTPProxyPluginOptions) Complete added in v0.59.0

func (o *HTTPProxyPluginOptions) Complete()

type HTTPS2HTTPPluginOptions

type HTTPS2HTTPPluginOptions struct {
	Type              string           `json:"type,omitempty"`
	LocalAddr         string           `json:"localAddr,omitempty"`
	HostHeaderRewrite string           `json:"hostHeaderRewrite,omitempty"`
	RequestHeaders    HeaderOperations `json:"requestHeaders,omitempty"`
	EnableHTTP2       *bool            `json:"enableHTTP2,omitempty"`
	CrtPath           string           `json:"crtPath,omitempty"`
	KeyPath           string           `json:"keyPath,omitempty"`
}

func (*HTTPS2HTTPPluginOptions) Clone added in v0.68.0

func (*HTTPS2HTTPPluginOptions) Complete added in v0.59.0

func (o *HTTPS2HTTPPluginOptions) Complete()

type HTTPS2HTTPSPluginOptions

type HTTPS2HTTPSPluginOptions struct {
	Type              string           `json:"type,omitempty"`
	LocalAddr         string           `json:"localAddr,omitempty"`
	HostHeaderRewrite string           `json:"hostHeaderRewrite,omitempty"`
	RequestHeaders    HeaderOperations `json:"requestHeaders,omitempty"`
	EnableHTTP2       *bool            `json:"enableHTTP2,omitempty"`
	CrtPath           string           `json:"crtPath,omitempty"`
	KeyPath           string           `json:"keyPath,omitempty"`
}

func (*HTTPS2HTTPSPluginOptions) Clone added in v0.68.0

func (*HTTPS2HTTPSPluginOptions) Complete added in v0.59.0

func (o *HTTPS2HTTPSPluginOptions) Complete()

type HTTPSProxyConfig

type HTTPSProxyConfig struct {
	ProxyBaseConfig
	DomainConfig
}

func (*HTTPSProxyConfig) Clone added in v0.68.0

func (c *HTTPSProxyConfig) Clone() ProxyConfigurer

func (*HTTPSProxyConfig) MarshalToMsg

func (c *HTTPSProxyConfig) MarshalToMsg(m *msg.NewProxy)

func (*HTTPSProxyConfig) UnmarshalFromMsg

func (c *HTTPSProxyConfig) UnmarshalFromMsg(m *msg.NewProxy)

type HeaderOperations

type HeaderOperations struct {
	Set map[string]string `json:"set,omitempty"`
}

func (HeaderOperations) Clone added in v0.68.0

type HealthCheckConfig

type HealthCheckConfig struct {
	// Type specifies what protocol to use for health checking.
	// Valid values include "tcp", "http", and "". If this value is "", health
	// checking will not be performed.
	//
	// If the type is "tcp", a connection will be attempted to the target
	// server. If a connection cannot be established, the health check fails.
	//
	// If the type is "http", a GET request will be made to the endpoint
	// specified by HealthCheckURL. If the response is not a 200, the health
	// check fails.
	Type string `json:"type"` // tcp | http
	// TimeoutSeconds specifies the number of seconds to wait for a health
	// check attempt to connect. If the timeout is reached, this counts as a
	// health check failure. By default, this value is 3.
	TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
	// MaxFailed specifies the number of allowed failures before the
	// is stopped. By default, this value is 1.
	MaxFailed int `json:"maxFailed,omitempty"`
	// IntervalSeconds specifies the time in seconds between health
	// checks. By default, this value is 10.
	IntervalSeconds int `json:"intervalSeconds"`
	// Path specifies the path to send health checks to if the
	// health check type is "http".
	Path string `json:"path,omitempty"`
	// HTTPHeaders specifies the headers to send with the health request, if
	// the health check type is "http".
	HTTPHeaders []HTTPHeader `json:"httpHeaders,omitempty"`
}

HealthCheckConfig configures health checking. This can be useful for load balancing purposes to detect and remove proxies to failing services.

func (HealthCheckConfig) Clone added in v0.68.0

type LoadBalancerConfig

type LoadBalancerConfig struct {
	// Group specifies which group the is a part of. The server will use
	// this information to load balance proxies in the same group. If the value
	// is "", this will not be in a group.
	Group string `json:"group"`
	// GroupKey specifies a group key, which should be the same among proxies
	// of the same group.
	GroupKey string `json:"groupKey,omitempty"`
}

type LogConfig

type LogConfig struct {
	// This is destination where frp should write the logs.
	// If "console" is used, logs will be printed to stdout, otherwise,
	// logs will be written to the specified file.
	// By default, this value is "console".
	To string `json:"to,omitempty"`
	// Level specifies the minimum log level. Valid values are "trace",
	// "debug", "info", "warn", and "error". By default, this value is "info".
	Level string `json:"level,omitempty"`
	// MaxDays specifies the maximum number of days to store log information
	// before deletion.
	MaxDays int64 `json:"maxDays"`
	// DisablePrintColor disables log colors when log.to is "console".
	DisablePrintColor bool `json:"disablePrintColor,omitempty"`
}

func (*LogConfig) Complete

func (c *LogConfig) Complete()

type NatTraversalConfig added in v0.65.0

type NatTraversalConfig struct {
	// DisableAssistedAddrs disables the use of local network interfaces
	// for assisted connections during NAT traversal. When enabled,
	// only STUN-discovered public addresses will be used.
	DisableAssistedAddrs bool `json:"disableAssistedAddrs,omitempty"`
}

NatTraversalConfig defines configuration options for NAT traversal

func (*NatTraversalConfig) Clone added in v0.68.0

type ProxyBackend

type ProxyBackend struct {
	// LocalIP specifies the IP address or host name of the backend.
	LocalIP string `json:"localIP,omitempty"`
	// LocalPort specifies the port of the backend.
	LocalPort int `json:"localPort,omitempty"`

	// Plugin specifies what plugin should be used for handling connections. If this value
	// is set, the LocalIP and LocalPort values will be ignored.
	Plugin TypedClientPluginOptions `json:"plugin,omitempty"`
}

func (ProxyBackend) Clone added in v0.68.0

func (c ProxyBackend) Clone() ProxyBackend

type ProxyBaseConfig

type ProxyBaseConfig struct {
	Name string `json:"name"`
	Type string `json:"type"`
	// Enabled controls whether this proxy is enabled. nil or true means enabled, false means disabled.
	// This allows individual control over each proxy, complementing the global "start" field.
	Enabled     *bool             `json:"enabled,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
	Transport   ProxyTransport    `json:"transport,omitempty"`
	// metadata info for each proxy
	Metadatas    map[string]string  `json:"metadatas,omitempty"`
	LoadBalancer LoadBalancerConfig `json:"loadBalancer,omitempty"`
	HealthCheck  HealthCheckConfig  `json:"healthCheck,omitempty"`
	ProxyBackend
}

func (ProxyBaseConfig) Clone added in v0.68.0

func (c ProxyBaseConfig) Clone() ProxyBaseConfig

func (*ProxyBaseConfig) Complete

func (c *ProxyBaseConfig) Complete()

func (*ProxyBaseConfig) GetBaseConfig

func (c *ProxyBaseConfig) GetBaseConfig() *ProxyBaseConfig

func (*ProxyBaseConfig) MarshalToMsg

func (c *ProxyBaseConfig) MarshalToMsg(m *msg.NewProxy)

func (*ProxyBaseConfig) UnmarshalFromMsg

func (c *ProxyBaseConfig) UnmarshalFromMsg(m *msg.NewProxy)

type ProxyConfigurer

type ProxyConfigurer interface {
	Complete()
	GetBaseConfig() *ProxyBaseConfig
	Clone() ProxyConfigurer
	// MarshalToMsg marshals this config into a msg.NewProxy message. This
	// function will be called on the frpc side.
	MarshalToMsg(*msg.NewProxy)
	// UnmarshalFromMsg unmarshal a msg.NewProxy message into this config.
	// This function will be called on the frps side.
	UnmarshalFromMsg(*msg.NewProxy)
}

func DecodeProxyConfigurerJSON added in v0.68.0

func DecodeProxyConfigurerJSON(b []byte, options DecodeOptions) (ProxyConfigurer, error)

func NewProxyConfigurerByType

func NewProxyConfigurerByType(proxyType ProxyType) ProxyConfigurer

type ProxyTransport

type ProxyTransport struct {
	// UseEncryption controls whether or not communication with the server will
	// be encrypted. Encryption is done using the tokens supplied in the server
	// and client configuration.
	UseEncryption bool `json:"useEncryption,omitempty"`
	// UseCompression controls whether or not communication with the server
	// will be compressed.
	UseCompression bool `json:"useCompression,omitempty"`
	// BandwidthLimit limit the bandwidth
	// 0 means no limit
	BandwidthLimit types.BandwidthQuantity `json:"bandwidthLimit,omitempty"`
	// BandwidthLimitMode specifies whether to limit the bandwidth on the
	// client or server side. Valid values include "client" and "server".
	// By default, this value is "client".
	BandwidthLimitMode string `json:"bandwidthLimitMode,omitempty"`
	// ProxyProtocolVersion specifies which protocol version to use. Valid
	// values include "v1", "v2", and "". If the value is "", a protocol
	// version will be automatically selected. By default, this value is "".
	ProxyProtocolVersion string `json:"proxyProtocolVersion,omitempty"`
}

type ProxyType

type ProxyType string
const (
	ProxyTypeTCP    ProxyType = "tcp"
	ProxyTypeUDP    ProxyType = "udp"
	ProxyTypeTCPMUX ProxyType = "tcpmux"
	ProxyTypeHTTP   ProxyType = "http"
	ProxyTypeHTTPS  ProxyType = "https"
	ProxyTypeSTCP   ProxyType = "stcp"
	ProxyTypeXTCP   ProxyType = "xtcp"
	ProxyTypeSUDP   ProxyType = "sudp"
)

type QUICOptions

type QUICOptions struct {
	KeepalivePeriod    int `json:"keepalivePeriod,omitempty"`
	MaxIdleTimeout     int `json:"maxIdleTimeout,omitempty"`
	MaxIncomingStreams int `json:"maxIncomingStreams,omitempty"`
}

QUIC protocol options

func (*QUICOptions) Complete

func (c *QUICOptions) Complete()

type SSHTunnelGateway added in v0.53.0

type SSHTunnelGateway struct {
	BindPort              int    `json:"bindPort,omitempty"`
	PrivateKeyFile        string `json:"privateKeyFile,omitempty"`
	AutoGenPrivateKeyPath string `json:"autoGenPrivateKeyPath,omitempty"`
	AuthorizedKeysFile    string `json:"authorizedKeysFile,omitempty"`
}

func (*SSHTunnelGateway) Complete added in v0.53.0

func (c *SSHTunnelGateway) Complete()

type STCPProxyConfig

type STCPProxyConfig struct {
	ProxyBaseConfig

	Secretkey  string   `json:"secretKey,omitempty"`
	AllowUsers []string `json:"allowUsers,omitempty"`
}

func (*STCPProxyConfig) Clone added in v0.68.0

func (c *STCPProxyConfig) Clone() ProxyConfigurer

func (*STCPProxyConfig) MarshalToMsg

func (c *STCPProxyConfig) MarshalToMsg(m *msg.NewProxy)

func (*STCPProxyConfig) UnmarshalFromMsg

func (c *STCPProxyConfig) UnmarshalFromMsg(m *msg.NewProxy)

type STCPVisitorConfig

type STCPVisitorConfig struct {
	VisitorBaseConfig
}

func (*STCPVisitorConfig) Clone added in v0.68.0

type SUDPProxyConfig

type SUDPProxyConfig struct {
	ProxyBaseConfig

	Secretkey  string   `json:"secretKey,omitempty"`
	AllowUsers []string `json:"allowUsers,omitempty"`
}

func (*SUDPProxyConfig) Clone added in v0.68.0

func (c *SUDPProxyConfig) Clone() ProxyConfigurer

func (*SUDPProxyConfig) MarshalToMsg

func (c *SUDPProxyConfig) MarshalToMsg(m *msg.NewProxy)

func (*SUDPProxyConfig) UnmarshalFromMsg

func (c *SUDPProxyConfig) UnmarshalFromMsg(m *msg.NewProxy)

type SUDPVisitorConfig

type SUDPVisitorConfig struct {
	VisitorBaseConfig
}

func (*SUDPVisitorConfig) Clone added in v0.68.0

type ServerConfig

type ServerConfig struct {
	APIMetadata

	Auth AuthServerConfig `json:"auth,omitempty"`
	// BindAddr specifies the address that the server binds to. By default,
	// this value is "0.0.0.0".
	BindAddr string `json:"bindAddr,omitempty"`
	// BindPort specifies the port that the server listens on. By default, this
	// value is 7000.
	BindPort int `json:"bindPort,omitempty"`
	// KCPBindPort specifies the KCP port that the server listens on. If this
	// value is 0, the server will not listen for KCP connections.
	KCPBindPort int `json:"kcpBindPort,omitempty"`
	// QUICBindPort specifies the QUIC port that the server listens on.
	// Set this value to 0 will disable this feature.
	QUICBindPort int `json:"quicBindPort,omitempty"`
	// ProxyBindAddr specifies the address that the proxy binds to. This value
	// may be the same as BindAddr.
	ProxyBindAddr string `json:"proxyBindAddr,omitempty"`
	// VhostHTTPPort specifies the port that the server listens for HTTP Vhost
	// requests. If this value is 0, the server will not listen for HTTP
	// requests.
	VhostHTTPPort int `json:"vhostHTTPPort,omitempty"`
	// VhostHTTPTimeout specifies the response header timeout for the Vhost
	// HTTP server, in seconds. By default, this value is 60.
	VhostHTTPTimeout int64 `json:"vhostHTTPTimeout,omitempty"`
	// VhostHTTPSPort specifies the port that the server listens for HTTPS
	// Vhost requests. If this value is 0, the server will not listen for HTTPS
	// requests.
	VhostHTTPSPort int `json:"vhostHTTPSPort,omitempty"`
	// TCPMuxHTTPConnectPort specifies the port that the server listens for TCP
	// HTTP CONNECT requests. If the value is 0, the server will not multiplex TCP
	// requests on one single port. If it's not - it will listen on this value for
	// HTTP CONNECT requests.
	TCPMuxHTTPConnectPort int `json:"tcpmuxHTTPConnectPort,omitempty"`
	// If TCPMuxPassthrough is true, frps won't do any update on traffic.
	TCPMuxPassthrough bool `json:"tcpmuxPassthrough,omitempty"`
	// SubDomainHost specifies the domain that will be attached to sub-domains
	// requested by the client when using Vhost proxying. For example, if this
	// value is set to "frps.com" and the client requested the subdomain
	// "test", the resulting URL would be "test.frps.com".
	SubDomainHost string `json:"subDomainHost,omitempty"`
	// Custom404Page specifies a path to a custom 404 page to display. If this
	// value is "", a default page will be displayed.
	Custom404Page string `json:"custom404Page,omitempty"`

	SSHTunnelGateway SSHTunnelGateway `json:"sshTunnelGateway,omitempty"`

	WebServer WebServerConfig `json:"webServer,omitempty"`
	// EnablePrometheus will export prometheus metrics on webserver address
	// in /metrics api.
	EnablePrometheus bool `json:"enablePrometheus,omitempty"`

	Log LogConfig `json:"log,omitempty"`

	Transport ServerTransportConfig `json:"transport,omitempty"`

	// DetailedErrorsToClient defines whether to send the specific error (with
	// debug info) to frpc. By default, this value is true.
	DetailedErrorsToClient *bool `json:"detailedErrorsToClient,omitempty"`
	// MaxPortsPerClient specifies the maximum number of ports a single client
	// may proxy to. If this value is 0, no limit will be applied.
	MaxPortsPerClient int64 `json:"maxPortsPerClient,omitempty"`
	// UserConnTimeout specifies the maximum time to wait for a work
	// connection. By default, this value is 10.
	UserConnTimeout int64 `json:"userConnTimeout,omitempty"`
	// UDPPacketSize specifies the UDP packet size
	// By default, this value is 1500
	UDPPacketSize int64 `json:"udpPacketSize,omitempty"`
	// NatHoleAnalysisDataReserveHours specifies the hours to reserve nat hole analysis data.
	NatHoleAnalysisDataReserveHours int64 `json:"natholeAnalysisDataReserveHours,omitempty"`

	AllowPorts []types.PortsRange `json:"allowPorts,omitempty"`

	HTTPPlugins []HTTPPluginOptions `json:"httpPlugins,omitempty"`
}

func (*ServerConfig) Complete

func (c *ServerConfig) Complete() error

type ServerTransportConfig

type ServerTransportConfig struct {
	// TCPMux toggles TCP stream multiplexing. This allows multiple requests
	// from a client to share a single TCP connection. By default, this value
	// is true.
	// $HideFromDoc
	TCPMux *bool `json:"tcpMux,omitempty"`
	// TCPMuxKeepaliveInterval specifies the keep alive interval for TCP stream multiplier.
	// If TCPMux is true, heartbeat of application layer is unnecessary because it can only rely on heartbeat in TCPMux.
	TCPMuxKeepaliveInterval int64 `json:"tcpMuxKeepaliveInterval,omitempty"`
	// TCPKeepAlive specifies the interval between keep-alive probes for an active network connection between frpc and frps.
	// If negative, keep-alive probes are disabled.
	TCPKeepAlive int64 `json:"tcpKeepalive,omitempty"`
	// MaxPoolCount specifies the maximum pool size for each proxy. By default,
	// this value is 5.
	MaxPoolCount int64 `json:"maxPoolCount,omitempty"`
	// HeartBeatTimeout specifies the maximum time to wait for a heartbeat
	// before terminating the connection. It is not recommended to change this
	// value. By default, this value is 90. Set negative value to disable it.
	HeartbeatTimeout int64 `json:"heartbeatTimeout,omitempty"`
	// QUIC options.
	QUIC QUICOptions `json:"quic,omitempty"`
	// TLS specifies TLS settings for the connection from the client.
	TLS TLSServerConfig `json:"tls,omitempty"`
}

func (*ServerTransportConfig) Complete

func (c *ServerTransportConfig) Complete()

type Socks5PluginOptions

type Socks5PluginOptions struct {
	Type     string `json:"type,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

func (*Socks5PluginOptions) Clone added in v0.68.0

func (*Socks5PluginOptions) Complete added in v0.59.0

func (o *Socks5PluginOptions) Complete()

type StaticFilePluginOptions

type StaticFilePluginOptions struct {
	Type         string `json:"type,omitempty"`
	LocalPath    string `json:"localPath,omitempty"`
	StripPrefix  string `json:"stripPrefix,omitempty"`
	HTTPUser     string `json:"httpUser,omitempty"`
	HTTPPassword string `json:"httpPassword,omitempty"`
}

func (*StaticFilePluginOptions) Clone added in v0.68.0

func (*StaticFilePluginOptions) Complete added in v0.59.0

func (o *StaticFilePluginOptions) Complete()

type StoreConfig added in v0.68.0

type StoreConfig struct {
	// Path is the store file path.
	Path string `json:"path,omitempty"`
}

StoreConfig configures the built-in store source.

func (*StoreConfig) IsEnabled added in v0.68.0

func (c *StoreConfig) IsEnabled() bool

IsEnabled returns true if the store is configured with a valid path.

type TCPMultiplexerType

type TCPMultiplexerType string
const (
	TCPMultiplexerHTTPConnect TCPMultiplexerType = "httpconnect"
)

type TCPMuxProxyConfig

type TCPMuxProxyConfig struct {
	ProxyBaseConfig
	DomainConfig

	HTTPUser        string `json:"httpUser,omitempty"`
	HTTPPassword    string `json:"httpPassword,omitempty"`
	RouteByHTTPUser string `json:"routeByHTTPUser,omitempty"`
	Multiplexer     string `json:"multiplexer,omitempty"`
}

func (*TCPMuxProxyConfig) Clone added in v0.68.0

func (*TCPMuxProxyConfig) MarshalToMsg

func (c *TCPMuxProxyConfig) MarshalToMsg(m *msg.NewProxy)

func (*TCPMuxProxyConfig) UnmarshalFromMsg

func (c *TCPMuxProxyConfig) UnmarshalFromMsg(m *msg.NewProxy)

type TCPProxyConfig

type TCPProxyConfig struct {
	ProxyBaseConfig

	RemotePort int `json:"remotePort,omitempty"`
}

func (*TCPProxyConfig) Clone added in v0.68.0

func (c *TCPProxyConfig) Clone() ProxyConfigurer

func (*TCPProxyConfig) MarshalToMsg

func (c *TCPProxyConfig) MarshalToMsg(m *msg.NewProxy)

func (*TCPProxyConfig) UnmarshalFromMsg

func (c *TCPProxyConfig) UnmarshalFromMsg(m *msg.NewProxy)

type TLS2RawPluginOptions added in v0.60.0

type TLS2RawPluginOptions struct {
	Type      string `json:"type,omitempty"`
	LocalAddr string `json:"localAddr,omitempty"`
	CrtPath   string `json:"crtPath,omitempty"`
	KeyPath   string `json:"keyPath,omitempty"`
}

func (*TLS2RawPluginOptions) Clone added in v0.68.0

func (*TLS2RawPluginOptions) Complete added in v0.60.0

func (o *TLS2RawPluginOptions) Complete()

type TLSClientConfig

type TLSClientConfig struct {
	// TLSEnable specifies whether or not TLS should be used when communicating
	// with the server. If "tls.certFile" and "tls.keyFile" are valid,
	// client will load the supplied tls configuration.
	// Since v0.50.0, the default value has been changed to true, and tls is enabled by default.
	Enable *bool `json:"enable,omitempty"`
	// If DisableCustomTLSFirstByte is set to false, frpc will establish a connection with frps using the
	// first custom byte when tls is enabled.
	// Since v0.50.0, the default value has been changed to true, and the first custom byte is disabled by default.
	DisableCustomTLSFirstByte *bool `json:"disableCustomTLSFirstByte,omitempty"`

	TLSConfig
}

func (*TLSClientConfig) Complete

func (c *TLSClientConfig) Complete()

type TLSConfig

type TLSConfig struct {
	// CertFile specifies the path of the cert file that client will load.
	CertFile string `json:"certFile,omitempty"`
	// KeyFile specifies the path of the secret key file that client will load.
	KeyFile string `json:"keyFile,omitempty"`
	// TrustedCaFile specifies the path of the trusted ca file that will load.
	TrustedCaFile string `json:"trustedCaFile,omitempty"`
	// ServerName specifies the custom server name of tls certificate. By
	// default, server name if same to ServerAddr.
	ServerName string `json:"serverName,omitempty"`
}

type TLSServerConfig

type TLSServerConfig struct {
	// Force specifies whether to only accept TLS-encrypted connections.
	Force bool `json:"force,omitempty"`

	TLSConfig
}

type TypedClientPluginOptions

type TypedClientPluginOptions struct {
	Type string `json:"type"`
	ClientPluginOptions
}

func DecodeClientPluginOptionsJSON added in v0.68.0

func DecodeClientPluginOptionsJSON(b []byte, options DecodeOptions) (TypedClientPluginOptions, error)

func (TypedClientPluginOptions) Clone added in v0.68.0

func (*TypedClientPluginOptions) MarshalJSON added in v0.58.1

func (c *TypedClientPluginOptions) MarshalJSON() ([]byte, error)

func (*TypedClientPluginOptions) UnmarshalJSON

func (c *TypedClientPluginOptions) UnmarshalJSON(b []byte) error

type TypedProxyConfig

type TypedProxyConfig struct {
	Type string `json:"type"`
	ProxyConfigurer
}

func (*TypedProxyConfig) MarshalJSON added in v0.58.1

func (c *TypedProxyConfig) MarshalJSON() ([]byte, error)

func (*TypedProxyConfig) UnmarshalJSON

func (c *TypedProxyConfig) UnmarshalJSON(b []byte) error

type TypedVisitorConfig

type TypedVisitorConfig struct {
	Type string `json:"type"`
	VisitorConfigurer
}

func (*TypedVisitorConfig) MarshalJSON added in v0.58.1

func (c *TypedVisitorConfig) MarshalJSON() ([]byte, error)

func (*TypedVisitorConfig) UnmarshalJSON

func (c *TypedVisitorConfig) UnmarshalJSON(b []byte) error

type TypedVisitorPluginOptions added in v0.62.0

type TypedVisitorPluginOptions struct {
	Type string `json:"type"`
	VisitorPluginOptions
}

func DecodeVisitorPluginOptionsJSON added in v0.68.0

func DecodeVisitorPluginOptionsJSON(b []byte, options DecodeOptions) (TypedVisitorPluginOptions, error)

func (TypedVisitorPluginOptions) Clone added in v0.68.0

func (*TypedVisitorPluginOptions) MarshalJSON added in v0.62.0

func (c *TypedVisitorPluginOptions) MarshalJSON() ([]byte, error)

func (*TypedVisitorPluginOptions) UnmarshalJSON added in v0.62.0

func (c *TypedVisitorPluginOptions) UnmarshalJSON(b []byte) error

type UDPProxyConfig

type UDPProxyConfig struct {
	ProxyBaseConfig

	RemotePort int `json:"remotePort,omitempty"`
}

func (*UDPProxyConfig) Clone added in v0.68.0

func (c *UDPProxyConfig) Clone() ProxyConfigurer

func (*UDPProxyConfig) MarshalToMsg

func (c *UDPProxyConfig) MarshalToMsg(m *msg.NewProxy)

func (*UDPProxyConfig) UnmarshalFromMsg

func (c *UDPProxyConfig) UnmarshalFromMsg(m *msg.NewProxy)

type UnixDomainSocketPluginOptions

type UnixDomainSocketPluginOptions struct {
	Type     string `json:"type,omitempty"`
	UnixPath string `json:"unixPath,omitempty"`
}

func (*UnixDomainSocketPluginOptions) Clone added in v0.68.0

func (*UnixDomainSocketPluginOptions) Complete added in v0.59.0

func (o *UnixDomainSocketPluginOptions) Complete()

type ValueSource added in v0.64.0

type ValueSource struct {
	Type string      `json:"type"`
	File *FileSource `json:"file,omitempty"`
	Exec *ExecSource `json:"exec,omitempty"`
}

ValueSource provides a way to dynamically resolve configuration values from various sources like files, environment variables, or external services.

func (*ValueSource) Resolve added in v0.64.0

func (v *ValueSource) Resolve(ctx context.Context) (string, error)

Resolve resolves the value from the configured source.

func (*ValueSource) Validate added in v0.64.0

func (v *ValueSource) Validate() error

Validate validates the ValueSource configuration.

type VirtualNetConfig added in v0.62.0

type VirtualNetConfig struct {
	Address string `json:"address,omitempty"`
}

type VirtualNetPluginOptions added in v0.62.0

type VirtualNetPluginOptions struct {
	Type string `json:"type,omitempty"`
}

func (*VirtualNetPluginOptions) Clone added in v0.68.0

func (*VirtualNetPluginOptions) Complete added in v0.62.0

func (o *VirtualNetPluginOptions) Complete()

type VirtualNetVisitorPluginOptions added in v0.62.0

type VirtualNetVisitorPluginOptions struct {
	Type          string `json:"type"`
	DestinationIP string `json:"destinationIP"`
}

func (*VirtualNetVisitorPluginOptions) Clone added in v0.68.0

func (*VirtualNetVisitorPluginOptions) Complete added in v0.62.0

func (o *VirtualNetVisitorPluginOptions) Complete()

type VisitorBaseConfig

type VisitorBaseConfig struct {
	Name string `json:"name"`
	Type string `json:"type"`
	// Enabled controls whether this visitor is enabled. nil or true means enabled, false means disabled.
	// This allows individual control over each visitor, complementing the global "start" field.
	Enabled   *bool            `json:"enabled,omitempty"`
	Transport VisitorTransport `json:"transport,omitempty"`
	SecretKey string           `json:"secretKey,omitempty"`
	// if the server user is not set, it defaults to the current user
	ServerUser string `json:"serverUser,omitempty"`
	ServerName string `json:"serverName,omitempty"`
	BindAddr   string `json:"bindAddr,omitempty"`
	// BindPort is the port that visitor listens on.
	// It can be less than 0, it means don't bind to the port and only receive connections redirected from
	// other visitors. (This is not supported for SUDP now)
	BindPort int `json:"bindPort,omitempty"`

	// Plugin specifies what plugin should be used.
	Plugin TypedVisitorPluginOptions `json:"plugin,omitempty"`
}

func (VisitorBaseConfig) Clone added in v0.68.0

func (*VisitorBaseConfig) Complete

func (c *VisitorBaseConfig) Complete()

func (*VisitorBaseConfig) GetBaseConfig

func (c *VisitorBaseConfig) GetBaseConfig() *VisitorBaseConfig

type VisitorConfigurer

type VisitorConfigurer interface {
	Complete()
	GetBaseConfig() *VisitorBaseConfig
	Clone() VisitorConfigurer
}

func DecodeVisitorConfigurerJSON added in v0.68.0

func DecodeVisitorConfigurerJSON(b []byte, options DecodeOptions) (VisitorConfigurer, error)

func NewVisitorConfigurerByType

func NewVisitorConfigurerByType(t VisitorType) VisitorConfigurer

type VisitorPluginOptions added in v0.62.0

type VisitorPluginOptions interface {
	Complete()
	Clone() VisitorPluginOptions
}

type VisitorTransport

type VisitorTransport struct {
	UseEncryption  bool `json:"useEncryption,omitempty"`
	UseCompression bool `json:"useCompression,omitempty"`
}

type VisitorType

type VisitorType string
const (
	VisitorTypeSTCP VisitorType = "stcp"
	VisitorTypeXTCP VisitorType = "xtcp"
	VisitorTypeSUDP VisitorType = "sudp"
)

type WebServerConfig

type WebServerConfig struct {
	// This is the network address to bind on for serving the web interface and API.
	// By default, this value is "127.0.0.1".
	Addr string `json:"addr,omitempty"`
	// Port specifies the port for the web server to listen on. If this
	// value is 0, the admin server will not be started.
	Port int `json:"port,omitempty"`
	// User specifies the username that the web server will use for login.
	User string `json:"user,omitempty"`
	// Password specifies the password that the admin server will use for login.
	Password string `json:"password,omitempty"`
	// AssetsDir specifies the local directory that the admin server will load
	// resources from. If this value is "", assets will be loaded from the
	// bundled executable using embed package.
	AssetsDir string `json:"assetsDir,omitempty"`
	// Enable golang pprof handlers.
	PprofEnable bool `json:"pprofEnable,omitempty"`
	// Enable TLS if TLSConfig is not nil.
	TLS *TLSConfig `json:"tls,omitempty"`
}

func (*WebServerConfig) Complete

func (c *WebServerConfig) Complete()

type XTCPProxyConfig

type XTCPProxyConfig struct {
	ProxyBaseConfig

	Secretkey  string   `json:"secretKey,omitempty"`
	AllowUsers []string `json:"allowUsers,omitempty"`

	// NatTraversal configuration for NAT traversal
	NatTraversal *NatTraversalConfig `json:"natTraversal,omitempty"`
}

func (*XTCPProxyConfig) Clone added in v0.68.0

func (c *XTCPProxyConfig) Clone() ProxyConfigurer

func (*XTCPProxyConfig) MarshalToMsg

func (c *XTCPProxyConfig) MarshalToMsg(m *msg.NewProxy)

func (*XTCPProxyConfig) UnmarshalFromMsg

func (c *XTCPProxyConfig) UnmarshalFromMsg(m *msg.NewProxy)

type XTCPVisitorConfig

type XTCPVisitorConfig struct {
	VisitorBaseConfig

	Protocol          string `json:"protocol,omitempty"`
	KeepTunnelOpen    bool   `json:"keepTunnelOpen,omitempty"`
	MaxRetriesAnHour  int    `json:"maxRetriesAnHour,omitempty"`
	MinRetryInterval  int    `json:"minRetryInterval,omitempty"`
	FallbackTo        string `json:"fallbackTo,omitempty"`
	FallbackTimeoutMs int    `json:"fallbackTimeoutMs,omitempty"`

	// NatTraversal configuration for NAT traversal
	NatTraversal *NatTraversalConfig `json:"natTraversal,omitempty"`
}

func (*XTCPVisitorConfig) Clone added in v0.68.0

func (*XTCPVisitorConfig) Complete

func (c *XTCPVisitorConfig) Complete()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL