]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cfg.go
.hdr files
[nncp.git] / src / cfg.go
index 50ad498d647c1af91dacf9d1e5376f0acc73e7a6..6e781d19e62a0ca1d6f0e628466f91be8af22a6d 100644 (file)
@@ -81,6 +81,15 @@ type CallJSON struct {
        Addr           *string `json:"addr,omitempty"`
        OnlineDeadline *uint   `json:"onlinedeadline,omitempty"`
        MaxOnlineTime  *uint   `json:"maxonlinetime,omitempty"`
+       WhenTxExists   *bool   `json:"when-tx-exists,omitempty"`
+       NoCK           *bool   `json:"nock"`
+
+       AutoToss       *bool `json:"autotoss,omitempty"`
+       AutoTossDoSeen *bool `json:"autotoss-doseen,omitempty"`
+       AutoTossNoFile *bool `json:"autotoss-nofile,omitempty"`
+       AutoTossNoFreq *bool `json:"autotoss-nofreq,omitempty"`
+       AutoTossNoExec *bool `json:"autotoss-noexec,omitempty"`
+       AutoTossNoTrns *bool `json:"autotoss-notrns,omitempty"`
 }
 
 type NodeOurJSON struct {
@@ -110,6 +119,7 @@ type CfgJSON struct {
        Umask string `json:"umask,omitempty"`
 
        OmitPrgrs bool `json:"noprogress,omitempty"`
+       NoHdr     bool `json:"nohdr,omitempty"`
 
        Notify *NotifyJSON `json:"notify,omitempty"`
 
@@ -260,12 +270,7 @@ func NewNode(name string, cfg NodeJSON) (*Node, error) {
                        onlineDeadline = time.Duration(*callCfg.OnlineDeadline) * time.Second
                }
 
-               var maxOnlineTime time.Duration
-               if callCfg.MaxOnlineTime != nil {
-                       maxOnlineTime = time.Duration(*callCfg.MaxOnlineTime) * time.Second
-               }
-
-               calls = append(calls, &Call{
+               call := Call{
                        Cron:           expr,
                        Nice:           nice,
                        Xx:             xx,
@@ -273,8 +278,37 @@ func NewNode(name string, cfg NodeJSON) (*Node, error) {
                        TxRate:         txRate,
                        Addr:           addr,
                        OnlineDeadline: onlineDeadline,
-                       MaxOnlineTime:  maxOnlineTime,
-               })
+               }
+
+               if callCfg.MaxOnlineTime != nil {
+                       call.MaxOnlineTime = time.Duration(*callCfg.MaxOnlineTime) * time.Second
+               }
+               if callCfg.WhenTxExists != nil {
+                       call.WhenTxExists = *callCfg.WhenTxExists
+               }
+               if callCfg.NoCK != nil {
+                       call.NoCK = *callCfg.NoCK
+               }
+               if callCfg.AutoToss != nil {
+                       call.AutoToss = *callCfg.AutoToss
+               }
+               if callCfg.AutoTossDoSeen != nil {
+                       call.AutoTossDoSeen = *callCfg.AutoTossDoSeen
+               }
+               if callCfg.AutoTossNoFile != nil {
+                       call.AutoTossNoFile = *callCfg.AutoTossNoFile
+               }
+               if callCfg.AutoTossNoFreq != nil {
+                       call.AutoTossNoFreq = *callCfg.AutoTossNoFreq
+               }
+               if callCfg.AutoTossNoExec != nil {
+                       call.AutoTossNoExec = *callCfg.AutoTossNoExec
+               }
+               if callCfg.AutoTossNoTrns != nil {
+                       call.AutoTossNoTrns = *callCfg.AutoTossNoTrns
+               }
+
+               calls = append(calls, &call)
        }
 
        node := Node{
@@ -430,11 +464,16 @@ 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),