Documentation
¶
Index ¶
- type AccountGCConfig
- type AppConfig
- type AuthConfig
- type AuthConfigBasic
- type AuthConfigCode
- type AuthConfigToken
- type ClusterConfig
- type ClusterFailoverConfig
- type ClusterNodeConfig
- type Config
- type GrpcConfig
- type HttpConfig
- type MediaConfig
- type MediaConfigFS
- type PathsConfig
- type PluginConfig
- type PluginRpcFilterConfig
- type PprofConf
- type PushCommonConfig
- type PushCommonConfigPayload
- type PushConfig
- type PushFcmConfig
- type PushFcmConfigCredentials
- type SecretsConfig
- type StoreConfig
- type StorePostgresConfig
- type TlsAutocertConfig
- type TlsConfig
- type ValidatorConfig
- type ValidatorConfigEmail
- type WSConfig
- type WebRtcConfigIceServer
- type WebRtcVideoConfig
- type WebrtcConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountGCConfig ¶
type AccountGCConfig struct { Enabled bool `json:"enabled" mapstructure:"enabled"` // How often to run GC (seconds). GcPeriod int `json:"gc_period" mapstructure:"gc_period"` // Number of accounts to delete in one pass. GcBlockSize int `json:"gc_block_size" mapstructure:"gc_block_size"` // Minimum hours since account was last modified. GcMinAccountAge int `json:"gc_min_account_age" mapstructure:"gc_min_account_age"` }
Stale unvalidated user account GC config.
type AppConfig ¶
type AppConfig struct { PermanentAccount bool `json:"permanent_account" mapstructure:"permanent_account"` Version string `json:"version" mapstructure:"version"` BuildStampCommand string `json:"buildstamp_command" mapstructure:"buildstamp_command"` // 2-letter country code (ISO 3166-1 alpha-2) to assign to sessions by default // when the country isn't specified by the client explicitly and // it's impossible to infer it. DefaultCountryCode string `json:"default_country_code" mapstructure:"default_country_code"` // Masked tags: tags immutable on User (mask), mutable on Topic only within the mask. MaskedTagsNS []string `json:"masked_tags_ns" mapstructure:"masked_tags_ns"` }
type AuthConfig ¶
type AuthConfig struct { LogicalNames []string `json:"logical_names" mapstructure:"logical_names"` Basic *AuthConfigBasic `json:"basic" mapstructure:"basic"` Token *AuthConfigToken `json:"token" mapstructure:"token"` Code *AuthConfigCode `json:"code" mapstructure:"code"` }
type AuthConfigBasic ¶
type AuthConfigBasic struct { // Add 'auth-name:username' to tags making user discoverable by username. AddToTags bool `json:"add_to_tags" mapstructure:"add_to_tags"` // The minimum length of a login in unicode runes, i.e. "登录" is length 2, not 6. // // The maximum length is 32 and it cannot be changed. MinLoginLength int `json:"min_login_length" mapstructure:"min_login_length"` // The minimum length of a password in unicode runes, "пароль" is length 6, not 12. // // There is no limit on maximum length. MinPasswordLength int `json:"min_password_length" mapstructure:"min_password_length"` }
type AuthConfigCode ¶
type AuthConfigCode struct { // Lifetime of a security code in seconds. 900 seconds = 15 minutes. ExpireIn int `json:"expire_in" mapstructure:"expire_in"` // Number of times a user can try to enter the code. MaxRetries int `json:"max_retries" mapstructure:"max_retries"` // Length of the secret code. CodeLength int `json:"code_length" mapstructure:"code_length"` }
AuthConfigCode Short code authenticator for resetting passwords.
type AuthConfigToken ¶
type AuthConfigToken struct { // Lifetime of a security token in seconds. 1209600 = 2 weeks. ExpireIn int `json:"expire_in" mapstructure:"expire_in"` // Serial number of the token. Can be used to invalidate all issued tokens at once. SerialNumber int `json:"serial_number" mapstructure:"serial_number"` // Secret key (HMAC salt) for signing the tokens Any 32 random bytes base64 encoded. Key string `json:"key" mapstructure:"key"` }
type ClusterConfig ¶
type ClusterConfig struct { // List of all members of the cluster, including this member Nodes []ClusterNodeConfig `json:"nodes" mapstructure:"nodes"` // Name of this cluster node MainName string `json:"main_name" mapstructure:"main_name"` ClusterFailOver ClusterFailoverConfig `json:"cluster_fail_over" mapstructure:"cluster_fail_over"` }
type ClusterFailoverConfig ¶
type ClusterFailoverConfig struct { Enabled bool `json:"enabled" mapstructure:"enabled"` // Time in milliseconds between heartbeats Heartbeat int `json:"heartbeat" mapstructure:"heartbeat"` // Number of failed heartbeats before a leader election is initiated. VoteAfter int `json:"vote_after" mapstructure:"vote_after"` // Number of failures before a node is considered dead NodeFailures int `json:"node_failures" mapstructure:"node_failures"` }
type ClusterNodeConfig ¶
type Config ¶
type Config struct { App AppConfig `json:"app" mapstructure:"app"` Http HttpConfig `mapstructure:"http"` Paths PathsConfig `json:"paths" mapstructure:"paths"` WsConfig WSConfig `json:"ws_config" mapstructure:"ws_config"` GrpcConfig GrpcConfig `json:"grpc_config" mapstructure:"grpc_config"` Secrets SecretsConfig `json:"secrets" mapstructure:"secrets"` Media *MediaConfig `json:"media" mapstructure:"media"` PProf PprofConf `json:"pprof" mapstructure:"pprof"` // Configs for subsystems Cluster ClusterConfig `json:"cluster" mapstructure:"cluster"` Plugins []PluginConfig `json:"plugins" mapstructure:"plugins"` Store StoreConfig `json:"store" mapstructure:"store"` Push PushConfig `json:"push" mapstructure:"push"` Tls TlsConfig `json:"tls" mapstructure:"tls"` Auth AuthConfig `json:"auth" mapstructure:"auth"` Validator ValidatorConfig `json:"validator" mapstructure:"validator"` AccountGC *AccountGCConfig `json:"account_gc" mapstructure:"account_gc"` Webrtc *WebrtcConfig `json:"webrtc" mapstructure:"webrtc"` }
func LoadConfig ¶
type GrpcConfig ¶
type GrpcConfig struct { // Address:port to listen for gRPC clients Listen string `json:"listen" mapstructure:"listen"` // Enable handling of gRPC keepalives https://github.com/grpc/grpc/blob/master/doc/keepalive.md // This sets server's GRPC_ARG_KEEPALIVE_TIME_MS to 60 seconds instead of the default 2 hours. Keepalive bool `json:"keepalive" mapstructure:"keepalive"` }
type HttpConfig ¶
type HttpConfig struct { // Cache-Control value for static content. CacheControl int `json:"cache_control" mapstructure:"cache_control"` // Take IP address of the client from HTTP header 'X-Forwarded-For'. // Useful when chat app is behind a proxy. If missing, fallback to default RemoteAddr. UseXForwardedFor bool `json:"use_x_forwarded_for" mapstructure:"use_x_forwarded_for"` }
type MediaConfig ¶
type MediaConfig struct { // The name of the handler to use for file uploads. HandlerName string `json:"handler_name" mapstructure:"handler_name"` // Maximum allowed size of an uploaded file MaxFileUploadSize int64 `json:"max_file_upload_size" mapstructure:"max_file_upload_size"` // Garbage collection periodicity in seconds: unused or abandoned uploads are deleted. GcPeriod int `json:"gc_period" mapstructure:"gc_period"` // Number of entries to delete in one pass GcBlockSize int `json:"gc_block_size" mapstructure:"gc_block_size"` FS *MediaConfigFS `json:"fs" mapstructure:"fs"` }
type MediaConfigFS ¶
type MediaConfigFS struct { FileUploadDirectory string `json:"file_upload_directory" mapstructure:"file_upload_directory"` CacheControl string `json:"cache_control" mapstructure:"cache_control"` ServerURL string `json:"server_url" mapstructure:"server_url"` CorsOrigins []string `json:"cors_origins" mapstructure:"cors_origins"` }
type PathsConfig ¶
type PathsConfig struct { // HTTP(S) address:port to listen on for websocket and long polling clients. Either a // numeric or a canonical name, e.g. ":80" or ":https". Could include a host name, e.g. // "localhost:80". // Could be blank: if TLS is not configured, will use ":80", otherwise ":443". Listen string `json:"listen" mapstructure:"listen"` // URL path for exposing runtime stats. Disabled if the path is blank. Expvar string `json:"expvar" mapstructure:"expvar"` // Base URL path where the streaming and large file API calls are served, Api string `json:"api" mapstructure:"api"` // // URL path for mounting the directory with static files . StaticMount string `json:"static_mount" mapstructure:"static_mount"` // Local path to static files. All files in this path are made accessible by HTTP. StaticData string `json:"static_data" mapstructure:"static_data"` // URL path for internal server status. Disabled if the path is blank or "-" ServerStatus string `json:"server_status" mapstructure:"server_status"` PProf string `json:"pprof" mapstructure:"pprof"` }
type PluginConfig ¶
type PluginConfig struct { Enabled bool `json:"enabled" mapstructure:"enabled"` // Unique service name Name string `json:"name" mapstructure:"name"` // Microseconds to wait before timeout Timeout int `json:"timeout" mapstructure:"timeout"` // Filters for RPC calls: when to call vs when to skip the call Filters PluginRpcFilterConfig `json:"filters" mapstructure:"filters"` // What should the server do if plugin failed: HTTP error code FailureCode int `json:"failure_code" mapstructure:"failure_code"` // HTTP Error message to go with the code FailureMessage string `json:"failure_message" mapstructure:"failure_message"` // Address of plugin server of the form "tcp://localhost:123" or "unix://path_to_socket_file" ServiceAddr string `json:"service_addr" mapstructure:"service_addr"` }
type PluginRpcFilterConfig ¶
type PluginRpcFilterConfig struct { // Filter by packet name, topic type [or exact name - not supported yet]. 2D: "pub,pres;p2p,me" FireHose *string `json:"fire_host" mapstructure:"fire_host"` // Filter by CUD, [exact user name - not supported yet]. 1D: "C" Account *string `json:"account" mapstructure:"account"` // Filter by CUD, topic type[, exact name]: "p2p;CU" Topic *string `json:"topic" mapstructure:"topic"` // Filter by CUD, topic type[, exact topic name, exact user name]: "CU" Subscription *string `json:"subscription" mapstructure:"subscription"` // Filter by C.D, topic type[, exact topic name, exact user name]: "grp;CD" Message *string `json:"message" mapstructure:"message"` // Call Find service Find bool `json:"find" mapstructure:"find"` }
PluginRpcFilterConfig filters for an individual RPC call. Filter strings are formatted as follows: <comma separated list of packet names> ; <comma separated list of topics or topic types> ; <actions (combination of C U D)>
For instance: "acc,login;;CU" - grab packets {acc} or {login}; no filtering by topic, Create or Update action "pub,pres;me,p2p;"
type PprofConf ¶
type PprofConf struct { // FileName to save profiling info FileName string `json:"file_name" mapstructure:"file_name"` }
type PushCommonConfig ¶
type PushCommonConfig struct { Enabled bool `json:"enabled,omitempty" mapstructure:"enabled"` // Common defaults for all push types. PushCommonConfigPayload `mapstructure:"push_common_config_payload"` // Configs for specific push types. Msg PushCommonConfigPayload `json:"msg,omitempty" mapstructure:"msg"` Sub PushCommonConfigPayload `json:"sub,omitempty" mapstructure:"sub"` }
PushCommonConfig is the configuration of a Notification payload.
type PushCommonConfigPayload ¶
type PushCommonConfigPayload struct { // Common for APNS and Android Body string `json:"body,omitempty" mapstructure:"body"` Title string `json:"title,omitempty" mapstructure:"title"` TitleLocKey string `json:"title_loc_key,omitempty" mapstructure:"title_loc_key"` TitleLocArgs []string `json:"title_loc_args,omitempty" mapstructure:"title_loc_args"` // Android BodyLocKey string `json:"body_loc_key,omitempty" mapstructure:"body_loc_key"` BodyLocArgs []string `json:"body_loc_args,omitempty" mapstructure:"body_loc_args"` Icon string `json:"icon,omitempty" mapstructure:"icon"` Color string `json:"color,omitempty" mapstructure:"color"` ClickAction string `json:"click_action,omitempty" mapstructure:"click_action"` Sound string `json:"sound,omitempty" mapstructure:"sound"` Image string `json:"image,omitempty" mapstructure:"image"` // APNS Action string `json:"action,omitempty" mapstructure:"action"` ActionLocKey string `json:"action_loc_key,omitempty" mapstructure:"action_loc_key"` LaunchImage string `json:"launch_image,omitempty" mapstructure:"launch_image"` LocArgs []string `json:"loc_args,omitempty" mapstructure:"loc_args"` LocKey string `json:"loc_key,omitempty" mapstructure:"loc_key"` Subtitle string `json:"subtitle,omitempty" mapstructure:"subtitle"` SummaryArg string `json:"summary_arg,omitempty" mapstructure:"summary_arg"` SummaryArgCount int `json:"summary_arg_count,omitempty" mapstructure:"summary_arg_count"` }
PushCommonConfigPayload to be sent for a specific notification type.
type PushConfig ¶
type PushConfig struct { Name string FCM *PushFcmConfig }
type PushFcmConfig ¶
type PushFcmConfig struct { Enabled bool `json:"enabled" mapstructure:"enabled"` DryRun bool `json:"dry_run" mapstructure:"dry_run"` Credentials PushFcmConfigCredentials `json:"credentials" mapstructure:"credentials"` CredentialsFile string `json:"credentials_file" mapstructure:"credentials_file"` TimeToLive int `json:"time_to_live" mapstructure:"time_to_live"` // Apple Push Notification service (APNs) ApnsBundleID string `json:"apns_bundle_id" mapstructure:"apns_bundle_id"` Android PushCommonConfig `json:"android" mapstructure:"android"` Apns PushCommonConfig `json:"apns" mapstructure:"apns"` WebPush PushCommonConfig `json:"web_push" mapstructure:"web_push"` }
type PushFcmConfigCredentials ¶
type PushFcmConfigCredentials struct { Type string `json:"type" mapstructure:"type"` ProjectID string `json:"project_id" mapstructure:"project_id"` PrivateKeyID string `json:"private_key_id" mapstructure:"private_key_id"` PrivateKey string `json:"private_key" mapstructure:"private_key"` ClientEmail string `json:"client_email" mapstructure:"client_email"` AuthUri string `json:"auth_uri" mapstructure:"auth_uri"` TokenUri string `json:"token_uri" mapstructure:"token_uri"` AuthProviderX509CertUrl string `json:"auth_provider_x509_cert_url" mapstructure:"auth_provider_x_509_cert_url"` ClientX509CertUrl string `json:"client_x509_cert_url" mapstructure:"client_x_509_cert_url"` }
type SecretsConfig ¶
type SecretsConfig struct { // Salt used in signing API keys ApiKeySalt string `json:"api_key_salt" mapstructure:"api_key_salt"` }
type StoreConfig ¶
type StoreConfig struct { // 16-byte key for XTEA. Used to initialize types.UidGenerator. UidKey string `json:"uid_key" mapstructure:"uid_key"` // Maximum number of results to return from adapter. MaxResults int `json:"max_results" mapstructure:"max_results"` AdapterName string `json:"adapter_name" mapstructure:"adapter_name"` Postgres *StorePostgresConfig `json:"postgres" mapstructure:"postgres"` }
type StorePostgresConfig ¶
type StorePostgresConfig struct { User string `json:"user" mapstructure:"user"` Password string `json:"password" mapstructure:"password"` Host string `json:"host" mapstructure:"host"` Port int `json:"port" mapstructure:"port"` DbName string `json:"db_name" mapstructure:"db_name"` Dsn string `json:"dsn" mapstructure:"dsn"` MaxOpenConn int `json:"max_open_conn" mapstructure:"max_open_conn"` MaxIdleConn int `json:"max_idle_conn" mapstructure:"max_idle_conn"` MaxLifetimeConn int `json:"max_lifetime_conn" mapstructure:"max_lifetime_conn"` // Maximum number of records to return MaxResults int `json:"max_results" mapstructure:"max_results"` // Maximum number of message records to return MaxMessageResults int `json:"max_message_results" mapstructure:"max_message_results"` Version int `json:"version" mapstructure:"version"` // Single query timeout. SqlTimeout int `json:"sql_timeout" mapstructure:"sql_timeout"` // DB transaction timeout. TxTimeout int `json:"tx_timeout" mapstructure:"tx_timeout"` }
type TlsAutocertConfig ¶
type TlsAutocertConfig struct { // Domains to support by autocert Domains []string `json:"domains" mapstructure:"domains"` // Name of directory where auto-certificates are cached, e.g. /etc/letsencrypt/live/your-domain-here Cache string `json:"cache" mapstructure:"cache"` // Contact email for letsencrypt Email string `json:"email" mapstructure:"email"` }
type TlsConfig ¶
type TlsConfig struct { Enabled bool `json:"enabled" mapstructure:"enabled"` // Listen for connections on this address:port and redirect them to HTTPS port. HttpRedirect string `json:"http_redirect" mapstructure:"http_redirect"` // Enable Strict-Transport-Security by setting max_age > 0 StrictMaxAge int `json:"strict_max_age" mapstructure:"strict_max_age"` // ACME autocert config, e.g. letsencrypt.org Autocert *TlsAutocertConfig `json:"autocert" mapstructure:"autocert"` // If Autocert is not defined, provide file names of static certificate and key CertFile string `json:"cert_file" mapstructure:"cert_file"` KeyFile string `json:"key_file" mapstructure:"key_file"` }
type ValidatorConfig ¶
type ValidatorConfig struct {
Email *ValidatorConfigEmail `json:"email" mapstructure:"email"`
}
type ValidatorConfigEmail ¶
type ValidatorConfigEmail struct { // Path to email validation templates, either a template itself or a literal string. ValidationTemplFile string `json:"validation_templ" mapstructure:"validation_templ_file"` // Path to templates for resetting the authentication secret. ResetTemplFile string `json:"reset_secret_templ" mapstructure:"reset_templ_file"` // Optional list of human languages to try to load templates for. If you don't care about i18n, // leave it blank or remove. The first language in the list is the default language. Languages []string `json:"languages" mapstructure:"languages"` // Length of secret numeric code to sent for validation. CodeLength int `json:"code_length"` AddToTags bool `json:"add_to_tags" mapstructure:"add_to_tags"` // Authentication level which triggers this validator: "auth", "anon"... or "" Required []string `json:"required" mapstructure:"required"` // Address of the host where the chat server is running. This will be used in URLs in the email. HostUrl string `json:"host_url" mapstructure:"host_url"` // Address of the SMPT server to use. SmtpServer string `json:"smtp_server" mapstructure:"smtp_server"` // SMTP port to use. "25" for basic email RFC 5321 (2821, 821), "587" for RFC 3207 (TLS). SmtpPort string `json:"smtp_port" mapstructure:"smtp_port"` // RFC 5322 email address to show in the From: field. Sender string `json:"sender" mapstructure:"sender"` // Optional login to use for authentication; if missing, the connection is not authenticated. Login string `json:"login" mapstructure:"login"` // Password to use when authenticating the sender; used only if "login" is provided Password string `json:"password" mapstructure:"password"` // Authentication mechanism to use, optional. One of "login", "cram-md5", "plain" (default). AuthMechanism string `json:"auth_mechanism" mapstructure:"auth_mechanism"` // FQDN to use in SMTP HELO/EHLO command; if missing, the hostname from "host_url" is used. SmtpHeloHost string `json:"smtp_helo_host" mapstructure:"smtp_helo_host"` // Skip verification of the server's certificate chain and host name. // In this mode, TLS is susceptible to machine-in-the-middle attacks. InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify"` // Allow this many confirmation attempts before blocking the credential. MaxRetries int `json:"max_retries" mapstructure:"max_retries"` // List of email domains allowed to be used for registration. // Missing or empty list means any email domain is accepted. Domains []string `json:"domains" mapstructure:"domains"` // Dummy response to accept. // // === IMPORTANT === // // REMOVE IN PRODUCTION!!! Otherwise anyone will be able to register // with fake emails. DebugResponse string `json:"debug_response" mapstructure:"debug_response"` }
type WSConfig ¶
type WSConfig struct { // If true attempt to negotiate websocket per message compression (RFC 7692.4). // It should be disabled (set to false) if you are using MSFT IIS as a reverse proxy. WSCompressionEnabled bool `json:"ws_compression_enabled" mapstructure:"ws_compression_enabled"` // Maximum message size allowed from client. Intended to prevent malicious client from sending // very large files inband (does not affect out of band uploads). MaxMessageSize int `json:"max_message_size" mapstructure:"max_message_size"` // Maximum number of group topic subscribers. MaxSubscriberCount int `json:"max_subscriber_count" mapstructure:"max_subscriber_count"` // Masked tags: tags immutable on User (mask), mutable on Topic only within the mask. MaskedTagNamespaces []string `json:"masked_tag_namespaces" mapstructure:"masked_tag_namespaces"` // Maximum number of indexable tags. MaxTagCount int `json:"max_tag_count" mapstructure:"max_tag_count"` }
type WebRtcConfigIceServer ¶
type WebRtcConfigIceServer struct { Username string `json:"username" mapstructure:"username"` Credential string `json:"credential" mapstructure:"credential"` CredentialType string `json:"credential_type" mapstructure:"credential_type"` Urls []string `json:"urls" mapstructure:"urls"` Config WebRtcVideoConfig `json:"config" mapstructure:"config"` }
type WebRtcVideoConfig ¶
type WebRtcVideoConfig struct { Enabled bool `json:"enabled" mapstructure:"enabled"` EndpointUrl string `json:"endpoint_url" mapstructure:"endpoint_url"` ApiKey string `json:"api_key" mapstructure:"api_key"` ApiSecret string `json:"api_secret" mapstructure:"api_secret"` MaxDuration int `json:"max_duration" mapstructure:"max_duration"` }
type WebrtcConfig ¶
type WebrtcConfig struct { // Enable video/voice calls. Enabled bool `json:"enabled" mapstructure:"enabled"` // Timeout in seconds before a call is dropped if not answered. CallEstablishmentTimeout int `json:"call_establishment_timeout" mapstructure:"call_establishment_timeout"` IceServers []WebRtcConfigIceServer `json:"ice_servers" mapstructure:"ice_servers"` // Alternative config as an external file. IceServersFile string `json:"ice_servers_file" mapstructure:"ice_servers_file"` }
Source Files
¶
- account_gc_config.go
- app_config.go
- auth_config.go
- cluster_config.go
- config.go
- grpc_config.go
- http.go
- media_config.go
- paths_config.go
- plugins_config.go
- pprof_config.go
- push_config.go
- push_fcm_config.go
- secrets_config.go
- store_config.go
- store_postgres_config.go
- tls_config.go
- validators_config.go
- webrtc_config.go
- ws_config.go
Click to show internal directories.
Click to hide internal directories.