Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
d6636a55
Commit
d6636a55
authored
Jan 09, 2018
by
Tomas
Browse files
Change how Sentry DSN is applied, and rename clientConfig to Preferences
parent
810f0cf4
Changes
2
Hide whitespace changes
Inline
Side-by-side
irmaclient/client.go
View file @
d6636a55
...
...
@@ -7,11 +7,11 @@ import (
"time"
"github.com/credentials/go-go-gadget-paillier"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs"
"github.com/getsentry/raven-go"
"github.com/go-errors/errors"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs"
)
// This file contains most methods of the Client (c.f. session.go
...
...
@@ -48,10 +48,8 @@ type Client struct {
// Where we store/load it to/from
storage
storage
// configuration
config
clientConfiguration
// Other state
Preferences
Preferences
Configuration
*
irma
.
Configuration
UnenrolledSchemeManagers
[]
irma
.
SchemeManagerIdentifier
irmaConfigurationPath
string
...
...
@@ -60,14 +58,14 @@ type Client struct {
state
*
issuanceState
}
type
clientConfiguration
struct
{
Send
CrashReport
s
bool
ravenDSN
string
type
Preferences
struct
{
Enable
CrashReport
ing
bool
SentryDSN
string
}
var
defaultClientConfig
=
clientConfiguration
{
Send
CrashReport
s
:
true
,
raven
DSN
:
""
,
// Set this in the init() function, empty string -> no crash reports
var
defaultClientConfig
=
Preferences
{
Enable
CrashReport
ing
:
true
,
Sentry
DSN
:
""
,
// Set this in the init() function, empty string -> no crash reports
}
// KeyshareHandler is used for asking the user for his email address and PIN,
...
...
@@ -141,10 +139,10 @@ func New(
return
nil
,
err
}
if
cm
.
config
,
err
=
cm
.
storage
.
LoadClientConfig
();
err
!=
nil
{
if
cm
.
Preferences
,
err
=
cm
.
storage
.
LoadClientConfig
();
err
!=
nil
{
return
nil
,
err
}
cm
.
apply
ClientConfig
()
cm
.
apply
Preferences
()
// Perform new update functions from clientUpdates, if any
if
err
=
cm
.
update
();
err
!=
nil
{
...
...
@@ -742,20 +740,16 @@ func (client *Client) Logs() ([]*LogEntry, error) {
// SendCrashReports toggles whether or not crash reports should be sent to Sentry.
// Has effect only after restarting.
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
)
SetCrashReportingPreference
(
enable
bool
)
{
client
.
Preferences
.
EnableCrashReporting
=
enable
_
=
client
.
storage
.
StorePreferences
(
client
.
Preferences
)
client
.
applyPreferences
()
}
func
(
client
*
Client
)
applyClientConfig
()
{
if
client
.
config
.
SendCrashReports
&&
client
.
config
.
ravenDSN
!=
""
{
raven
.
SetDSN
(
client
.
config
.
ravenDSN
)
func
(
client
*
Client
)
applyPreferences
()
{
if
client
.
Preferences
.
EnableCrashReporting
{
raven
.
SetDSN
(
client
.
Preferences
.
SentryDSN
)
}
else
{
raven
.
SetDSN
(
""
)
}
}
irmaclient/storage.go
View file @
d6636a55
...
...
@@ -5,9 +5,9 @@ import (
"io/ioutil"
"os"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/fs"
"github.com/mhe/gabi"
)
// This file contains the storage struct and its methods,
...
...
@@ -21,14 +21,14 @@ type storage struct {
// Filenames in which we store stuff
const
(
skFile
=
"sk"
attributesFile
=
"attrs"
kssFile
=
"kss"
paillierFile
=
"paillier"
updatesFile
=
"updates"
logsFile
=
"logs"
configFile
=
"config
"
signaturesDir
=
"sigs"
skFile
=
"sk"
attributesFile
=
"attrs"
kssFile
=
"kss"
paillierFile
=
"paillier"
updatesFile
=
"updates"
logsFile
=
"logs"
preferencesFile
=
"preferences
"
signaturesDir
=
"sigs"
)
func
(
s
*
storage
)
path
(
p
string
)
string
{
...
...
@@ -111,8 +111,8 @@ func (s *storage) StoreLogs(logs []*LogEntry) error {
return
s
.
store
(
logs
,
logsFile
)
}
func
(
s
*
storage
)
Store
ClientConfig
(
config
clientConfiguration
)
error
{
return
s
.
store
(
config
,
config
File
)
func
(
s
*
storage
)
Store
Preferences
(
prefs
Preferences
)
error
{
return
s
.
store
(
prefs
,
preferences
File
)
}
func
(
s
*
storage
)
StoreUpdates
(
updates
[]
update
)
(
err
error
)
{
...
...
@@ -211,7 +211,7 @@ func (s *storage) LoadUpdates() (updates []update, err error) {
return
updates
,
nil
}
func
(
s
*
storage
)
LoadClientConfig
()
(
clientConfiguration
,
error
)
{
func
(
s
*
storage
)
LoadClientConfig
()
(
Preferences
,
error
)
{
config
:=
defaultClientConfig
return
config
,
s
.
load
(
&
config
,
config
File
)
return
config
,
s
.
load
(
&
config
,
preferences
File
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment