]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cfg.go
nncp-pkt is able to parse .hdr
[nncp.git] / src / cfg.go
index 946243396b7403c99aa499e22fd870a123516365..bb101cac2914c8af566e5dd7cbf0fe6b3c91da73 100644 (file)
@@ -82,6 +82,8 @@ type CallJSON struct {
        OnlineDeadline *uint   `json:"onlinedeadline,omitempty"`
        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"`
@@ -118,11 +120,15 @@ type CfgJSON struct {
        Umask string `json:"umask,omitempty"`
 
        OmitPrgrs bool `json:"noprogress,omitempty"`
+       NoHdr     bool `json:"nohdr,omitempty"`
 
        Notify *NotifyJSON `json:"notify,omitempty"`
 
        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) {
@@ -284,6 +290,12 @@ func NewNode(name string, cfg NodeJSON) (*Node, error) {
                if callCfg.WhenTxExists != nil {
                        call.WhenTxExists = *callCfg.WhenTxExists
                }
+               if callCfg.NoCK != nil {
+                       call.NoCK = *callCfg.NoCK
+               }
+               if callCfg.MCDIgnore != nil {
+                       call.MCDIgnore = *callCfg.MCDIgnore
+               }
                if callCfg.AutoToss != nil {
                        call.AutoToss = *callCfg.AutoToss
                }
@@ -404,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 {
@@ -415,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 {
@@ -459,14 +475,21 @@ func CfgParse(data []byte) (*Ctx, error) {
        if cfgJSON.OmitPrgrs {
                showPrgrs = false
        }
+       hdrUsage := true
+       if cfgJSON.NoHdr {
+               hdrUsage = false
+       }
        ctx := Ctx{
                Spool:      spoolPath,
                LogPath:    logPath,
                UmaskForce: umaskForce,
                ShowPrgrs:  showPrgrs,
+               HdrUsage:   hdrUsage,
                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 {