123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- package v1
- import (
- "github.com/samber/lo"
- "github.com/fatedier/frp/pkg/config/types"
- "github.com/fatedier/frp/pkg/util/util"
- )
- type ServerConfig struct {
- APIMetadata
- Auth AuthServerConfig `json:"auth,omitempty"`
-
-
- BindAddr string `json:"bindAddr,omitempty"`
-
-
- BindPort int `json:"bindPort,omitempty"`
-
-
- KCPBindPort int `json:"kcpBindPort,omitempty"`
-
-
- QUICBindPort int `json:"quicBindPort,omitempty"`
-
-
- ProxyBindAddr string `json:"proxyBindAddr,omitempty"`
-
-
-
- VhostHTTPPort int `json:"vhostHTTPPort,omitempty"`
-
-
- VhostHTTPTimeout int64 `json:"vhostHTTPTimeout,omitempty"`
-
-
-
- VhostHTTPSPort int `json:"vhostHTTPSPort,omitempty"`
-
-
-
-
- TCPMuxHTTPConnectPort int `json:"tcpmuxHTTPConnectPort,omitempty"`
-
- TCPMuxPassthrough bool `json:"tcpmuxPassthrough,omitempty"`
-
-
-
-
- SubDomainHost string `json:"subDomainHost,omitempty"`
-
-
- Custom404Page string `json:"custom404Page,omitempty"`
- SSHTunnelGateway SSHTunnelGateway `json:"sshTunnelGateway,omitempty"`
- WebServer WebServerConfig `json:"webServer,omitempty"`
-
-
- EnablePrometheus bool `json:"enablePrometheus,omitempty"`
- Log LogConfig `json:"log,omitempty"`
- Transport ServerTransportConfig `json:"transport,omitempty"`
-
-
- DetailedErrorsToClient *bool `json:"detailedErrorsToClient,omitempty"`
-
-
- MaxPortsPerClient int64 `json:"maxPortsPerClient,omitempty"`
-
-
- UserConnTimeout int64 `json:"userConnTimeout,omitempty"`
-
-
- UDPPacketSize int64 `json:"udpPacketSize,omitempty"`
-
- NatHoleAnalysisDataReserveHours int64 `json:"natholeAnalysisDataReserveHours,omitempty"`
- AllowPorts []types.PortsRange `json:"allowPorts,omitempty"`
- HTTPPlugins []HTTPPluginOptions `json:"httpPlugins,omitempty"`
- }
- func (c *ServerConfig) Complete() {
- c.Auth.Complete()
- c.Log.Complete()
- c.Transport.Complete()
- c.WebServer.Complete()
- c.SSHTunnelGateway.Complete()
- c.BindAddr = util.EmptyOr(c.BindAddr, "0.0.0.0")
- c.BindPort = util.EmptyOr(c.BindPort, 7000)
- if c.ProxyBindAddr == "" {
- c.ProxyBindAddr = c.BindAddr
- }
- if c.WebServer.Port > 0 {
- c.WebServer.Addr = util.EmptyOr(c.WebServer.Addr, "0.0.0.0")
- }
- c.VhostHTTPTimeout = util.EmptyOr(c.VhostHTTPTimeout, 60)
- c.DetailedErrorsToClient = util.EmptyOr(c.DetailedErrorsToClient, lo.ToPtr(true))
- c.UserConnTimeout = util.EmptyOr(c.UserConnTimeout, 10)
- c.UDPPacketSize = util.EmptyOr(c.UDPPacketSize, 1500)
- c.NatHoleAnalysisDataReserveHours = util.EmptyOr(c.NatHoleAnalysisDataReserveHours, 7*24)
- }
- type AuthServerConfig struct {
- Method AuthMethod `json:"method,omitempty"`
- AdditionalScopes []AuthScope `json:"additionalScopes,omitempty"`
- Token string `json:"token,omitempty"`
- OIDC AuthOIDCServerConfig `json:"oidc,omitempty"`
- }
- func (c *AuthServerConfig) Complete() {
- c.Method = util.EmptyOr(c.Method, "token")
- }
- type AuthOIDCServerConfig struct {
-
-
-
- Issuer string `json:"issuer,omitempty"`
-
-
- Audience string `json:"audience,omitempty"`
-
-
- SkipExpiryCheck bool `json:"skipExpiryCheck,omitempty"`
-
-
- SkipIssuerCheck bool `json:"skipIssuerCheck,omitempty"`
- }
- type ServerTransportConfig struct {
-
-
-
-
- TCPMux *bool `json:"tcpMux,omitempty"`
-
-
- TCPMuxKeepaliveInterval int64 `json:"tcpMuxKeepaliveInterval,omitempty"`
-
-
- TCPKeepAlive int64 `json:"tcpKeepalive,omitempty"`
-
-
- MaxPoolCount int64 `json:"maxPoolCount,omitempty"`
-
-
-
- HeartbeatTimeout int64 `json:"heartbeatTimeout,omitempty"`
-
- QUIC QUICOptions `json:"quic,omitempty"`
-
- TLS TLSServerConfig `json:"tls,omitempty"`
- }
- func (c *ServerTransportConfig) Complete() {
- c.TCPMux = util.EmptyOr(c.TCPMux, lo.ToPtr(true))
- c.TCPMuxKeepaliveInterval = util.EmptyOr(c.TCPMuxKeepaliveInterval, 30)
- c.TCPKeepAlive = util.EmptyOr(c.TCPKeepAlive, 7200)
- c.MaxPoolCount = util.EmptyOr(c.MaxPoolCount, 5)
- if lo.FromPtr(c.TCPMux) {
-
- c.HeartbeatTimeout = util.EmptyOr(c.HeartbeatTimeout, -1)
- } else {
- c.HeartbeatTimeout = util.EmptyOr(c.HeartbeatTimeout, 90)
- }
- c.QUIC.Complete()
- if c.TLS.TrustedCaFile != "" {
- c.TLS.Force = true
- }
- }
- type TLSServerConfig struct {
-
- Force bool `json:"force,omitempty"`
- TLSConfig
- }
- type SSHTunnelGateway struct {
- BindPort int `json:"bindPort,omitempty"`
- PrivateKeyFile string `json:"privateKeyFile,omitempty"`
- AutoGenPrivateKeyPath string `json:"autoGenPrivateKeyPath,omitempty"`
- AuthorizedKeysFile string `json:"authorizedKeysFile,omitempty"`
- }
- func (c *SSHTunnelGateway) Complete() {
- c.AutoGenPrivateKeyPath = util.EmptyOr(c.AutoGenPrivateKeyPath, "./.autogen_ssh_key")
- }
|