123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- package v1
- import (
- "os"
- "github.com/samber/lo"
- "github.com/fatedier/frp/pkg/util/util"
- )
- type ClientConfig struct {
- ClientCommonConfig
- Proxies []TypedProxyConfig `json:"proxies,omitempty"`
- Visitors []TypedVisitorConfig `json:"visitors,omitempty"`
- }
- type ClientCommonConfig struct {
- APIMetadata
- Auth AuthClientConfig `json:"auth,omitempty"`
-
-
-
- User string `json:"user,omitempty"`
-
-
- ServerAddr string `json:"serverAddr,omitempty"`
-
-
- ServerPort int `json:"serverPort,omitempty"`
-
- NatHoleSTUNServer string `json:"natHoleStunServer,omitempty"`
-
-
- DNSServer string `json:"dnsServer,omitempty"`
-
-
-
- LoginFailExit *bool `json:"loginFailExit,omitempty"`
-
-
-
- Start []string `json:"start,omitempty"`
- Log LogConfig `json:"log,omitempty"`
- WebServer WebServerConfig `json:"webServer,omitempty"`
- Transport ClientTransportConfig `json:"transport,omitempty"`
-
-
- UDPPacketSize int64 `json:"udpPacketSize,omitempty"`
-
- Metadatas map[string]string `json:"metadatas,omitempty"`
-
- IncludeConfigFiles []string `json:"includes,omitempty"`
- }
- func (c *ClientCommonConfig) Complete() {
- c.ServerAddr = util.EmptyOr(c.ServerAddr, "0.0.0.0")
- c.ServerPort = util.EmptyOr(c.ServerPort, 7000)
- c.LoginFailExit = util.EmptyOr(c.LoginFailExit, lo.ToPtr(true))
- c.NatHoleSTUNServer = util.EmptyOr(c.NatHoleSTUNServer, "stun.easyvoip.com:3478")
- c.Auth.Complete()
- c.Log.Complete()
- c.Transport.Complete()
- c.WebServer.Complete()
- c.UDPPacketSize = util.EmptyOr(c.UDPPacketSize, 1500)
- }
- type ClientTransportConfig struct {
-
-
-
- Protocol string `json:"protocol,omitempty"`
-
- DialServerTimeout int64 `json:"dialServerTimeout,omitempty"`
-
-
- DialServerKeepAlive int64 `json:"dialServerKeepalive,omitempty"`
-
-
- ConnectServerLocalIP string `json:"connectServerLocalIP,omitempty"`
-
-
-
- ProxyURL string `json:"proxyURL,omitempty"`
-
-
- PoolCount int `json:"poolCount,omitempty"`
-
-
-
-
- TCPMux *bool `json:"tcpMux,omitempty"`
-
-
- TCPMuxKeepaliveInterval int64 `json:"tcpMuxKeepaliveInterval,omitempty"`
-
- QUIC QUICOptions `json:"quic,omitempty"`
-
-
-
- HeartbeatInterval int64 `json:"heartbeatInterval,omitempty"`
-
-
-
- HeartbeatTimeout int64 `json:"heartbeatTimeout,omitempty"`
-
- TLS TLSClientConfig `json:"tls,omitempty"`
- }
- func (c *ClientTransportConfig) Complete() {
- c.Protocol = util.EmptyOr(c.Protocol, "tcp")
- c.DialServerTimeout = util.EmptyOr(c.DialServerTimeout, 10)
- c.DialServerKeepAlive = util.EmptyOr(c.DialServerKeepAlive, 7200)
- c.ProxyURL = util.EmptyOr(c.ProxyURL, os.Getenv("http_proxy"))
- c.PoolCount = util.EmptyOr(c.PoolCount, 1)
- c.TCPMux = util.EmptyOr(c.TCPMux, lo.ToPtr(true))
- c.TCPMuxKeepaliveInterval = util.EmptyOr(c.TCPMuxKeepaliveInterval, 30)
- if lo.FromPtr(c.TCPMux) {
-
- c.HeartbeatInterval = util.EmptyOr(c.HeartbeatInterval, -1)
- c.HeartbeatTimeout = util.EmptyOr(c.HeartbeatTimeout, -1)
- } else {
- c.HeartbeatInterval = util.EmptyOr(c.HeartbeatInterval, 30)
- c.HeartbeatTimeout = util.EmptyOr(c.HeartbeatTimeout, 90)
- }
- c.QUIC.Complete()
- c.TLS.Complete()
- }
- type TLSClientConfig struct {
-
-
-
-
- Enable *bool `json:"enable,omitempty"`
-
-
-
- DisableCustomTLSFirstByte *bool `json:"disableCustomTLSFirstByte,omitempty"`
- TLSConfig
- }
- func (c *TLSClientConfig) Complete() {
- c.Enable = util.EmptyOr(c.Enable, lo.ToPtr(true))
- c.DisableCustomTLSFirstByte = util.EmptyOr(c.DisableCustomTLSFirstByte, lo.ToPtr(true))
- }
- type AuthClientConfig struct {
-
-
-
-
- Method AuthMethod `json:"method,omitempty"`
-
-
- AdditionalScopes []AuthScope `json:"additionalScopes,omitempty"`
-
-
-
- Token string `json:"token,omitempty"`
- OIDC AuthOIDCClientConfig `json:"oidc,omitempty"`
- }
- func (c *AuthClientConfig) Complete() {
- c.Method = util.EmptyOr(c.Method, "token")
- }
- type AuthOIDCClientConfig struct {
-
- ClientID string `json:"clientID,omitempty"`
-
-
- ClientSecret string `json:"clientSecret,omitempty"`
-
- Audience string `json:"audience,omitempty"`
-
- Scope string `json:"scope,omitempty"`
-
-
- TokenEndpointURL string `json:"tokenEndpointURL,omitempty"`
-
-
- AdditionalEndpointParams map[string]string `json:"additionalEndpointParams,omitempty"`
- }
|