Exemplo n.º 1
0
func NewMailer(username, password, addr string) *Mailer {
	mailer := &Mailer{
		addr:       addr,
		username:   username,
		bufferPool: bytes2.NewSyncPool(1024, false),
	}
	auth := smtp.PlainAuth("", username, password, strings.Split(addr, ":")[0])
	mailer.auth = auth
	mailer.Templates = make(map[string]mailTemplate)

	return mailer
}
Exemplo n.º 2
0
func (x *Xsrf) Init(env zerver.Env) error {
	if x.Secret == "" {
		return errors.Err("xsrf secret can't be empty")
	}

	defval.Int64(&x.Timeout, _DEF_XSRF_TIMEOUT)
	defval.Nil(&x.HashMethod, sha256.New)
	defval.String(&x.Error, "xsrf token is invalid or not found")

	if x.UsePool {
		if x.Pool == nil {
			x.Pool = bytes2.NewSyncPool(0, true)
		}
	} else {
		x.Pool = bytes2.FakePool{}
	}
	defval.Nil(&x.TokenInfo, jsonToken{})
	x.log = log.Derive("Component", "Xsrf")
	return nil
}