Documentation ¶
Index ¶
- Constants
- func ClientCommonToV1(c *ClientCommon) (r v1.ClientCommonConfig)
- func Expiry(configPath string, del AutoDelete) (time.Duration, error)
- func UnmarshalAppConf(path string, dst *App) error
- type App
- type AutoDelete
- type BaseProxyConf
- type ClientAuth
- type ClientCommon
- type ClientConfig
- func (conf *ClientConfig) AddItem(item interface{}) bool
- func (conf *ClientConfig) AutoStart() bool
- func (conf *ClientConfig) Complete(read bool)
- func (conf *ClientConfig) Copy(all bool) Config
- func (conf *ClientConfig) CountStart() int
- func (conf *ClientConfig) DeleteItem(index int)
- func (conf *ClientConfig) Expiry() bool
- func (conf *ClientConfig) Ext() string
- func (conf *ClientConfig) GetLogFile() string
- func (conf *ClientConfig) GetSTUNServer() string
- func (conf *ClientConfig) ItemAt(index int) interface{}
- func (conf *ClientConfig) Items() interface{}
- func (conf *ClientConfig) Save(path string) error
- type ClientConfigV1
- type Config
- type DefaultValue
- type HealthCheckConf
- type Mgr
- type PluginParams
- type Proxy
- type ProxyMgr
- type RangePort
- type TypedProxyConfig
- type TypedVisitorConfig
Constants ¶
const DefaultAppFile = "app.json"
Variables ¶
This section is empty.
Functions ¶
func ClientCommonToV1 ¶ added in v1.16.0
func ClientCommonToV1(c *ClientCommon) (r v1.ClientCommonConfig)
func Expiry ¶ added in v1.12.0
func Expiry(configPath string, del AutoDelete) (time.Duration, error)
Expiry returns the remaining duration, after which a config will expire. If a config has no expiry date, an `ErrNoDeadline` error is returned.
func UnmarshalAppConf ¶ added in v1.16.0
Types ¶
type App ¶ added in v1.12.0
type App struct { Lang string `json:"lang,omitempty"` Password string `json:"password,omitempty"` Defaults DefaultValue `json:"defaults"` }
type AutoDelete ¶ added in v1.13.0
type AutoDelete struct { // DeleteMethod specifies what delete method to use to delete the config. // If "absolute" is specified, the expiry date is set in config. If "relative" is specified, the expiry date // is calculated by adding the days to the file modification time. If it's empty, the config has no expiry date. DeleteMethod string `ini:"frpmgr_delete_method,omitempty" json:"method,omitempty"` // DeleteAfterDays is the number of days a config will be kept, after which it may be stopped and deleted. DeleteAfterDays int64 `ini:"frpmgr_delete_after_days,omitempty" relative:"true" json:"afterDays,omitempty"` // DeleteAfterDate is the last date the config will be valid, after which it may be stopped and deleted. DeleteAfterDate time.Time `ini:"frpmgr_delete_after_date,omitempty" absolute:"true" json:"afterDate,omitempty"` }
func (AutoDelete) Complete ¶ added in v1.13.0
func (ad AutoDelete) Complete() AutoDelete
type BaseProxyConf ¶
type BaseProxyConf struct { // Name is the name of this proxy. Name string `ini:"-"` // Type specifies the type of this. Valid values include tcp, udp, // xtcp, stcp, sudp, http, https, tcpmux. By default, this value is "tcp". Type string `ini:"type,omitempty"` // UseEncryption controls whether communication with the server will // be encrypted. Encryption is done using the tokens supplied in the server // and client configuration. By default, this value is false. UseEncryption bool `ini:"use_encryption,omitempty"` // UseCompression controls whether communication with the server // will be compressed. By default, this value is false. UseCompression bool `ini:"use_compression,omitempty"` // Group specifies which group the proxy 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. By default, this value is "". Group string `ini:"group,omitempty"` // GroupKey specifies a group key, which should be the same among proxies // of the same group. By default, this value is "". GroupKey string `ini:"group_key,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 `ini:"proxy_protocol_version,omitempty"` // BandwidthLimit limits the bandwidth. // 0 means no limit. BandwidthLimit string `ini:"bandwidth_limit,omitempty"` BandwidthLimitMode string `ini:"bandwidth_limit_mode,omitempty"` // LocalIP specifies the IP address or host name. LocalIP string `ini:"local_ip,omitempty"` // LocalPort specifies the port. LocalPort string `ini:"local_port,omitempty"` // Plugin specifies what plugin should be used for ng. If this value // is set, the LocalIp and LocalPort values will be ignored. By default, // this value is "". Plugin string `ini:"plugin,omitempty"` // PluginParams specify parameters to be passed to the plugin, if one is // being used. PluginParams `ini:",extends"` // HealthCheckType specifies what protocol to use for health checking. HealthCheckType string `ini:"health_check_type,omitempty"` // tcp | http // Health checking parameters. HealthCheckConf `ini:",extends"` // Meta info for each proxy Metas map[string]string `ini:"-"` // Annotations for each proxy Annotations map[string]string `ini:"-"` // Disabled defines whether to start the proxy. Disabled bool `ini:"-"` }
BaseProxyConf provides configuration info that is common to all types.
type ClientAuth ¶
type ClientAuth struct { AuthMethod string `ini:"authentication_method,omitempty"` AuthenticateHeartBeats bool `ini:"authenticate_heartbeats,omitempty" token:"true" oidc:"true"` AuthenticateNewWorkConns bool `ini:"authenticate_new_work_conns,omitempty" token:"true" oidc:"true"` Token string `ini:"token,omitempty" token:"true"` OIDCClientId string `ini:"oidc_client_id,omitempty" oidc:"true"` OIDCClientSecret string `ini:"oidc_client_secret,omitempty" oidc:"true"` OIDCAudience string `ini:"oidc_audience,omitempty" oidc:"true"` OIDCScope string `ini:"oidc_scope,omitempty" oidc:"true"` OIDCTokenEndpoint string `ini:"oidc_token_endpoint_url,omitempty" oidc:"true"` OIDCAdditionalEndpointParams map[string]string `ini:"-" oidc:"true"` }
func (ClientAuth) Complete ¶ added in v1.13.0
func (ca ClientAuth) Complete() ClientAuth
type ClientCommon ¶
type ClientCommon struct { v1.APIMetadata `ini:"-"` ClientAuth `ini:",extends"` ServerAddress string `ini:"server_addr,omitempty"` ServerPort int `ini:"server_port,omitempty"` NatHoleSTUNServer string `ini:"nat_hole_stun_server,omitempty"` DialServerTimeout int64 `ini:"dial_server_timeout,omitempty"` DialServerKeepAlive int64 `ini:"dial_server_keepalive,omitempty"` ConnectServerLocalIP string `ini:"connect_server_local_ip,omitempty"` HTTPProxy string `ini:"http_proxy,omitempty"` LogFile string `ini:"log_file,omitempty"` LogLevel string `ini:"log_level,omitempty"` LogMaxDays int64 `ini:"log_max_days,omitempty"` AdminAddr string `ini:"admin_addr,omitempty"` AdminPort int `ini:"admin_port,omitempty"` AdminUser string `ini:"admin_user,omitempty"` AdminPwd string `ini:"admin_pwd,omitempty"` AdminTLS v1.TLSConfig `ini:"-"` AssetsDir string `ini:"assets_dir,omitempty"` PoolCount int `ini:"pool_count,omitempty"` DNSServer string `ini:"dns_server,omitempty"` Protocol string `ini:"protocol,omitempty"` QUICKeepalivePeriod int `ini:"quic_keepalive_period,omitempty"` QUICMaxIdleTimeout int `ini:"quic_max_idle_timeout,omitempty"` QUICMaxIncomingStreams int `ini:"quic_max_incoming_streams,omitempty"` LoginFailExit bool `ini:"login_fail_exit"` User string `ini:"user,omitempty"` HeartbeatInterval int64 `ini:"heartbeat_interval,omitempty"` HeartbeatTimeout int64 `ini:"heartbeat_timeout,omitempty"` TCPMux bool `ini:"tcp_mux"` TCPMuxKeepaliveInterval int64 `ini:"tcp_mux_keepalive_interval,omitempty"` TLSEnable bool `ini:"tls_enable"` TLSCertFile string `ini:"tls_cert_file,omitempty"` TLSKeyFile string `ini:"tls_key_file,omitempty"` TLSTrustedCaFile string `ini:"tls_trusted_ca_file,omitempty"` TLSServerName string `ini:"tls_server_name,omitempty"` UDPPacketSize int64 `ini:"udp_packet_size,omitempty"` Start []string `ini:"start,omitempty"` PprofEnable bool `ini:"pprof_enable,omitempty"` DisableCustomTLSFirstByte bool `ini:"disable_custom_tls_first_byte"` // ManualStart defines whether to start the config on system boot. ManualStart bool `ini:"frpmgr_manual_start,omitempty"` // SVCBEnable resolves the SVCB record of server address. // By enabling this feature, the server address and port // can be updated dynamically. // // WARNING: This is an experimental feature. // It may affect the stability of the service. SVCBEnable bool `ini:"frpmgr_svcb_enable,omitempty"` // AutoDelete is a mechanism for temporary use. // The config will be stopped and deleted at some point. AutoDelete `ini:",extends"` // Client meta info Metas map[string]string `ini:"-"` // Config file format LegacyFormat bool `ini:"-"` }
func ClientCommonFromV1 ¶ added in v1.16.0
func ClientCommonFromV1(c *v1.ClientCommonConfig) (r ClientCommon)
type ClientConfig ¶
type ClientConfig struct { ClientCommon Proxies []*Proxy }
func NewDefaultClientConfig ¶
func NewDefaultClientConfig() *ClientConfig
func UnmarshalClientConf ¶ added in v1.16.0
func UnmarshalClientConf(source interface{}) (*ClientConfig, error)
func UnmarshalClientConfFromIni ¶
func UnmarshalClientConfFromIni(source interface{}) (*ClientConfig, error)
func (*ClientConfig) AddItem ¶
func (conf *ClientConfig) AddItem(item interface{}) bool
func (*ClientConfig) AutoStart ¶
func (conf *ClientConfig) AutoStart() bool
func (*ClientConfig) Complete ¶
func (conf *ClientConfig) Complete(read bool)
func (*ClientConfig) Copy ¶ added in v1.9.0
func (conf *ClientConfig) Copy(all bool) Config
func (*ClientConfig) CountStart ¶ added in v1.7.1
func (conf *ClientConfig) CountStart() int
CountStart returns the number of enabled proxies.
func (*ClientConfig) DeleteItem ¶
func (conf *ClientConfig) DeleteItem(index int)
func (*ClientConfig) Expiry ¶ added in v1.13.0
func (conf *ClientConfig) Expiry() bool
func (*ClientConfig) Ext ¶ added in v1.16.1
func (conf *ClientConfig) Ext() string
func (*ClientConfig) GetLogFile ¶
func (conf *ClientConfig) GetLogFile() string
func (*ClientConfig) GetSTUNServer ¶ added in v1.14.0
func (conf *ClientConfig) GetSTUNServer() string
func (*ClientConfig) ItemAt ¶
func (conf *ClientConfig) ItemAt(index int) interface{}
func (*ClientConfig) Items ¶
func (conf *ClientConfig) Items() interface{}
func (*ClientConfig) Save ¶
func (conf *ClientConfig) Save(path string) error
type ClientConfigV1 ¶ added in v1.16.0
type ClientConfigV1 struct { v1.ClientCommonConfig Proxies []TypedProxyConfig `json:"proxies,omitempty"` Visitors []TypedVisitorConfig `json:"visitors,omitempty"` Mgr Mgr `json:"frpmgr,omitempty"` }
func NewDefaultClientConfigV1 ¶ added in v1.16.0
func NewDefaultClientConfigV1() ClientConfigV1
type Config ¶
type Config interface { // Items returns all sections in this config. which must be a slice of pointer to struct. Items() interface{} // ItemAt returns the section in this config for the given index. ItemAt(index int) interface{} // DeleteItem deletes the section for the given index. DeleteItem(index int) // AddItem adds a section to this config. AddItem(item interface{}) bool // Save serializes this config and saves to the given path. Save(path string) error // Complete prunes and completes this config. // When "read" is true, the config should be completed for a file loaded from source. // Otherwise, it should be completed for file written to disk. Complete(read bool) // GetLogFile returns the log file path of this config. GetLogFile() string // AutoStart indicates whether this config should be started at boot. AutoStart() bool // Expiry indicates whether the config has an expiry date. Expiry() bool // GetSTUNServer returns the STUN server to help penetrate NAT hole. GetSTUNServer() string // Copy creates a new copy of this config. Copy(all bool) Config // Ext is the file extension of this config. Ext() string }
Config is the interface that a config must implement to support management.
type DefaultValue ¶ added in v1.16.0
type DefaultValue struct { Protocol string `json:"protocol,omitempty"` User string `json:"user,omitempty"` LogLevel string `json:"logLevel"` LogMaxDays int64 `json:"logMaxDays"` DeleteAfterDays int64 `json:"deleteAfterDays,omitempty"` DNSServer string `json:"dnsServer,omitempty"` NatHoleSTUNServer string `json:"natHoleStunServer,omitempty"` ConnectServerLocalIP string `json:"connectServerLocalIP,omitempty"` TCPMux bool `json:"tcpMux"` TLSEnable bool `json:"tls"` ManualStart bool `json:"manualStart,omitempty"` LegacyFormat bool `json:"legacyFormat,omitempty"` }
func (*DefaultValue) AsClientConfig ¶ added in v1.16.0
func (dv *DefaultValue) AsClientConfig() ClientCommon
type HealthCheckConf ¶
type HealthCheckConf struct { // HealthCheckTimeoutS 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. HealthCheckTimeoutS int `ini:"health_check_timeout_s,omitempty" tcp:"true" http:"true"` // HealthCheckMaxFailed specifies the number of allowed failures before the // is stopped. By default, this value is 1. HealthCheckMaxFailed int `ini:"health_check_max_failed,omitempty" tcp:"true" http:"true"` // HealthCheckIntervalS specifies the time in seconds between health // checks. By default, this value is 10. HealthCheckIntervalS int `ini:"health_check_interval_s,omitempty" tcp:"true" http:"true"` // HealthCheckURL specifies the address to send health checks to if the // health check type is "http". HealthCheckURL string `ini:"health_check_url,omitempty" http:"true"` // HealthCheckHTTPHeaders specifies the headers to send with the http request. HealthCheckHTTPHeaders map[string]string `ini:"-" http:"true"` }
HealthCheckConf configures health checking. This can be useful for load balancing purposes to detect and remove proxies to failing services.
type Mgr ¶ added in v1.16.0
type Mgr struct { ManualStart bool `json:"manualStart,omitempty"` SVCBEnable bool `json:"svcbEnable,omitempty"` AutoDelete AutoDelete `json:"autoDelete,omitempty"` }
type PluginParams ¶
type PluginParams struct { PluginLocalAddr string `ini:"plugin_local_addr,omitempty" http2https:"true" http2http:"true" https2https:"true" https2http:"true" tls2raw:"true"` PluginCrtPath string `ini:"plugin_crt_path,omitempty" https2https:"true" https2http:"true" tls2raw:"true"` PluginKeyPath string `ini:"plugin_key_path,omitempty" https2https:"true" https2http:"true" tls2raw:"true"` PluginHostHeaderRewrite string `ini:"plugin_host_header_rewrite,omitempty" http2https:"true" http2http:"true" https2https:"true" https2http:"true"` PluginHttpUser string `ini:"plugin_http_user,omitempty" http_proxy:"true" static_file:"true"` PluginHttpPasswd string `ini:"plugin_http_passwd,omitempty" http_proxy:"true" static_file:"true"` PluginUser string `ini:"plugin_user,omitempty" socks5:"true"` PluginPasswd string `ini:"plugin_passwd,omitempty" socks5:"true"` PluginLocalPath string `ini:"plugin_local_path,omitempty" static_file:"true"` PluginStripPrefix string `ini:"plugin_strip_prefix,omitempty" static_file:"true"` PluginUnixPath string `ini:"plugin_unix_path,omitempty" unix_domain_socket:"true"` PluginHeaders map[string]string `ini:"-" http2https:"true" http2http:"true" https2https:"true" https2http:"true"` PluginEnableHTTP2 bool `ini:"-" https2https:"true" https2http:"true"` }
type Proxy ¶
type Proxy struct { BaseProxyConf `ini:",extends"` RemotePort string `ini:"remote_port,omitempty" tcp:"true" udp:"true"` Role string `ini:"role,omitempty" stcp:"true" xtcp:"true" sudp:"true" visitor:"*"` SK string `ini:"sk,omitempty" stcp:"true" xtcp:"true" sudp:"true" visitor:"*"` AllowUsers string `ini:"allow_users,omitempty" stcp:"true" xtcp:"true" sudp:"true"` ServerUser string `ini:"server_user,omitempty" visitor:"*"` ServerName string `ini:"server_name,omitempty" visitor:"*"` BindAddr string `ini:"bind_addr,omitempty" visitor:"*"` BindPort int `ini:"bind_port,omitempty" visitor:"*"` CustomDomains string `ini:"custom_domains,omitempty" http:"true" https:"true" tcpmux:"true"` SubDomain string `ini:"subdomain,omitempty" http:"true" https:"true" tcpmux:"true"` Locations string `ini:"locations,omitempty" http:"true"` HTTPUser string `ini:"http_user,omitempty" http:"true" tcpmux:"true"` HTTPPwd string `ini:"http_pwd,omitempty" http:"true" tcpmux:"true"` HostHeaderRewrite string `ini:"host_header_rewrite,omitempty" http:"true"` Headers map[string]string `ini:"-" http:"true"` ResponseHeaders map[string]string `ini:"-" http:"true"` Multiplexer string `ini:"multiplexer,omitempty" tcpmux:"true"` RouteByHTTPUser string `ini:"route_by_http_user,omitempty" http:"true" tcpmux:"true"` // "kcp" or "quic" Protocol string `ini:"protocol,omitempty" visitor:"xtcp"` KeepTunnelOpen bool `ini:"keep_tunnel_open,omitempty" visitor:"xtcp"` MaxRetriesAnHour int `ini:"max_retries_an_hour,omitempty" visitor:"xtcp"` MinRetryInterval int `ini:"min_retry_interval,omitempty" visitor:"xtcp"` FallbackTo string `ini:"fallback_to,omitempty" visitor:"xtcp"` FallbackTimeoutMs int `ini:"fallback_timeout_ms,omitempty" visitor:"xtcp"` }
func ClientProxyFromV1 ¶ added in v1.16.0
func ClientProxyFromV1(pxyCfg TypedProxyConfig) *Proxy
func ClientVisitorFromV1 ¶ added in v1.16.0
func ClientVisitorFromV1(visitorCfg TypedVisitorConfig) *Proxy
func NewDefaultProxyConfig ¶ added in v1.8.0
func NewProxyFromIni ¶ added in v1.8.0
NewProxyFromIni creates a proxy object from ini section
func UnmarshalProxyFromIni ¶ added in v1.8.0
UnmarshalProxyFromIni finds a single proxy section and unmarshals it from ini source.
func (*Proxy) Complete ¶ added in v1.14.0
func (p *Proxy) Complete()
Complete removes redundant parameters base on the proxy type.
type TypedProxyConfig ¶ added in v1.16.0
type TypedProxyConfig struct { v1.TypedProxyConfig Mgr ProxyMgr `json:"frpmgr,omitempty"` }
func ClientProxyToV1 ¶ added in v1.16.0
func ClientProxyToV1(p *Proxy) ([]TypedProxyConfig, error)
func (*TypedProxyConfig) UnmarshalJSON ¶ added in v1.16.0
func (c *TypedProxyConfig) UnmarshalJSON(b []byte) error
type TypedVisitorConfig ¶ added in v1.18.0
type TypedVisitorConfig struct { v1.TypedVisitorConfig Mgr ProxyMgr `json:"frpmgr,omitempty"` }
func ClientVisitorToV1 ¶ added in v1.16.0
func ClientVisitorToV1(p *Proxy) TypedVisitorConfig
func (*TypedVisitorConfig) UnmarshalJSON ¶ added in v1.18.0
func (c *TypedVisitorConfig) UnmarshalJSON(b []byte) error