]> Cypherpunks.ru repositories - nncp.git/commitdiff
Additional public keys existence checks
authorSergey Matveev <stargrave@stargrave.org>
Sun, 8 Aug 2021 12:11:40 +0000 (15:11 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 8 Aug 2021 12:26:37 +0000 (15:26 +0300)
doc/news.ru.texi
doc/news.texi
src/cfg.go
src/cmd/nncp-caller/main.go
src/sp.go
src/tx.go

index 497509ddffaafcf62a18c58cb938393649a10d5b..5de3cbadaaab076ba79631adce43eabde360b5b1 100644 (file)
 дескриптор (@env{$NNCPLOG=FD:5} например).
 Что дружелюбно к использованию под @command{daemontools}.
 
+@item
+Добавлены дополнительные проверки наличия публичных ключей в
+конфигурационном файле, предотвращающие падения некоторых команд.
+
 @end itemize
 
 @node Релиз 7.5.1
index 80153a83ad4956354579397fcd50d2e67a1bf542..e737a52fe347649399554d30830619f237ca1707 100644 (file)
@@ -12,6 +12,10 @@ Logging may be done to specified opened file descriptor
 (@env{$NNCPLOG=FD:5} for example).
 That is friendly to use under @command{daemontools}.
 
+@item
+Added additional checks of public keys existence in configuration file,
+preventing some commands from failing.
+
 @end itemize
 
 @node Release 7_5_1
index 22da596baf206e6e61447d9ddd8974c5f55aa915..55c9dd0a2479cbe93ae98d97edb2aeb846098ff7 100644 (file)
@@ -21,6 +21,7 @@ import (
        "bytes"
        "encoding/json"
        "errors"
+       "fmt"
        "log"
        "os"
        "path"
@@ -445,6 +446,9 @@ func NewArea(ctx *Ctx, name string, cfg *AreaJSON) (*Area, error) {
                copy(area.Pub[:], pub)
        }
        if cfg.Prv != nil {
+               if area.Pub == nil {
+                       return nil, fmt.Errorf("area %s: prv requires pub presence", name)
+               }
                prv, err := Base32Codec.DecodeString(*cfg.Prv)
                if err != nil {
                        return nil, err
index 614a0512a4a0068c3e6e978f5029e5c37bf0f0d7..177065fce845a4b10f7615f64e8a6fd6572a7e12 100644 (file)
@@ -94,6 +94,9 @@ func main() {
                        if err != nil {
                                log.Fatalln("Invalid NODE specified:", err)
                        }
+                       if node.NoisePub == nil {
+                               log.Fatalln("Node", nodeId, "does not have online communication capability")
+                       }
                        if len(node.Calls) == 0 {
                                ctx.LogD(
                                        "caller-no-calls",
index 099aa4761086eb3c87ce4d7822967e94908b7e40..3de629b59b5108b9c2d49bae226f9041cb8ccbe9 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -549,6 +549,9 @@ func (state *SPState) StartR(conn ConnDeadlined) error {
 
        var node *Node
        for _, n := range state.Ctx.Neigh {
+               if n.NoisePub == nil {
+                       continue
+               }
                if subtle.ConstantTimeCompare(state.hs.PeerStatic(), n.NoisePub[:]) == 1 {
                        node = n
                        break
index 337bcfd879576d9bcc1cb653c9080db8c110da70..0ddbd510db5411e62ae4abbe2d8db79b2ca41b08 100644 (file)
--- a/src/tx.go
+++ b/src/tx.go
@@ -60,7 +60,7 @@ func (ctx *Ctx) Tx(
        if areaId != nil {
                area = ctx.AreaId2Area[*areaId]
                if area.Prv == nil {
-                       return nil, errors.New("unknown area id")
+                       return nil, errors.New("area has no encryption keys")
                }
        }
        hops := make([]*Node, 0, 1+len(node.Via))