]> Cypherpunks.ru repositories - nncp.git/commitdiff
SP checks .seen existence
authorSergey Matveev <stargrave@stargrave.org>
Sat, 2 Jun 2018 18:21:28 +0000 (21:21 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 10 Jun 2018 10:14:59 +0000 (13:14 +0300)
VERSION
doc/Makefile
doc/news.ru.texi
doc/news.texi
doc/sp.texi
doc/sp.txt [new file with mode: 0644]
ports/nncp/Makefile
src/cypherpunks.ru/nncp/sp.go

diff --git a/VERSION b/VERSION
index a3ec5a4bd3d7209b4a687a77cad49b945339994b..eb39e5382f4f035e4d71c7f67712cdbfa6c0c335 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.2
+3.3
index 4e65b0fe549402cc16a91d150962c62e5b3de85b..4e92b3e5a75ea41b6e37985c61de63792d603780 100644 (file)
@@ -2,12 +2,15 @@ all: nncp.info nncp.html
 
 MAKEINFO ?= makeinfo
 
-nncp.info: *.texi pedro.txt
+sp.utxt: sp.txt
+       plantuml -tutxt sp.txt
+
+nncp.info: *.texi sp.utxt pedro.txt
        $(MAKEINFO) -o nncp.info index.texi
 
 CSS != cat style.css
 
-nncp.html: *.texi pedro.txt
+nncp.html: *.texi sp.utxt pedro.txt
        rm -f nncp.html/*.html
        $(MAKEINFO) --html \
                --set-customization-variable CSS_LINES='$(CSS)' \
index 0cc0e7a37f41cf88de3925e2fd523d4d5ac92dd3..5aebb84d17f13c2e56e4cbcdb7b5f58ef5748203 100644 (file)
@@ -1,6 +1,16 @@
 @node Новости
 @section Новости
 
+@node Релиз 3.3
+@subsection Релиз 3.3
+@itemize
+@item
+@command{nncp-daemon}, @command{nncp-call}, @command{nncp-caller}
+проверяют существование @file{.seen} файла и расценивают его как то, что
+файл уже был скачан. Возможно передача данных была осуществлена
+сторонним способом и удалённая сторона должна быть оповещена об этом.
+@end itemize
+
 @node Релиз 3.2
 @subsection Релиз 3.2
 @itemize
index ae4c1a94abb586bcf46b85a9e85fe470c8747ccb..123a1ca3f45d6f0d3bce571e71ea543e456b676f 100644 (file)
@@ -3,6 +3,16 @@
 
 See also this page @ref{Новости, on russian}.
 
+@node Release 3.3
+@section Release 3.3
+@itemize
+@item
+@command{nncp-daemon}, @command{nncp-call}, @command{nncp-caller} check
+if @file{.seen} exists and treat it like file was already downloaded.
+Possibly it was transferred out-of-bound and remote side needs to be
+notifier about that.
+@end itemize
+
 @node Release 3.2
 @section Release 3.2
 @itemize
index 919cca108c2104bc58a63f06bb70465685a114b1..41ebf45121da6e1284563dad454bbe3ad16a7ff8 100644 (file)
@@ -136,36 +136,62 @@ just an unsigned integer telling what body structure follows.
 
 Typical peer's behaviour is following:
 
+@verbatiminclude sp.utxt
+
 @enumerate
-@item Perform Noise-IK handshake.
-@item When remote peer's identity is known (by definition for initiator
-and after receiving first packet for responser (however it is not
-authenticated yet)), then collect all @emph{tx}-related files
-information and prepare payload packets with all that @emph{INFO}s.
-@item Pad the very first payload packet (that is sent with first Noise
-handshake message) with @emph{HALT}s to the maximal size.
-@item Send all queued payload packets.
-@item When @emph{INFO} packet received, check that is has an acceptable
-niceness level (skip if not), check if file's @file{.part} exists and
-queue @emph{FREQ} outgoing packet (with corresponding offset if
-required).
+@item Perform @emph{Noise-IK} handshake:
+
+    @table @strong
+    @item Initiator
+    Collects all @emph{tx}-related files information and prepares
+    payload filled with @emph{INFO}s for including in the @strong{first}
+    handshake message.
+    @item Responder
+    After receiving the first handshake message, it gains remote
+    identity knowledge and similarly prepares the payload for including
+    in the @strong{second} handshake message.
+    @end table
+
+    All payloads are padded to maximal message size with @emph{HALT}s.
+
+@item If queued @emph{INFO}s are not sent completely in handshake
+payloads, then send all of remaining in the transport stage.
+
+@item When @emph{INFO} packet received:
+
+    @itemize
+    @item Check that it has an acceptable niceness level.
+    Ignore it if it is too nice.
+    @item If already downloaded file exists, then queue @emph{DONE}
+    sending.
+    @item If @file{.seen} exists, then queue @emph{DONE} sending.
+    @item If @file{.part} exists, then queue @emph{FREQ} sending with
+    corresponding offset.
+    @end itemize
+
 @item When @emph{FREQ} packet received, append it to current sending
 queue. Sending queue contains files with offsets that are needed to be
 sent.
-@item While sending queue is not empty, send @emph{FILE} packet until
-queue's head is not fully sent. @emph{FREQ} can contain offset equal to
-size -- anyway sent @emph{FILE} packet with an empty payload.
-@item When @emph{FILE} packet received, check if it is not fully
-downloaded (comparing to @emph{INFO}'s packet information). If so, then
-run background integrity checker on it. If check is succeeded, then
+
+@item While sending queue is not empty, send @emph{FILE} packets.
+@emph{FREQ} could contain offset equal to size -- anyway sent
+@emph{FILE} packet with an empty payload. @emph{FILE} sending is
+performed only if no other outgoing packets are queued: @emph{INFO}s
+have higher priority.
+
+@item When @emph{FILE} packet received, check if it is completely
+downloaded (comparing to @emph{INFO}'s packet size information). If so,
+then run background integrity checker on it. If check succeeds, then
 delete @file{.part} suffix from file's name and send @emph{DONE} packet.
+
 @item When @emph{DONE} packet received, delete corresponding file.
 @item When @emph{HALT} packet received, empty file sending queue.
-@item @emph{FILE} sending is performed only if no other outgoing packets
-are queued.
+
 @item Each second, node checks: are there any new @emph{tx} packets
 appeared and queues corresponding @emph{INFO} packets.
+
 @item If no packets are sent and received during @ref{CfgOnlineDeadline,
 onlinedeadline} duration, then close the connection. There is no
 explicit indication that session is over.
+
 @end enumerate
diff --git a/doc/sp.txt b/doc/sp.txt
new file mode 100644 (file)
index 0000000..461c95a
--- /dev/null
@@ -0,0 +1,19 @@
+@startuml
+hide footbox
+participant Initiator
+participant Responder
+
+== preparation ==
+
+Initiator <- Responder : [s]
+
+== interactive ==
+
+Initiator -> Responder : [e, es, s, ss], INFO..., HALT...
+Initiator <- Responder : [e, ee, se], INFO..., HALT...
+Initiator -> Responder : INFO..., FREQ..., DONE...
+Initiator <- Responder : INFO..., FREQ..., DONE...
+Initiator -> Responder : FILE..., INFO..., DONE...
+Initiator <- Responder : FILE..., INFO..., DONE...
+
+@enduml
index ba883b7c867a02d464719ce8f76063d8228072aa..3a494907d793f1fc3605500e8924bb63bf639256 100644 (file)
@@ -1,7 +1,7 @@
 # $FreeBSD: head/net/nncp/Makefile 471003 2018-05-27 20:24:00Z krion $
 
 PORTNAME=      nncp
-DISTVERSION=   3.2
+DISTVERSION=   3.3
 CATEGORIES=    net
 MASTER_SITES=  http://www.nncpgo.org/download/
 
index 5bffe28d306f6d37301ede3ff433926f54293ae2..f6b07ce5ad7dac0ac1f6d7ab04f28bab4ae9a5b8 100644 (file)
@@ -763,22 +763,23 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                        state.infosTheir[*info.Hash] = &info
                        state.Unlock()
                        state.ctx.LogD("sp-process", sdsp, "stating part")
-                       if _, err = os.Stat(filepath.Join(
+                       pktPath := filepath.Join(
                                state.ctx.Spool,
                                state.Node.Id.String(),
                                string(TRx),
                                ToBase32(info.Hash[:]),
-                       )); err == nil {
+                       )
+                       if _, err = os.Stat(pktPath); err == nil {
                                state.ctx.LogD("sp-process", sdsp, "already done")
                                replies = append(replies, MarshalSP(SPTypeDone, SPDone{info.Hash}))
                                continue
                        }
-                       fi, err := os.Stat(filepath.Join(
-                               state.ctx.Spool,
-                               state.Node.Id.String(),
-                               string(TRx),
-                               ToBase32(info.Hash[:])+PartSuffix,
-                       ))
+                       if _, err = os.Stat(pktPath + SeenSuffix); err == nil {
+                               state.ctx.LogD("sp-process", sdsp, "already seen")
+                               replies = append(replies, MarshalSP(SPTypeDone, SPDone{info.Hash}))
+                               continue
+                       }
+                       fi, err := os.Stat(pktPath + PartSuffix)
                        var offset int64
                        if err == nil {
                                offset = fi.Size()