From: Sergey Matveev Date: Sat, 14 Jan 2017 08:59:42 +0000 (+0300) Subject: Ability to completely omit noisepub field X-Git-Tag: 0.2^2~28 X-Git-Url: http://www.git.cypherpunks.ru/?a=commitdiff_plain;h=845f386deac00d0eb14e00a993f2e4393eabd6a1;p=nncp.git Ability to completely omit noisepub field --- diff --git a/doc/cfg.texi b/doc/cfg.texi index 4141aba..19cfe40 100644 --- a/doc/cfg.texi +++ b/doc/cfg.texi @@ -42,7 +42,6 @@ neigh: id: 2IZNP...UYGYA exchpub: WFLMZ...B7NHA signpub: GTGXG...IE3OA - noisepub: EQAZM...J3NBA sendmail: [/usr/sbin/sendmail] freq: /home/bob/pub via: [alice] @@ -74,8 +73,8 @@ node has the following fields: @table @strong @item noisepub -Must be present, but can be dummy (only zeros) if no online -communication using @ref{Sync, synchronization protocol} will be used. +If present, then node can be online called using @ref{Sync, +synchronization protocol}. Contains authentication public key. @item sendmail An array containing path to executable and its command line arguments diff --git a/src/cypherpunks.ru/nncp/cfg.go b/src/cypherpunks.ru/nncp/cfg.go index c69c523..1bb9c02 100644 --- a/src/cypherpunks.ru/nncp/cfg.go +++ b/src/cypherpunks.ru/nncp/cfg.go @@ -40,7 +40,7 @@ type NodeYAML struct { Id string ExchPub string SignPub string - NoisePub string + NoisePub *string `noisepub,omitempty` Sendmail []string Incoming *string `incoming,omitempty` Freq *string `freq,omitempty` @@ -100,12 +100,15 @@ func NewNode(name string, yml NodeYAML) (*Node, error) { return nil, errors.New("Invalid signPub size") } - noisePub, err := FromBase32(yml.NoisePub) - if err != nil { - return nil, err - } - if len(noisePub) != 32 { - return nil, errors.New("Invalid noisePub size") + var noisePub []byte + if yml.NoisePub != nil { + noisePub, err = FromBase32(*yml.NoisePub) + if err != nil { + return nil, err + } + if len(noisePub) != 32 { + return nil, errors.New("Invalid noisePub size") + } } var incoming *string @@ -131,14 +134,16 @@ func NewNode(name string, yml NodeYAML) (*Node, error) { Id: nodeId, ExchPub: new([32]byte), SignPub: ed25519.PublicKey(signPub), - NoisePub: new([32]byte), Sendmail: yml.Sendmail, Incoming: incoming, Freq: freq, Addrs: yml.Addrs, } copy(node.ExchPub[:], exchPub) - copy(node.NoisePub[:], noisePub) + if len(noisePub) > 0 { + node.NoisePub = new([32]byte) + copy(node.NoisePub[:], noisePub) + } return &node, nil } diff --git a/src/cypherpunks.ru/nncp/cmd/nncp-call/main.go b/src/cypherpunks.ru/nncp/cmd/nncp-call/main.go index 236d445..a3861dc 100644 --- a/src/cypherpunks.ru/nncp/cmd/nncp-call/main.go +++ b/src/cypherpunks.ru/nncp/cmd/nncp-call/main.go @@ -89,6 +89,9 @@ func main() { if err != nil { log.Fatalln("Invalid NODE specified:", err) } + if node.NoisePub == nil { + log.Fatalln("Node does not have online communication capability") + } var xxOnly nncp.TRxTx if *rxOnly { diff --git a/src/cypherpunks.ru/nncp/cmd/nncp-newnode/main.go b/src/cypherpunks.ru/nncp/cmd/nncp-newnode/main.go index 89ea84e..a8e73e6 100644 --- a/src/cypherpunks.ru/nncp/cmd/nncp-newnode/main.go +++ b/src/cypherpunks.ru/nncp/cmd/nncp-newnode/main.go @@ -55,6 +55,7 @@ func main() { } incoming := "/path/to/upload/dir, omit it to forbid uploading" freq := "/path/to/freq/able/dir, omit to forbid freqing" + noisePub := nncp.ToBase32(nodeOur.NoisePub[:]) cfg := nncp.CfgYAML{ Self: nncp.NodeOurYAML{ Id: nodeOur.Id.String(), @@ -70,7 +71,7 @@ func main() { Id: nodeOur.Id.String(), ExchPub: nncp.ToBase32(nodeOur.ExchPub[:]), SignPub: nncp.ToBase32(nodeOur.SignPub[:]), - NoisePub: nncp.ToBase32(nodeOur.NoisePub[:]), + NoisePub: &noisePub, Sendmail: []string{nncp.DefaultSendmailPath}, Incoming: &incoming, Freq: &freq,