From a7bc092eb93fb9526b27bca20ae7b88b01d99f84 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 26 Jan 2022 12:19:40 +0300 Subject: [PATCH] NNCPDEADLINE --- doc/news.ru.texi | 5 +++++ doc/news.texi | 5 +++++ doc/sp.texi | 5 +++++ src/sp.go | 10 ++++++++++ 4 files changed, 25 insertions(+) diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 73d32cc..18a271f 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -12,6 +12,11 @@ По ошибке @option{-mcd-wait} опция у @command{nncp-call} была включена по умолчанию. +@item +Возможность переопределять внутренний timeout по умолчанию для протокола +синхронизации через @env{$NNCPDEADLINE} переменную окружения. Может быть +полезно для каналов с очень большими задержками. + @end itemize @node Релиз 8.4.0 diff --git a/doc/news.texi b/doc/news.texi index 5b913b2..b52f514 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -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 diff --git a/doc/sp.texi b/doc/sp.texi index 3944a75..e7f4895 100644 --- a/doc/sp.texi +++ b/doc/sp.texi @@ -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 diff --git a/src/sp.go b/src/sp.go index 4db3587..e8e477c 100644 --- 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 { -- 2.44.0