]> Cypherpunks.ru repositories - nncp.git/commitdiff
Ability to do chunked freqing
authorSergey Matveev <stargrave@stargrave.org>
Sat, 29 Apr 2017 08:23:17 +0000 (11:23 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 29 Apr 2017 08:40:02 +0000 (11:40 +0300)
doc/cfg.texi
doc/cmds.texi
doc/news.texi
src/cypherpunks.ru/nncp/cfg.go
src/cypherpunks.ru/nncp/node.go
src/cypherpunks.ru/nncp/toss.go

index 653c8013f3b71e4a7ee07f3af47a3faf2b0bde1b..ea104f51da53f2b338cf613b9ba186b4cf5a6867 100644 (file)
@@ -49,6 +49,8 @@ neigh:
     signpub: GTGXG...IE3OA
     sendmail: [/usr/sbin/sendmail]
     freq: /home/bob/pub
+    freqchunked: 1024
+    freqminsize: 2097152
     via: [alice]
 @end verbatim
 
@@ -99,6 +101,14 @@ omitted to forbid file uploading on that node.
 Full path to directory from where file requests will queue files for
 transmission. May be omitted to forbid freqing from that node.
 
+@item freqchunked
+If set, then enable @ref{Chunked, chunked} file transmission during
+freqing. This is the desired chunk size in KiBs.
+
+@item freqminsize
+If set, then apply @ref{OptMinSize, -minsize} option during file
+transmission.
+
 @item via
 An array of node identifiers that will be used as a relay to that node.
 For example @verb{|[foo,bar]|} means that packet can reach current node
index 5d7d6335923c886863d58fba4af6db7475cb1baf..b8da1d949b84551dce87ced936e6352ace950167 100644 (file)
@@ -10,9 +10,10 @@ Nearly all commands have the following common options:
 @item -debug
     Print debug messages. Normally this option should not be used.
 @item -minsize
-    Minimal required resulting packet size. For example if you send 2
-    KiB file and set @option{-minsize 4096}, then resulting packet will
-    be 4 KiB (containing file itself and some junk).
+    @anchor{OptMinSize}
+    Minimal required resulting packet size, in bytes. For example if you
+    send 2 KiB file and set @option{-minsize 4096}, then resulting
+    packet will be 4 KiB (containing file itself and some junk).
 @item -nice
     Set desired outgoing packet @ref{Niceness, niceness level}.
     1-255 values are allowed.
index 77e63a1fcc15bda7be3a7dd497b0a18ae7424188..5f3bd27e731c99a86885d5c4e58d6f4b37cf634b 100644 (file)
@@ -7,8 +7,10 @@
 @item Ability to feed @command{nncp-file} from stdin, that uses an
 encrypted temporary file for that.
 @item Chunked files transmission appeared with corresponding
-@command{nncp-reass} command. Useful for transferring big files over
-small storage devices.
+@command{nncp-reass} command and @option{freqchunked} configuration file
+entry. Useful for transferring big files over small storage devices.
+@item @option{freqminsize} configuration file option, analogue to
+@option{-minsize} one.
 @item Cryptographic libraries (dependecies) are updated.
 @end itemize
 
index f89c106f3c3178dadaa3a736b8277f16ad205b7c..ce70963661c07a01af906646fd35a9328009f6c5 100644 (file)
@@ -40,15 +40,17 @@ var (
 )
 
 type NodeYAML struct {
-       Id       string
-       ExchPub  string
-       SignPub  string
-       NoisePub *string    `noisepub,omitempty`
-       Sendmail []string   `sendmail,omitempty`
-       Incoming *string    `incoming,omitempty`
-       Freq     *string    `freq,omitempty`
-       Via      []string   `via,omitempty`
-       Calls    []CallYAML `calls,omitempty`
+       Id          string
+       ExchPub     string
+       SignPub     string
+       NoisePub    *string    `noisepub,omitempty`
+       Sendmail    []string   `sendmail,omitempty`
+       Incoming    *string    `incoming,omitempty`
+       Freq        *string    `freq,omitempty`
+       FreqChunked *uint64    `freqchunked,omitempty`
+       FreqMinSize *uint64    `freqminsize,omitempty`
+       Via         []string   `via,omitempty`
+       Calls       []CallYAML `calls,omitempty`
 
        Addrs map[string]string `addrs,omitempty`
 
@@ -144,6 +146,17 @@ func NewNode(name string, yml NodeYAML) (*Node, error) {
                }
                freq = &fr
        }
+       var freqChunked int64
+       if yml.FreqChunked != nil {
+               if *yml.FreqChunked == 0 {
+                       return nil, errors.New("freqchunked value must be greater than zero")
+               }
+               freqChunked = int64(*yml.FreqChunked)
+       }
+       var freqMinSize int64
+       if yml.FreqMinSize != nil {
+               freqMinSize = int64(*yml.FreqMinSize)
+       }
 
        defOnlineDeadline := uint(DefaultDeadline)
        if yml.OnlineDeadline != nil {
@@ -218,6 +231,8 @@ func NewNode(name string, yml NodeYAML) (*Node, error) {
                Sendmail:       yml.Sendmail,
                Incoming:       incoming,
                Freq:           freq,
+               FreqChunked:    freqChunked,
+               FreqMinSize:    freqMinSize,
                Calls:          calls,
                Addrs:          yml.Addrs,
                OnlineDeadline: defOnlineDeadline,
index 7992f4bc8f1ce19d4c6a2b3e7d13f7cd937f1b78..22fa3fb2e03663f81f47c7ba06633d2209ea9934 100644 (file)
@@ -45,6 +45,8 @@ type Node struct {
        Sendmail       []string
        Incoming       *string
        Freq           *string
+       FreqChunked    int64
+       FreqMinSize    int64
        Via            []*NodeId
        Addrs          map[string]string
        OnlineDeadline uint
index 8a48e91d50a4d7eab80d5fa09041032763e1a9b4..4ae9711f8d7d6f42fbefb50b1363ef3001ccaef6 100644 (file)
@@ -264,7 +264,25 @@ func (ctx *Ctx) Toss(nodeId *NodeId, nice uint8, dryRun bool) bool {
                                goto Closing
                        }
                        if !dryRun {
-                               if err = ctx.TxFile(sender, job.PktEnc.Nice, filepath.Join(*freq, src), dst, 0); err != nil {
+                               if sender.FreqChunked == 0 {
+                                       err = ctx.TxFile(
+                                               sender,
+                                               job.PktEnc.Nice,
+                                               filepath.Join(*freq, src),
+                                               dst,
+                                               sender.FreqMinSize,
+                                       )
+                               } else {
+                                       err = ctx.TxFileChunked(
+                                               sender,
+                                               job.PktEnc.Nice,
+                                               filepath.Join(*freq, src),
+                                               dst,
+                                               sender.FreqMinSize,
+                                               sender.FreqChunked,
+                                       )
+                               }
+                               if err != nil {
                                        ctx.LogE("rx", SdsAdd(sds, SDS{"err": err}), "tx file")
                                        isBad = true
                                        goto Closing