]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cfg.go
Mode NodeName to appropriate place
[nncp.git] / src / cfg.go
index 6e781d19e62a0ca1d6f0e628466f91be8af22a6d..bb101cac2914c8af566e5dd7cbf0fe6b3c91da73 100644 (file)
@@ -83,6 +83,7 @@ type CallJSON struct {
        MaxOnlineTime  *uint   `json:"maxonlinetime,omitempty"`
        WhenTxExists   *bool   `json:"when-tx-exists,omitempty"`
        NoCK           *bool   `json:"nock"`
+       MCDIgnore      *bool   `json:"mcd-ignore"`
 
        AutoToss       *bool `json:"autotoss,omitempty"`
        AutoTossDoSeen *bool `json:"autotoss-doseen,omitempty"`
@@ -125,6 +126,9 @@ type CfgJSON struct {
 
        Self  *NodeOurJSON        `json:"self"`
        Neigh map[string]NodeJSON `json:"neigh"`
+
+       MCDRxIfis []string       `json:"mcd-listen"`
+       MCDTxIfis map[string]int `json:"mcd-send"`
 }
 
 func NewNode(name string, cfg NodeJSON) (*Node, error) {
@@ -289,6 +293,9 @@ func NewNode(name string, cfg NodeJSON) (*Node, error) {
                if callCfg.NoCK != nil {
                        call.NoCK = *callCfg.NoCK
                }
+               if callCfg.MCDIgnore != nil {
+                       call.MCDIgnore = *callCfg.MCDIgnore
+               }
                if callCfg.AutoToss != nil {
                        call.AutoToss = *callCfg.AutoToss
                }
@@ -409,7 +416,7 @@ func NewNodeOur(cfg *NodeOurJSON) (*NodeOur, error) {
 
 func CfgParse(data []byte) (*Ctx, error) {
        var err error
-       if bytes.Compare(data[:8], MagicNNCPBv3[:]) == 0 {
+       if bytes.Compare(data[:8], MagicNNCPBv3.B[:]) == 0 {
                os.Stderr.WriteString("Passphrase:") // #nosec G104
                password, err := term.ReadPassword(0)
                if err != nil {
@@ -420,6 +427,10 @@ func CfgParse(data []byte) (*Ctx, error) {
                if err != nil {
                        return nil, err
                }
+       } else if bytes.Compare(data[:8], MagicNNCPBv2.B[:]) == 0 {
+               log.Fatalln(MagicNNCPBv2.TooOld())
+       } else if bytes.Compare(data[:8], MagicNNCPBv1.B[:]) == 0 {
+               log.Fatalln(MagicNNCPBv1.TooOld())
        }
        var cfgGeneral map[string]interface{}
        if err = hjson.Unmarshal(data, &cfgGeneral); err != nil {
@@ -477,6 +488,8 @@ func CfgParse(data []byte) (*Ctx, error) {
                Self:       self,
                Neigh:      make(map[NodeId]*Node, len(cfgJSON.Neigh)),
                Alias:      make(map[string]*NodeId),
+               MCDRxIfis:  cfgJSON.MCDRxIfis,
+               MCDTxIfis:  cfgJSON.MCDTxIfis,
        }
        if cfgJSON.Notify != nil {
                if cfgJSON.Notify.File != nil {