Documentation ¶
Index ¶
- Constants
- Variables
- func Empty(c *Matrix) bool
- func EnsureConnected(driver, conn string) (db *sql.DB, err error)
- func FormatDate(ts time.Time, local, useGMT bool) string
- func IsValidEmail(email string) bool
- func MergeTemplates(a, b []Template) map[string]Template
- func ProcessFile(src []byte) []byte
- type Client
- type Container
- type Crypto
- type DB
- type Email
- type EmailProvider
- type Field
- type HTTPClient
- type Invite
- type Key
- type Kmail
- type Mail
- type Matrix
- type NoopMail
- type Peer
- type Provider
- type SMTPClient
- type SMTPEmail
- type Server
- type Template
- type Validation
- type Validator
- type Verification
Constants ¶
const AgentName = "matrixid"
AgentName the name used for User-Agent header. All http clients making requests between matrix serves include this header.
const ApplicationName = "sydent-go"
ApplicationName the name of the application.
const MaxRetries = 16
MaxRetries is the maximum number of retries for http requests made by matrixid clients before backing off.
const ThreepidSessionValidationLifetime = 24 * 60 * 60 * 1000
ThreepidSessionValidationLifetime duration in ms of the retaining period for sessions.
const ThreepidSessionValidationTimeout = 24 * 60 * 60 * 1000
ThreepidSessionValidationTimeout duration in MS of the time a user will have to wait before the session he/she created is validates.
Variables ¶
var ( InviteTpl = "/email/invite_template.eml" InviteVector = "/email/invite_template_vector.eml" VerificationTpl = "/email/verification_template.eml" VerificationVector = "/email/verification_template_vector.eml" VerifyResponsePage = "/email/verify_response_page_template" VerifyResponsePageVector = "/email/verify_response_page_template_vector_im" )
embedded templates
Functions ¶
func EnsureConnected ¶
EnsureConnected for automated deployments there are some cases when the database might be booting up so connections here will fall, this does exponential retries to connect to the database.
func FormatDate ¶
FormatDate similar to python email.utils.formatdate
func IsValidEmail ¶
func MergeTemplates ¶
func ProcessFile ¶
ProcessFile expands environment variables in src. This means it will replace all $VAR or ${VAR} declarations with values found in environment variables.
Types ¶
type Container ¶
type Container struct { Name string `hcl:",key"` State string `hcl:"state"` Settings map[string]interface{} `hcl:"settings"` }
Container abstract struct for storing namespaced settings.
type Crypto ¶
type Crypto struct { Algorithm string `hcl:"algorithm"` Version string `hcl:"version"` SingingKey string `hcl:"signing_key"` VerifyKey string `hcl:"verify_key"` }
Crypto cryptographic keys used for signing and verifying messages.
func (Crypto) Key ¶
func (c Crypto) Key() *signedjson.Key
func (Crypto) Valid ¶
func (c Crypto) Valid() *Validation
Valid returns nil if c is a valid configuration for identity service crypto.
type Email ¶
type Email struct { Providers []Provider `hcl:"provider"` Invite Invite `hcl:"invite"` Verification Verification `hcl:"verification"` }
Email defines all possible configuration for email client.
type EmailProvider ¶
type HTTPClient ¶
HTTPClient defines API for sending http requests.
type Kmail ¶
type Kmail struct {
// contains filtered or unexported fields
}
Kmail provide methods for sending emails.
func (*Kmail) SendMail ¶
func (k *Kmail) SendMail(ctx context.Context, tmpl, from string, to []string, data map[string]string) error
SendMail uses tmpl template to send and email, data is a context object which is passed to the cached template and rendered to generate the email message.
func (*Kmail) Valid ¶
func (k *Kmail) Valid() *Validation
type Mail ¶
type Mail interface {
SendMail(ctx context.Context, tmpl, from string, to []string, data map[string]string) error
}
Mail is an interface for sending transactional email for the matrixid home server.
type Matrix ¶
type Matrix struct { Mode string `hcl:"mode"` Server Server `hcl:"server"` DB DB `hcl:"db"` Email Email `hcl:"email"` Templates []Template `hcl:"templates"` Peers []Peer `hcl:"peer"` // contains filtered or unexported fields }
Matrix is the central configuration for the whole server. This stores settings for all services api and evertything needed to run the server.
func LoadFile ¶
LoadFile decodes Matrix object from src. src is either json/hcl configuration in raw bytes.
func LoadFromEnv ¶
func LoadFromEnv() *Matrix
func (*Matrix) GetTemplate ¶
func (*Matrix) LoadTemplates ¶
func (*Matrix) Valid ¶
func (m *Matrix) Valid() *Validation
Valid performs validation of m. Call Validation.IsValid() to see if validation passed.
func (*Matrix) Validate ¶
Validate validate m and logs the error message in case m is not valid to lg.
func (*Matrix) WriteToFile ¶
WriteToFile marshals m and writes the hcl configuration to the the file filename.
type NoopMail ¶
type NoopMail struct{}
NoopMail implements Mail intreface but does not actually send the email.
func (NoopMail) SendMail ¶
func (n NoopMail) SendMail(ctx context.Context, tmpl, from string, to []string, data map[string]string) error
SendMail does nothing and always returns nil.
func (NoopMail) Valid ¶
func (n NoopMail) Valid() *Validation
type Peer ¶
type Peer struct { Name string `hcl:",key"` BaseReplicationURL string `hcl:"base_replication_url"` }
Peer defines settings for remote replication.
type SMTPClient ¶
type SMTPClient struct {
// contains filtered or unexported fields
}
func NewSMAPCLient ¶
func NewSMAPCLient(cfg SMTPEmail) *SMTPClient
func (*SMTPClient) Host ¶
func (s *SMTPClient) Host() string
func (*SMTPClient) Valid ¶
func (s *SMTPClient) Valid() *Validation
type SMTPEmail ¶
SMTPEmail smtp plain auth configurations.
func (SMTPEmail) Valid ¶
func (s SMTPEmail) Valid() *Validation
type Server ¶
type Server struct { Name string `hcl:"name"` Port string `hcl:"port"` ClientHTTPBase string `hcl:"client_http_base"` Crypto Crypto `hcl:"crypto"` }
Server defines setting for the main server. Unlike the reference implementation, all services are provided under the same server, service specific configuration is used to enable/disable services. So, this is the one and only server that runs on boot up.
Only TLS server is supported. Failure to provide tls certificates will result in validation error.
TODO: Add let's encrypt support with auto-tls.
type Template ¶
func EmbedTemplates ¶
func EmbedTemplates() []Template
type Validation ¶
type Validation struct { Namespace string `json:"namespace"` Fields []Field `json:"fields,omitempty"` Children []*Validation `json:",omitempty"` }
func (Validation) IsValid ¶
func (v Validation) IsValid() bool
func (*Validation) Set ¶
func (v *Validation) Set(name, value string)
func (Validation) String ¶
func (v Validation) String() string
type Validator ¶
type Validator interface {
Valid() *Validation
}
type Verification ¶
type Verification struct { From string `hcl:"from"` Template string `hcl:template"` ResponsePage string `hcl:"response_page_template"` }
Verification stores details used when sending token validation emails.
func (Verification) Valid ¶
func (i Verification) Valid() *Validation