Browse Source

latest cwtch

pull/28/head
Dan Ballard 1 month ago
parent
commit
8eafa8f98a
  1. 2
      go.mod
  2. 4
      go.sum
  3. 29
      serverConfig.go

2
go.mod

@ -3,7 +3,7 @@ module git.openprivacy.ca/cwtch.im/server
go 1.14
require (
cwtch.im/cwtch v0.14.8
cwtch.im/cwtch v0.14.9
git.openprivacy.ca/cwtch.im/tapir v0.4.9
git.openprivacy.ca/openprivacy/connectivity v1.5.0
git.openprivacy.ca/openprivacy/log v1.0.3

4
go.sum

@ -10,8 +10,8 @@ cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
cwtch.im/cwtch v0.14.8 h1:bybtnnCTp7utGvfIbQvdeffKmJQgGrkfgijrAfS8SQw=
cwtch.im/cwtch v0.14.8/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI=
cwtch.im/cwtch v0.14.9 h1:VYXbQG6f41fCoLpLEYDAeiJSG+9Gxstl1DOk1Hv4tjM=
cwtch.im/cwtch v0.14.9/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=

29
serverConfig.go

@ -37,10 +37,6 @@ const (
StoreageTypeNoPassword = "storage-no-password"
)
const version = "1"
const versionFile = "VERSION"
const saltFile = "SALT"
// Reporting is a struct for storing a the config a server needs to be a peer, and connect to a group to report
type Reporting struct {
LogMetricsToFile bool `json:"logMetricsToFile"`
@ -124,7 +120,7 @@ func CreateConfig(configDir, filename string, encrypted bool, password string, d
config := initDefaultConfig(configDir, filename, encrypted)
config.ServerReporting.LogMetricsToFile = defaultLogToFile
if encrypted {
key, _, err := InitV1Directory(configDir, password)
key, _, err := storage.InitV1Directory(configDir, password)
if err != nil {
log.Errorf("could not create server directory: %s", err)
return nil, err
@ -137,29 +133,6 @@ func CreateConfig(configDir, filename string, encrypted bool, password string, d
return config, nil
}
// InitV1Directory generates a key and salt from a password, writes a SALT and VERSION file and returns the key and salt
func InitV1Directory(directory, password string) ([32]byte, [128]byte, error) {
os.Mkdir(directory, 0700)
key, salt, err := v1.CreateKeySalt(password)
if err != nil {
log.Errorf("Could not create key for profile store from password: %v\n", err)
return [32]byte{}, [128]byte{}, err
}
if err = ioutil.WriteFile(path.Join(directory, versionFile), []byte(version), 0600); err != nil {
log.Errorf("Could not write version file: %v", err)
return [32]byte{}, [128]byte{}, err
}
if err = ioutil.WriteFile(path.Join(directory, saltFile), salt[:], 0600); err != nil {
log.Errorf("Could not write salt file: %v", err)
return [32]byte{}, [128]byte{}, err
}
return key, salt, nil
}
// LoadConfig loads a Config from a json file specified by filename
func LoadConfig(configDir, filename string, encrypted bool, password string) (*Config, error) {
config := initDefaultConfig(configDir, filename, encrypted)

Loading…
Cancel
Save