From 50476cec61ceeb54ac2dfbf37617ba0c07e0f6f7 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sun, 28 Apr 2019 12:35:40 +0300 Subject: [PATCH] Ability to transfer only specified packets in nncp-call --- doc/news.ru.texi | 6 +++--- doc/news.texi | 6 +++--- src/cypherpunks.ru/nncp/sp.go | 24 ++++++++++++++---------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 080333a..a17c2ef 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -14,10 +14,10 @@ Проверка доступного места перед копированием во время работы @command{nncp-xfer}, @command{nncp-daemon}, @command{nncp-call(er)}. @item -@command{nncp-call} теперь может только показывать список пакетов на -удалённой машине, без их передачи. +@command{nncp-call} имеет возможность только показывать список пакетов +на удалённой машине, без их передачи. @item -@command{nncp-call} может скачивать только чётко указанные пакеты. +@command{nncp-call} имеет возможность передавать только чётко указанные пакеты. @item Восстановлена работоспособность @option{xxrate} настройки в @option{calls} секции конфигурационного файла. diff --git a/doc/news.texi b/doc/news.texi index 80289c4..ed1bf08 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -15,10 +15,10 @@ decrypted data to external command. Older versions are not supported. Available free space checking before copying in @command{nncp-xfer}, @command{nncp-daemon}, @command{nncp-call(er)}. @item -@command{nncp-call} has ability only to listen packets on remote node, -without its transmission. +@command{nncp-call} has ability only to list packets on remote node, +without their transmission. @item -@command{nncp-call} has ability to download only specified packets. +@command{nncp-call} has ability to transfer only specified packets. @item Workability of @option{xxrate} preference in @option{calls} configuration file section. diff --git a/src/cypherpunks.ru/nncp/sp.go b/src/cypherpunks.ru/nncp/sp.go index bcdda79..f282514 100644 --- a/src/cypherpunks.ru/nncp/sp.go +++ b/src/cypherpunks.ru/nncp/sp.go @@ -949,18 +949,22 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) { state.Ctx.LogD("sp-process", sdsp, "queueing") nice, exists := state.infosOurSeen[*freq.Hash] if exists { - state.Lock() - insertIdx := 0 - var freqWithNice *FreqWithNice - for insertIdx, freqWithNice = range state.queueTheir { - if freqWithNice.nice > nice { - break + if state.onlyPkts == nil || !state.onlyPkts[*freq.Hash] { + state.Lock() + insertIdx := 0 + var freqWithNice *FreqWithNice + for insertIdx, freqWithNice = range state.queueTheir { + if freqWithNice.nice > nice { + break + } } + state.queueTheir = append(state.queueTheir, nil) + copy(state.queueTheir[insertIdx+1:], state.queueTheir[insertIdx:]) + state.queueTheir[insertIdx] = &FreqWithNice{&freq, nice} + state.Unlock() + } else { + state.Ctx.LogD("sp-process", sdsp, "skipping") } - state.queueTheir = append(state.queueTheir, nil) - copy(state.queueTheir[insertIdx+1:], state.queueTheir[insertIdx:]) - state.queueTheir[insertIdx] = &FreqWithNice{&freq, nice} - state.Unlock() } else { state.Ctx.LogD("sp-process", sdsp, "unknown") } -- 2.48.1