MaxOnlineTime uint
}
-func (ctx *Ctx) CallNode(node *Node, addrs []string, nice uint8, xxOnly TRxTx, rxRate, txRate int, onlineDeadline, maxOnlineTime uint) (isGood bool) {
+func (ctx *Ctx) CallNode(
+ node *Node,
+ addrs []string,
+ nice uint8,
+ xxOnly TRxTx,
+ rxRate, txRate int,
+ onlineDeadline, maxOnlineTime uint) (isGood bool) {
for _, addr := range addrs {
sds := SDS{"node": node.Id, "addr": addr}
ctx.LogD("call", sds, "dialing")
return written, nil
}
-func PktEncWrite(our *NodeOur, their *Node, pkt *Pkt, nice uint8, size, padSize int64, data io.Reader, out io.Writer) error {
+func PktEncWrite(
+ our *NodeOur,
+ their *Node,
+ pkt *Pkt,
+ nice uint8,
+ size, padSize int64,
+ data io.Reader,
+ out io.Writer) error {
pubEph, prvEph, err := box.GenerateKey(rand.Reader)
if err != nil {
return err
return ed25519.Verify(their.SignPub, tbsBuf.Bytes(), pktEnc.Sign[:]), nil
}
-func PktEncRead(our *NodeOur, nodes map[NodeId]*Node, data io.Reader, out io.Writer) (*Node, int64, error) {
+func PktEncRead(
+ our *NodeOur,
+ nodes map[NodeId]*Node,
+ data io.Reader,
+ out io.Writer) (*Node, int64, error) {
var pktEnc PktEnc
_, err := xdr.Unmarshal(data, &pktEnc)
if err != nil {
if err != nil {
panic(err)
}
- f := func(path string, pathSize uint8, data [1 << 16]byte, size, padSize uint16, junk []byte) bool {
+ f := func(
+ path string,
+ pathSize uint8,
+ data [1 << 16]byte,
+ size, padSize uint16,
+ junk []byte) bool {
dataR := bytes.NewReader(data[:])
var ct bytes.Buffer
if len(path) > int(pathSize) {
if state.maxOnlineTime > 0 && state.started.Add(time.Duration(state.maxOnlineTime)*time.Second).Before(now) {
return true
}
- return uint(now.Sub(state.RxLastSeen).Seconds()) >= state.onlineDeadline && uint(now.Sub(state.TxLastSeen).Seconds()) >= state.onlineDeadline
+ return uint(now.Sub(state.RxLastSeen).Seconds()) >= state.onlineDeadline &&
+ uint(now.Sub(state.TxLastSeen).Seconds()) >= state.onlineDeadline
}
func (state *SPState) dirUnlock() {
return payloadsSplit(payloads)
}
-func (ctx *Ctx) StartI(conn net.Conn, nodeId *NodeId, nice uint8, xxOnly TRxTx, rxRate, txRate int, onlineDeadline, maxOnlineTime uint) (*SPState, error) {
+func (ctx *Ctx) StartI(
+ conn net.Conn,
+ nodeId *NodeId,
+ nice uint8,
+ xxOnly TRxTx,
+ rxRate, txRate int,
+ onlineDeadline, maxOnlineTime uint) (*SPState, error) {
err := ctx.ensureRxDir(nodeId)
if err != nil {
return nil, err
return &state, err
}
-func (state *SPState) StartWorkers(conn net.Conn, infosPayloads [][]byte, payload []byte) error {
+func (state *SPState) StartWorkers(
+ conn net.Conn,
+ infosPayloads [][]byte,
+ payload []byte) error {
sds := SDS{"node": state.Node.Id, "nice": strconv.Itoa(int(state.nice))}
if len(infosPayloads) > 1 {
go func() {
))
}
-func (ctx *Ctx) Toss(nodeId *NodeId, nice uint8, dryRun, doSeen, noFile, noFreq, noExec, noTrns bool) bool {
+func (ctx *Ctx) Toss(
+ nodeId *NodeId,
+ nice uint8,
+ dryRun, doSeen, noFile, noFreq, noExec, noTrns bool) bool {
isBad := false
for job := range ctx.Jobs(nodeId, TRx) {
pktName := filepath.Base(job.Fd.Name())
"golang.org/x/crypto/blake2b"
)
-func (ctx *Ctx) Tx(node *Node, pkt *Pkt, nice uint8, size, minSize int64, src io.Reader) (*Node, error) {
+func (ctx *Ctx) Tx(
+ node *Node,
+ pkt *Pkt,
+ nice uint8,
+ size, minSize int64,
+ src io.Reader) (*Node, error) {
tmp, err := ctx.NewTmpFileWHash()
if err != nil {
return nil, err
return err
}
-func (ctx *Ctx) TxFileChunked(node *Node, nice uint8, srcPath, dstPath string, minSize int64, chunkSize int64) error {
+func (ctx *Ctx) TxFileChunked(
+ node *Node,
+ nice uint8,
+ srcPath, dstPath string,
+ minSize int64,
+ chunkSize int64) error {
if dstPath == "" {
if srcPath == "-" {
return errors.New("Must provide destination filename")
return err
}
-func (ctx *Ctx) TxFreq(node *Node, nice, replyNice uint8, srcPath, dstPath string, minSize int64) error {
+func (ctx *Ctx) TxFreq(
+ node *Node,
+ nice, replyNice uint8,
+ srcPath, dstPath string,
+ minSize int64) error {
dstPath = filepath.Clean(dstPath)
if filepath.IsAbs(dstPath) {
return errors.New("Relative destination path required")
return err
}
-func (ctx *Ctx) TxExec(node *Node, nice, replyNice uint8, handle string, args []string, body []byte, minSize int64) error {
+func (ctx *Ctx) TxExec(
+ node *Node,
+ nice, replyNice uint8,
+ handle string,
+ args []string,
+ body []byte,
+ minSize int64) error {
path := make([][]byte, 0, 1+len(args))
path = append(path, []byte(handle))
for _, arg := range args {