2 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
3 Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 "github.com/gorhill/cronexpr"
28 Cron *cronexpr.Expression
34 OnlineDeadline time.Duration
35 MaxOnlineTime time.Duration
45 func (ctx *Ctx) CallNode(
51 onlineDeadline, maxOnlineTime time.Duration,
53 onlyPkts map[[32]byte]bool,
55 for _, addr := range addrs {
56 sds := SDS{"node": node.Id, "addr": addr}
57 ctx.LogD("call", sds, "dialing")
58 var conn ConnDeadlined
61 conn, err = NewPipeConn(addr[1:])
63 conn, err = net.Dial("tcp", addr)
66 ctx.LogD("call", SdsAdd(sds, SDS{"err": err}), "dialing")
69 ctx.LogD("call", sds, "connected")
74 onlineDeadline: onlineDeadline,
75 maxOnlineTime: maxOnlineTime,
82 if err = state.StartI(conn); err == nil {
83 ctx.LogI("call-start", sds, "connected")
85 ctx.LogI("call-finish", SDS{
86 "node": state.Node.Id,
87 "duration": int64(state.Duration.Seconds()),
88 "rxbytes": state.RxBytes,
89 "txbytes": state.TxBytes,
90 "rxspeed": state.RxSpeed,
91 "txspeed": state.TxSpeed,
94 conn.Close() // #nosec G104
97 ctx.LogE("call-start", sds, err, "")
98 conn.Close() // #nosec G104