]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cfg.go
Fixed freq.chunked calculation
[nncp.git] / src / cfg.go
index 5a404edd67b2149d0673c3af5054bbbf522a9672..d46bf0e08ce8dbbed9dfddef04f6fc722100b02e 100644 (file)
@@ -21,6 +21,7 @@ import (
        "bytes"
        "encoding/json"
        "errors"
+       "fmt"
        "log"
        "os"
        "path"
@@ -190,7 +191,7 @@ func NewNode(name string, cfg NodeJSON) (*Node, error) {
        }
 
        var freqPath *string
-       freqChunked := int64(MaxFileSize)
+       var freqChunked int64
        var freqMinSize int64
        freqMaxSize := int64(MaxFileSize)
        if cfg.Freq != nil {
@@ -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
@@ -462,12 +466,12 @@ func NewArea(ctx *Ctx, name string, cfg *AreaJSON) (*Area, error) {
 func CfgParse(data []byte) (*CfgJSON, error) {
        var err error
        if bytes.Compare(data[:8], MagicNNCPBv3.B[:]) == 0 {
-               os.Stderr.WriteString("Passphrase:") // #nosec G104
+               os.Stderr.WriteString("Passphrase:")
                password, err := term.ReadPassword(0)
                if err != nil {
                        log.Fatalln(err)
                }
-               os.Stderr.WriteString("\n") // #nosec G104
+               os.Stderr.WriteString("\n")
                data, err = DeEBlob(data, password)
                if err != nil {
                        return nil, err