X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fnncp%2Fcall.go;h=3f150652bd915f5d1a65d58cf85b8ed9821de549;hb=dd92823db3d72fb21a4c712a7fb052dce16443dd;hp=5b8e0584a4f334599f702d0273d8fdd5d5fb0ecf;hpb=646ff4cddf6370748e2a7e2d1e06535685329a62;p=nncp.git diff --git a/src/cypherpunks.ru/nncp/call.go b/src/cypherpunks.ru/nncp/call.go index 5b8e058..3f15065 100644 --- a/src/cypherpunks.ru/nncp/call.go +++ b/src/cypherpunks.ru/nncp/call.go @@ -1,11 +1,10 @@ /* NNCP -- Node to Node copy, utilities for store-and-forward data exchange -Copyright (C) 2016-2017 Sergey Matveev +Copyright (C) 2016-2019 Sergey Matveev 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 -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,9 +20,31 @@ package nncp import ( "net" "strconv" + + "github.com/gorhill/cronexpr" ) -func (ctx *Ctx) CallNode(node *Node, addrs []string, nice uint8, xxOnly *TRxTx, onlineDeadline, maxOnlineTime uint) (isGood bool) { +type Call struct { + Cron *cronexpr.Expression + Nice uint8 + Xx TRxTx + RxRate int + TxRate int + Addr *string + OnlineDeadline uint + MaxOnlineTime uint +} + +func (ctx *Ctx) CallNode( + node *Node, + addrs []string, + nice uint8, + xxOnly TRxTx, + rxRate, txRate int, + onlineDeadline, maxOnlineTime uint, + listOnly bool, + onlyPkts map[[32]byte]bool, +) (isGood bool) { for _, addr := range addrs { sds := SDS{"node": node.Id, "addr": addr} ctx.LogD("call", sds, "dialing") @@ -33,15 +54,19 @@ func (ctx *Ctx) CallNode(node *Node, addrs []string, nice uint8, xxOnly *TRxTx, continue } ctx.LogD("call", sds, "connected") - state, err := ctx.StartI( - conn, - node.Id, - nice, - xxOnly, - onlineDeadline, - maxOnlineTime, - ) - if err == nil { + state := SPState{ + Ctx: ctx, + Node: node, + Nice: nice, + onlineDeadline: onlineDeadline, + maxOnlineTime: maxOnlineTime, + xxOnly: xxOnly, + rxRate: rxRate, + txRate: txRate, + listOnly: listOnly, + onlyPkts: onlyPkts, + } + if err = state.StartI(conn); err == nil { ctx.LogI("call-start", sds, "connected") state.Wait() ctx.LogI("call-finish", SDS{