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
46 func (ctx *Ctx) CallNode(
52 onlineDeadline, maxOnlineTime time.Duration,
54 onlyPkts map[[32]byte]bool,
56 for _, addr := range addrs {
57 les := LEs{{"Node", node.Id}, {"Addr", addr}}
58 ctx.LogD("call", les, "dialing")
59 var conn ConnDeadlined
62 conn, err = NewPipeConn(addr[1:])
64 conn, err = net.Dial("tcp", addr)
67 ctx.LogD("call", append(les, LE{"Err", err}), "dialing")
70 ctx.LogD("call", les, "connected")
75 onlineDeadline: onlineDeadline,
76 maxOnlineTime: maxOnlineTime,
83 if err = state.StartI(conn); err == nil {
84 ctx.LogI("call-start", les, "connected")
86 ctx.LogI("call-finish", LEs{
87 {"Node", state.Node.Id},
88 {"Duration", int64(state.Duration.Seconds())},
89 {"RxBytes", state.RxBytes},
90 {"TxBytes", state.TxBytes},
91 {"RxSpeed", state.RxSpeed},
92 {"TxSpeed", state.TxSpeed},
95 conn.Close() // #nosec G104
98 ctx.LogE("call-start", les, err, "")
99 conn.Close() // #nosec G104