aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/wnode/main.go31
1 files changed, 17 insertions, 14 deletions
diff --git a/cmd/wnode/main.go b/cmd/wnode/main.go
index 23b180487..f9b689b65 100644
--- a/cmd/wnode/main.go
+++ b/cmd/wnode/main.go
@@ -65,7 +65,7 @@ var (
pub *ecdsa.PublicKey
asymKey *ecdsa.PrivateKey
nodeid *ecdsa.PrivateKey
- topic []byte
+ topic whisper.TopicType
asymKeyID string
filterID string
symPass string
@@ -84,7 +84,7 @@ var (
testMode = flag.Bool("test", false, "use of predefined parameters for diagnostics")
echoMode = flag.Bool("echo", false, "echo mode: prints some arguments for diagnostics")
- argVerbosity = flag.Int("verbosity", int(log.LvlWarn), "log verbosity level")
+ argVerbosity = flag.Int("verbosity", int(log.LvlError), "log verbosity level")
argTTL = flag.Uint("ttl", 30, "time-to-live for messages in seconds")
argWorkTime = flag.Uint("work", 5, "work time in seconds")
argMaxSize = flag.Int("maxsize", whisper.DefaultMaxMessageLength, "max size of message")
@@ -129,7 +129,7 @@ func processArgs() {
if err != nil {
utils.Fatalf("Failed to parse the topic: %s", err)
}
- topic = x
+ topic = whisper.BytesToTopic(x)
}
if *asymmetricMode && len(*argPub) > 0 {
@@ -307,7 +307,11 @@ func configureNode() {
if *asymmetricMode {
if len(*argPub) == 0 {
s := scanLine("Please enter the peer's public key: ")
- pub = crypto.ToECDSAPub(common.FromHex(s))
+ b := common.FromHex(s)
+ if b == nil {
+ utils.Fatalf("Error: can not convert hexadecimal string")
+ }
+ pub = crypto.ToECDSAPub(b)
if !isKeyValid(pub) {
utils.Fatalf("Error: invalid public key")
}
@@ -354,7 +358,7 @@ func configureNode() {
filter := whisper.Filter{
KeySym: symKey,
KeyAsym: asymKey,
- Topics: [][]byte{topic},
+ Topics: [][]byte{topic[:]},
AllowP2P: p2pAccept,
}
filterID, err = shh.Subscribe(&filter)
@@ -365,7 +369,7 @@ func configureNode() {
}
func generateTopic(password []byte) {
- x := pbkdf2.Key(password, password, 8196, 128, sha512.New)
+ x := pbkdf2.Key(password, password, 4096, 128, sha512.New)
for i := 0; i < len(x); i++ {
topic[i%whisper.TopicLength] ^= x[i]
}
@@ -485,16 +489,15 @@ func sendMsg(payload []byte) common.Hash {
Dst: pub,
KeySym: symKey,
Payload: payload,
- Topic: whisper.BytesToTopic(topic),
+ Topic: topic,
TTL: uint32(*argTTL),
PoW: *argPoW,
WorkTime: uint32(*argWorkTime),
}
- msg := whisper.NewSentMessage(&params)
- if msg == nil {
- fmt.Printf("failed to create new message (OS level error)")
- os.Exit(0)
+ msg, err := whisper.NewSentMessage(&params)
+ if err != nil {
+ utils.Fatalf("failed to create new message: %s", err)
}
envelope, err := msg.Wrap(&params)
if err != nil {
@@ -624,9 +627,9 @@ func requestExpiredMessagesLoop() {
params.Src = nodeid
params.WorkTime = 5
- msg := whisper.NewSentMessage(&params)
- if msg == nil {
- utils.Fatalf("failed to create new message (OS level error)")
+ msg, err := whisper.NewSentMessage(&params)
+ if err != nil {
+ utils.Fatalf("failed to create new message: %s", err)
}
env, err := msg.Wrap(&params)
if err != nil {