/
config.go
43 lines (36 loc) · 1.19 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package server
import (
"encoding/json"
"io/ioutil"
"time"
"github.com/privacylab/talek/common"
)
// Config represents the configuration needed to start a Talek server.
// configurations can be generated through util/talekutil
type Config struct {
*common.Config
// How many read requests should be made of the PIR server at a time?
ReadBatch int
// What's the minimum frequency when pending writes should be applied?
WriteInterval time.Duration `json:",string"`
// What's the minimum frequency when pending reads should be applied?
ReadInterval time.Duration `json:",string"`
// The trust domain this server is within. Includes keychain for the server.
TrustDomain *common.TrustDomainConfig
// In client read requests, which index is relevant for this server.
TrustDomainIndex int
}
// ConfigFromFile restores a json cofig. returns the config on success or nil if
// loading or parsing the file fails.
func ConfigFromFile(file string, commonBase *common.Config) *Config {
configString, err := ioutil.ReadFile(file)
if err != nil {
return nil
}
config := new(Config)
if err := json.Unmarshal(configString, config); err != nil {
return nil
}
config.Config = commonBase
return config
}