]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/call.go
Autotoss call options
[nncp.git] / src / call.go
index fd57bd1f283eaca0985adfc0e1bb8c4b9ff4ef01..87fb5aeef9a76769163ee6f78be87790c39e6404 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2019 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2021 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
@@ -19,7 +19,7 @@ package nncp
 
 import (
        "net"
-       "strconv"
+       "time"
 
        "github.com/gorhill/cronexpr"
 )
@@ -31,8 +31,15 @@ type Call struct {
        RxRate         int
        TxRate         int
        Addr           *string
-       OnlineDeadline uint
-       MaxOnlineTime  uint
+       OnlineDeadline time.Duration
+       MaxOnlineTime  time.Duration
+
+       AutoToss       bool
+       AutoTossDoSeen bool
+       AutoTossNoFile bool
+       AutoTossNoFreq bool
+       AutoTossNoExec bool
+       AutoTossNoTrns bool
 }
 
 func (ctx *Ctx) CallNode(
@@ -41,7 +48,7 @@ func (ctx *Ctx) CallNode(
        nice uint8,
        xxOnly TRxTx,
        rxRate, txRate int,
-       onlineDeadline, maxOnlineTime uint,
+       onlineDeadline, maxOnlineTime time.Duration,
        listOnly bool,
        onlyPkts map[[32]byte]bool,
 ) (isGood bool) {
@@ -77,18 +84,18 @@ func (ctx *Ctx) CallNode(
                        state.Wait()
                        ctx.LogI("call-finish", SDS{
                                "node":     state.Node.Id,
-                               "duration": strconv.FormatInt(int64(state.Duration.Seconds()), 10),
-                               "rxbytes":  strconv.FormatInt(state.RxBytes, 10),
-                               "txbytes":  strconv.FormatInt(state.TxBytes, 10),
-                               "rxspeed":  strconv.FormatInt(state.RxSpeed, 10),
-                               "txspeed":  strconv.FormatInt(state.TxSpeed, 10),
+                               "duration": int64(state.Duration.Seconds()),
+                               "rxbytes":  state.RxBytes,
+                               "txbytes":  state.TxBytes,
+                               "rxspeed":  state.RxSpeed,
+                               "txspeed":  state.TxSpeed,
                        }, "")
                        isGood = true
-                       conn.Close()
+                       conn.Close() // #nosec G104
                        break
                } else {
-                       ctx.LogE("call-start", SdsAdd(sds, SDS{"err": err}), "")
-                       conn.Close()
+                       ctx.LogE("call-start", sds, err, "")
+                       conn.Close() // #nosec G104
                }
        }
        return