/*
NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
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
handle,
[]string{"arg0", "arg1"},
strings.NewReader("BODY\n"),
- 1<<15,
- false,
+ 1<<15, MaxFileSize,
false,
nil,
); err != nil {
}
files := make(map[string][]byte)
for i, fileSize := range fileSizes {
+ if fileSize == 0 {
+ // to prevent chunked send
+ fileSize++
+ }
data := make([]byte, fileSize)
if _, err := io.ReadFull(rand.Reader, data); err != nil {
panic(err)
return false
}
ctx.Neigh[*nodeOur.Id].Incoming = &incomingPath
- ctx.Toss(ctx.Self.Id, TRx, DefaultNiceFile,
- false, false, false, false, false, false, false)
+ if ctx.Toss(ctx.Self.Id, TRx, DefaultNiceFile,
+ false, false, false, false, false, false, false) {
+ return false
+ }
if len(dirFiles(rxPath)) != 0 {
return false
}
ctx.Neigh[*nodeOur.Id] = nodeOur.Their()
files := make(map[string][]byte)
for i, fileSize := range fileSizes {
+ if fileSize == 0 {
+ // to prevent chunked send
+ fileSize++
+ }
fileData := make([]byte, fileSize)
if _, err := io.ReadFull(rand.Reader, fileData); err != nil {
panic(err)
}
copy(pktTrans.Path[:], nodeOur.Id[:])
var dst bytes.Buffer
- if _, err := PktEncWrite(
+ if _, _, err := PktEncWrite(
ctx.Self,
ctx.Neigh[*nodeOur.Id],
&pktTrans,
123,
- int64(len(data)),
- 0,
+ 0, MaxFileSize, 1,
bytes.NewReader(data),
&dst,
); err != nil {