]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cfg.go
Use bytes.Equal() instead of bytes.Compare()==0
[nncp.git] / src / cfg.go
index ee8f4c63c348896f2fdf212b52a5112ca3e74f7f..a57277e88be3462aee9c4dcc4ab1d1282d07cd62 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2023 Sergey Matveev <stargrave@stargrave.org>
 
 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 {