]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cfg.go
exec notification
[nncp.git] / src / cfg.go
index ca8099e5fc5d08280e16e164d14b9c31e90de689..edc132a37ffc403a09dd55221871ceb07fb15a27 100644 (file)
@@ -68,6 +68,7 @@ type NodeFreqJSON struct {
        Path    *string `json:"path,omitempty"`
        Chunked *uint64 `json:"chunked,omitempty"`
        MinSize *uint64 `json:"minsize,omitempty"`
+       MaxSize *uint64 `json:"maxsize,omitempty"`
 }
 
 type CallJSON struct {
@@ -97,8 +98,9 @@ type FromToJSON struct {
 }
 
 type NotifyJSON struct {
-       File *FromToJSON `json:"file,omitempty"`
-       Freq *FromToJSON `json:"freq,omitempty"`
+       File *FromToJSON            `json:"file,omitempty"`
+       Freq *FromToJSON            `json:"freq,omitempty"`
+       Exec map[string]*FromToJSON `json:"exec,omitempty"`
 }
 
 type CfgJSON struct {
@@ -155,8 +157,9 @@ func NewNode(name string, yml NodeJSON) (*Node, error) {
        }
 
        var freqPath *string
-       var freqChunked int64
+       freqChunked := int64(MaxFileSize)
        var freqMinSize int64
+       freqMaxSize := int64(MaxFileSize)
        if yml.Freq != nil {
                f := yml.Freq
                if f.Path != nil {
@@ -175,6 +178,9 @@ func NewNode(name string, yml NodeJSON) (*Node, error) {
                if f.MinSize != nil {
                        freqMinSize = int64(*f.MinSize) * 1024
                }
+               if f.MaxSize != nil {
+                       freqMaxSize = int64(*f.MaxSize) * 1024
+               }
        }
 
        defRxRate := 0
@@ -278,6 +284,7 @@ func NewNode(name string, yml NodeJSON) (*Node, error) {
                FreqPath:       freqPath,
                FreqChunked:    freqChunked,
                FreqMinSize:    freqMinSize,
+               FreqMaxSize:    freqMaxSize,
                Calls:          calls,
                Addrs:          yml.Addrs,
                RxRate:         defRxRate,
@@ -431,6 +438,9 @@ func CfgParse(data []byte) (*Ctx, error) {
                if cfgJSON.Notify.Freq != nil {
                        ctx.NotifyFreq = cfgJSON.Notify.Freq
                }
+               if cfgJSON.Notify.Exec != nil {
+                       ctx.NotifyExec = cfgJSON.Notify.Exec
+               }
        }
        vias := make(map[NodeId][]string)
        for name, neighJSON := range cfgJSON.Neigh {