2 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
3 Copyright (C) 2016-2019 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, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 "github.com/gorhill/cronexpr"
29 Cron *cronexpr.Expression
39 func (ctx *Ctx) CallNode(
45 onlineDeadline, maxOnlineTime uint,
47 onlyPkts map[[32]byte]bool,
49 for _, addr := range addrs {
50 sds := SDS{"node": node.Id, "addr": addr}
51 ctx.LogD("call", sds, "dialing")
52 conn, err := net.Dial("tcp", addr)
54 ctx.LogD("call", SdsAdd(sds, SDS{"err": err}), "dialing")
57 ctx.LogD("call", sds, "connected")
62 onlineDeadline: onlineDeadline,
63 maxOnlineTime: maxOnlineTime,
70 if err = state.StartI(conn); err == nil {
71 ctx.LogI("call-start", sds, "connected")
73 ctx.LogI("call-finish", SDS{
74 "node": state.Node.Id,
75 "duration": strconv.FormatInt(int64(state.Duration.Seconds()), 10),
76 "rxbytes": strconv.FormatInt(state.RxBytes, 10),
77 "txbytes": strconv.FormatInt(state.TxBytes, 10),
78 "rxspeed": strconv.FormatInt(state.RxSpeed, 10),
79 "txspeed": strconv.FormatInt(state.TxSpeed, 10),
85 ctx.LogE("call-start", SdsAdd(sds, SDS{"err": err}), "")