X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcfg.go;h=98bc80c1a4c35c249f91d2cfa1e2488c9daed480;hb=891cee4997bb0a269d4b2f35311bab104bdc3283;hp=5a404edd67b2149d0673c3af5054bbbf522a9672;hpb=acb393c45ae15e4d7c45a157e16851f7cb52ca48;p=nncp.git diff --git a/src/cfg.go b/src/cfg.go index 5a404ed..98bc80c 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" @@ -37,6 +38,7 @@ const ( CfgPathEnv = "NNCPCFG" CfgSpoolEnv = "NNCPSPOOL" CfgLogEnv = "NNCPLOG" + CfgNoSync = "NNCPNOSYNC" ) var ( @@ -145,6 +147,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 +194,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 +449,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 +469,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 +545,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 {