]> Cypherpunks.ru repositories - nncp.git/commitdiff
Ability to completely omit noisepub field
authorSergey Matveev <stargrave@stargrave.org>
Sat, 14 Jan 2017 08:59:42 +0000 (11:59 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 14 Jan 2017 19:32:55 +0000 (22:32 +0300)
doc/cfg.texi
src/cypherpunks.ru/nncp/cfg.go
src/cypherpunks.ru/nncp/cmd/nncp-call/main.go
src/cypherpunks.ru/nncp/cmd/nncp-newnode/main.go

index 4141abaca40a00974dc8f5ee178df530adb1e20e..19cfe40f9fd697dbfe0f8a2a88ee6606b6475946 100644 (file)
@@ -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
index c69c523d688402a3c2b6e599d7a694bdd405b86d..1bb9c02a8cc307d0cc249238800d51ec9bbb87a6 100644 (file)
@@ -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
 }
 
index 236d445b552e074f086211eccc5425a2a4386066..a3861dc68d9ea7a99c953cc36843831125943dd9 100644 (file)
@@ -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 {
index 89ea84e49ed960a38e1d8ff3cc4e0b66a9968f04..a8e73e6591eeb104a34348f2a913627cfd230ff3 100644 (file)
@@ -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,