mirror of
https://github.com/status-im/status-go.git
synced 2025-01-18 18:55:47 +00:00
6cdea4ef97
* Update project to use Whisper v6. Part of #638 * Revert "Add patch to downgrade usage of Whisper v6 to v5 in some geth 1.8.1 vendor files. Part of #665" - this reverts commit 6aefb4c8fd02dbcfffac6b69e8bb22b13ef86b6b. * Enable light mode on Whisper v6 for non-mail servers. Part of #638 * Fix race condition in whisperv6/peer.go. Part of #665 (PR already accepted upstream for 1.8.2) * Update bootnode addresses in staticnodes.json. Part of #638 * Add `shh.lightclient` flag and tests for bloom filter setting logic. Part of #638 * Move MakeTestNodeConfig to utils. Part of #638 * Reduce PoW in `whisper_jail_test.go` to fix flaky test. Part of #638
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"fmt"
|
|
"io/ioutil"
|
|
|
|
"github.com/status-im/status-go/geth/params"
|
|
)
|
|
|
|
// whisperConfig creates node configuration object from flags
|
|
func whisperConfig(nodeConfig *params.NodeConfig) (*params.NodeConfig, error) {
|
|
whisperConfig := nodeConfig.WhisperConfig
|
|
whisperConfig.Enabled = true
|
|
whisperConfig.EnableMailServer = *enableMailServer
|
|
whisperConfig.LightClient = *lightClient
|
|
whisperConfig.MinimumPoW = *minPow
|
|
whisperConfig.TTL = *ttl
|
|
|
|
if whisperConfig.EnableMailServer {
|
|
if *passwordFile == "" {
|
|
return nil, errors.New("passwordfile should be specified if MailServer is enabled")
|
|
}
|
|
|
|
password, err := readFile(*passwordFile)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("password file: %v", err)
|
|
}
|
|
|
|
whisperConfig.Password = string(password)
|
|
}
|
|
|
|
// firebase configuration
|
|
firebaseConfig := whisperConfig.FirebaseConfig
|
|
firebaseConfig.AuthorizationKeyFile = *firebaseAuth
|
|
if firebaseConfig.AuthorizationKeyFile != "" {
|
|
if _, err := firebaseConfig.ReadAuthorizationKeyFile(); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return nodeConfig, nil
|
|
}
|
|
|
|
func readFile(path string) ([]byte, error) {
|
|
data, err := ioutil.ReadFile(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
data = bytes.TrimRight(data, "\n")
|
|
|
|
if len(data) == 0 {
|
|
return nil, errors.New("file is empty")
|
|
}
|
|
|
|
return data, nil
|
|
}
|