]> Cypherpunks.ru repositories - nncp.git/commitdiff
NNCPDEADLINE
authorSergey Matveev <stargrave@stargrave.org>
Wed, 26 Jan 2022 09:19:40 +0000 (12:19 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 26 Jan 2022 09:28:43 +0000 (12:28 +0300)
doc/news.ru.texi
doc/news.texi
doc/sp.texi
src/sp.go

index 73d32cc438bf9975d5a892910573a13a62b4fff0..18a271feabd9ca27d6500ced16b5cf8ac53b0a35 100644 (file)
 По ошибке @option{-mcd-wait} опция у @command{nncp-call} была включена
 по умолчанию.
 
+@item
+Возможность переопределять внутренний timeout по умолчанию для протокола
+синхронизации через @env{$NNCPDEADLINE} переменную окружения. Может быть
+полезно для каналов с очень большими задержками.
+
 @end itemize
 
 @node Релиз 8.4.0
index 5b913b220447fb8576eb36a9211b43183dcca711..b52f5140457c91af0d4d3f29fde83cc923558e56 100644 (file)
@@ -14,6 +14,11 @@ Fixed @command{nncp-bundle} workability.
 Mistakenly @option{-mcd-wait} option was enabled by default in
 @command{nncp-call}.
 
+@item
+Ability to override internal default timeout for online protocol through
+@env{$NNCPDEADLINE} environment variable. Can be useful for very high
+delay links.
+
 @end itemize
 
 @node Release 8_4_0
index 3944a752f630d5c53d1dd6bc9ef08f22e1994fb2..e7f4895c67f43c539915046887c1252d2de573b2 100644 (file)
@@ -12,6 +12,11 @@ high-delay links, so acknowledging of each received packet, like
 @url{https://en.wikipedia.org/wiki/XMODEM, XMODEM} does, causes
 unacceptable performance degradation.
 
+Internally it uses various timeouts and deadlines. One of them used
+extensively is 10 seconds default deadline timeout. You can override it
+with @env{$NNCPDEADLINE} environment variable, that could be useful with
+very high delay links.
+
 SP works on top of
 @url{http://noiseprotocol.org/noise.html#interactive-patterns,
 @code{Noise_IK_25519_ChaChaPoly_BLAKE2b}} protocol. Each Noise packet
index 4db358742a17b1f584aa102ac853a1c6386c6d13..e8e477cff9da8b5aa83b5ef75697142bd5c28cb8 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -27,6 +27,7 @@ import (
        "os"
        "path/filepath"
        "sort"
+       "strconv"
        "sync"
        "time"
 
@@ -39,6 +40,7 @@ const (
        MaxSPSize      = 1<<16 - 256
        PartSuffix     = ".part"
        SPHeadOverhead = 4
+       CfgDeadline    = "NNCPDEADLINE"
 )
 
 type MTHAndOffset struct {
@@ -132,6 +134,14 @@ type ConnDeadlined interface {
 }
 
 func init() {
+       if v := os.Getenv(CfgDeadline); v != "" {
+               i, err := strconv.Atoi(v)
+               if err != nil {
+                       log.Fatalln("Can not convert", CfgDeadline, "to integer:", err)
+               }
+               DefaultDeadline = time.Duration(i) * time.Second
+       }
+
        var buf bytes.Buffer
        spHead := SPHead{Type: SPTypeHalt}
        if _, err := xdr.Marshal(&buf, spHead); err != nil {