X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcfg.go;h=0937ab0f4f51d5eef96e6f2dd9d2b0d54cd57e7a;hb=e068d88291cd45a4d6b748e258077dd6c0ffb9c2;hp=5a404edd67b2149d0673c3af5054bbbf522a9672;hpb=acb393c45ae15e4d7c45a157e16851f7cb52ca48;p=nncp.git diff --git a/src/cfg.go b/src/cfg.go index 5a404ed..0937ab0 100644 --- a/src/cfg.go +++ b/src/cfg.go @@ -1,6 +1,6 @@ /* NNCP -- Node to Node copy, utilities for store-and-forward data exchange -Copyright (C) 2016-2021 Sergey Matveev +Copyright (C) 2016-2022 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ import ( "bytes" "encoding/json" "errors" + "fmt" "log" "os" "path" @@ -145,6 +146,8 @@ type CfgJSON struct { Neigh map[string]NodeJSON `json:"neigh"` Areas map[string]AreaJSON `json:"areas,omitempty"` + + YggdrasilAliases map[string]string `json:"yggdrasil-aliases,omitempty"` } func NewNode(name string, cfg NodeJSON) (*Node, error) { @@ -190,7 +193,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 +448,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 +468,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 @@ -538,6 +544,8 @@ func Cfg2Ctx(cfgJSON *CfgJSON) (*Ctx, error) { Alias: make(map[string]*NodeId), MCDRxIfis: cfgJSON.MCDRxIfis, MCDTxIfis: cfgJSON.MCDTxIfis, + + YggdrasilAliases: cfgJSON.YggdrasilAliases, } if cfgJSON.Notify != nil { if cfgJSON.Notify.File != nil {