Commit 47dea744 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Enable or disable crash reports at client instantiation

parent 31d3413e
......@@ -9,6 +9,7 @@ import (
"github.com/credentials/go-go-gadget-paillier"
"github.com/credentials/irmago"
"github.com/credentials/irmago/internal/fs"
"github.com/getsentry/raven-go"
"github.com/go-errors/errors"
"github.com/mhe/gabi"
)
......@@ -47,6 +48,9 @@ type Client struct {
// Where we store/load it to/from
storage storage
// configuration
config clientConfiguration
// Other state
Configuration *irma.Configuration
UnenrolledSchemeManagers []irma.SchemeManagerIdentifier
......@@ -56,6 +60,16 @@ type Client struct {
state *issuanceState
}
type clientConfiguration struct {
SendCrashReports bool
ravenDSN string
}
var defaultClientConfig clientConfiguration = clientConfiguration{
SendCrashReports: true,
ravenDSN: "", // Set this in the init() function, empty string -> no crash reports
}
// KeyshareHandler is used for asking the user for his email address and PIN,
// for enrolling at a keyshare server.
type KeyshareHandler interface {
......@@ -123,6 +137,11 @@ func New(
return nil, err
}
if cm.config, err = cm.storage.LoadClientConfig(); err != nil {
return nil, err
}
cm.applyClientConfig()
// Perform new update functions from clientUpdates, if any
if err = cm.update(); err != nil {
return nil, err
......@@ -704,3 +723,21 @@ func (client *Client) Logs() ([]*LogEntry, error) {
}
return client.logs, nil
}
func (client *Client) SendCrashReports(val bool) {
if val == client.config.SendCrashReports {
return
}
client.config.SendCrashReports = val
if val {
raven.SetDSN(client.config.ravenDSN)
}
_ = client.storage.StoreClientConfig(client.config)
}
func (client *Client) applyClientConfig() {
if client.config.SendCrashReports && client.config.ravenDSN != "" {
raven.SetDSN(client.config.ravenDSN)
}
}
......@@ -27,6 +27,7 @@ const (
paillierFile = "paillier"
updatesFile = "updates"
logsFile = "logs"
configFile = "config"
signaturesDir = "sigs"
)
......@@ -98,18 +99,22 @@ func (s *storage) StoreAttributes(attributes map[irma.CredentialTypeIdentifier][
return s.store(temp, attributesFile)
}
func (s *storage) StoreKeyshareServers(keyshareServers map[irma.SchemeManagerIdentifier]*keyshareServer) (err error) {
func (s *storage) StoreKeyshareServers(keyshareServers map[irma.SchemeManagerIdentifier]*keyshareServer) error {
return s.store(keyshareServers, kssFile)
}
func (s *storage) StorePaillierKeys(key *paillierPrivateKey) (err error) {
func (s *storage) StorePaillierKeys(key *paillierPrivateKey) error {
return s.store(key, paillierFile)
}
func (s *storage) StoreLogs(logs []*LogEntry) (err error) {
func (s *storage) StoreLogs(logs []*LogEntry) error {
return s.store(logs, logsFile)
}
func (s *storage) StoreClientConfig(config clientConfiguration) error {
return s.store(config, configFile)
}
func (s *storage) StoreUpdates(updates []update) (err error) {
return s.store(updates, updatesFile)
}
......@@ -205,3 +210,8 @@ func (s *storage) LoadUpdates() (updates []update, err error) {
}
return updates, nil
}
func (s *storage) LoadClientConfig() (clientConfiguration, error) {
config := defaultClientConfig
return config, s.load(&config, configFile)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment