X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcfg.go;h=a57277e88be3462aee9c4dcc4ab1d1282d07cd62;hb=d386e5b28dc603ac4ffac10337f322e15bc92d80;hp=ee8f4c63c348896f2fdf212b52a5112ca3e74f7f;hpb=0367cce2741e1ce6a89a49fd5c4e9df6005c9744;p=nncp.git diff --git a/src/cfg.go b/src/cfg.go index ee8f4c6..a57277e 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-2022 Sergey Matveev +Copyright (C) 2016-2023 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 @@ -38,6 +38,7 @@ const ( CfgPathEnv = "NNCPCFG" CfgSpoolEnv = "NNCPSPOOL" CfgLogEnv = "NNCPLOG" + CfgNoSync = "NNCPNOSYNC" ) var ( @@ -146,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) { @@ -465,7 +468,7 @@ 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 { + if bytes.Equal(data[:8], MagicNNCPBv3.B[:]) { os.Stderr.WriteString("Passphrase:") password, err := term.ReadPassword(0) if err != nil { @@ -476,9 +479,9 @@ func CfgParse(data []byte) (*CfgJSON, error) { if err != nil { return nil, err } - } else if bytes.Compare(data[:8], MagicNNCPBv2.B[:]) == 0 { + } else if bytes.Equal(data[:8], MagicNNCPBv2.B[:]) { log.Fatalln(MagicNNCPBv2.TooOld()) - } else if bytes.Compare(data[:8], MagicNNCPBv1.B[:]) == 0 { + } else if bytes.Equal(data[:8], MagicNNCPBv1.B[:]) { log.Fatalln(MagicNNCPBv1.TooOld()) } var cfgGeneral map[string]interface{} @@ -542,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 {