gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-scheme] branch master updated (c0c1dff -> 446af15)


From: gnunet
Subject: [gnunet-scheme] branch master updated (c0c1dff -> 446af15)
Date: Wed, 21 Sep 2022 16:57:14 +0200

This is an automated email from the git hooks/post-receive script.

maxime-devos pushed a change to branch master
in repository gnunet-scheme.

    from c0c1dff  tests/distributed-hash-table: Skip a to-be-investigated 
hanging test.
     new 204f416  fs/client: New client code.
     new c764746  Move file-sharing modules into gnu/gnunet/fs.
     new d451a30  Makefile.am: Compile and install (gnu gnunet fs uri).
     new 800edba  hashcode: Drop exception.
     new 5dcbb76  bv-slice: Implement slice-copy/bytevector.
     new efbc801  examples/web: Remove unused procedure 'slice-copy'.
     new b339184  Merge branches 'fs' (early part) and 'bytevector-slices'
     new 78297ac  fs/struct: New module.
     new 446af15  fs: Clarify the requesting / responding of a LOC signature.

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Makefile.am                           |  5 +++
 doc/bytevector-slices.tm              | 21 +++++++++++
 examples/web.scm                      |  5 ---
 gnu/gnunet/fs/client.scm              | 68 +++++++++++++++++++++++++++++++++++
 gnu/gnunet/{ => fs}/directory.scm     |  4 +--
 gnu/gnunet/fs/struct.scm              | 59 ++++++++++++++++++++++++++++++
 gnu/gnunet/{fs-uri.scm => fs/uri.scm} |  2 +-
 gnu/gnunet/hashcode.scm               |  5 ---
 gnu/gnunet/message/enum-fs.scmfrag    |  6 ++--
 gnu/gnunet/utils/bv-slice.scm         |  6 ++++
 tests/bv-slice.scm                    | 12 +++++++
 tests/file-sharing.scm                | 34 ++++++++++++++++++
 12 files changed, 211 insertions(+), 16 deletions(-)
 create mode 100644 gnu/gnunet/fs/client.scm
 rename gnu/gnunet/{ => fs}/directory.scm (98%)
 create mode 100644 gnu/gnunet/fs/struct.scm
 rename gnu/gnunet/{fs-uri.scm => fs/uri.scm} (99%)
 create mode 100644 tests/file-sharing.scm

diff --git a/Makefile.am b/Makefile.am
index 0ddd706..dc4badb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -86,6 +86,10 @@ modules = \
   gnu/gnunet/dht/network.scm \
   gnu/gnunet/dht/struct.scm \
   \
+  gnu/gnunet/fs/client.scm \
+  gnu/gnunet/fs/struct.scm \
+  gnu/gnunet/fs/uri.scm \
+  \
   gnu/gnunet/util/cmsg.scm \
   gnu/gnunet/util/time.scm \
   gnu/gnunet/icmp/struct.scm \
@@ -206,6 +210,7 @@ SCM_TESTS = \
   tests/cadet.scm \
   tests/crypto.scm \
   tests/distributed-hash-table.scm \
+  tests/file-sharing.scm \
   tests/form.scm \
   tests/lost-and-found.scm \
   tests/netstruct.scm \
diff --git a/doc/bytevector-slices.tm b/doc/bytevector-slices.tm
index e12f4ff..ca001bc 100644
--- a/doc/bytevector-slices.tm
+++ b/doc/bytevector-slices.tm
@@ -93,6 +93,27 @@
   </explain|Make a fresh, zero-initialised, read-write slice, of length
   <var|length>.>
 
+  <\explain>
+    <scm|(slice-copy/read-write <var|original>)><index|slice-copy/read-write>
+
+    <scm|(slice-copy/read-only <var|original>)><index|slice-copy/read-only>
+
+    <scm|(slice-copy/bytevector <var|original>)><index|slice-copy/bytevector>
+  <|explain>
+    <scm|slice-copy/read-write> makes a fresh read-write slice with the same
+    contents as <var|original>. It requires <var|original> to be readable \U
+    if not, a <scm|&missing-capabilities> exception is raised, with the
+    \<#2018\>what\<#2019\> field set to the symbol <scm|original>.
+
+    <scm|slice-copy/read-only> behaves the same as
+    <scm|slice-copy/read-write>, except for returning a read-only slice
+    instead of a read-write slice.
+
+    <scm|slice-copy/bytevector> behave the same as
+    <scm|slice-copy/read-write>, except for returning a bytevector instead of
+    a read-write slice.
+  </explain>
+
   <section|Predicates>
 
   <\explain>
diff --git a/examples/web.scm b/examples/web.scm
index 14811f9..823ad75 100644
--- a/examples/web.scm
+++ b/examples/web.scm
@@ -275,11 +275,6 @@ merely a race?")))
 
 (define-once started? #f)
 
-(define (slice-copy slice) ; TODO: move to (gnu gnunet utils bv-slice), use 
elsewhere?
-  (define s (make-slice/read-write (slice-length slice)))
-  (slice-copy! slice s)
-  s)
-
 (define (url-handler dht-server nse-server cadet-server request body)
   (match (uri-path (request-uri request))
     ("/" (respond/html
diff --git a/gnu/gnunet/fs/client.scm b/gnu/gnunet/fs/client.scm
new file mode 100644
index 0000000..33f6aea
--- /dev/null
+++ b/gnu/gnunet/fs/client.scm
@@ -0,0 +1,68 @@
+;#!r6rs
+;; This file is part of Scheme-GNUnet
+;; Copyright © 2022 GNUnet e.V.
+;;
+;; Scheme-GNUnet is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU Affero General Public License as published
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+;;
+;; Scheme-GNUnet is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Affero General Public License for more details.
+;;
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;; SPDX-License-Identifier: AGPL-3.0-or-later
+
+;; Author: Maxime Devos
+
+;; TODO: maybe rename to (gnu gnunet file-sharing client),
+;; and likewise for the other services?
+(define-library (gnu gnunet fs client)
+  (export (rename (server:fs? server?))
+         connect disconnect!)
+  (import (only (rnrs base) begin lambda define apply quote)
+         (only (rnrs records syntactic) define-record-type)
+         (only (guile) define*)
+         (only (ice-9 match) match)
+         (only (gnu gnunet mq handler) message-handlers)
+         (only (gnu gnunet server) <server> make-disconnect!
+               spawn-server-loop run-loop loop:terminal-condition
+               handle-control-message!)
+         (only (srfi srfi-26) cut))
+  (begin
+    (define-record-type (<server:fs> make-server:fs server:fs?)
+      (parent <server>)
+      (protocol (lambda (%make) (lambda () ((%make))))))
+
+    (define (make-message-handlers . _)
+      (message-handlers)) ; TODO
+
+    (define (control-message-handler message continue continue* message-queue
+                                    loop)
+      (define (k/reconnect!)
+       (run-loop loop))
+      (match message
+        (('resend-old-operations!) ; TODO no operations implemented yet
+        (continue loop))
+        (('lost . _)
+        ;; Server became unreachable, disconnect.  Tested by the
+        ;; "garbage collectable" test.
+        (continue* '(disconnect!) loop))
+        (rest (handle-control-message! message message-queue
+                                      (loop:terminal-condition loop)
+                                      (cut run-loop loop)))))
+
+    (define* (connect config #:key connected disconnected spawn #:rest r)
+      "Connect to the file-sharing service in the background.  This is an
+instance of the @code{connect} procedure of the @emph{server object} pattern."
+      (apply spawn-server-loop (make-server:fs)
+            #:make-message-handlers make-message-handlers
+            #:control-message-handler control-message-handler
+            #:configuration config
+            #:service-name "fs" r))
+
+    (define disconnect! (make-disconnect! 'fs server:fs?))))
diff --git a/gnu/gnunet/directory.scm b/gnu/gnunet/fs/directory.scm
similarity index 98%
rename from gnu/gnunet/directory.scm
rename to gnu/gnunet/fs/directory.scm
index 470c7a8..158aa28 100644
--- a/gnu/gnunet/directory.scm
+++ b/gnu/gnunet/fs/directory.scm
@@ -46,7 +46,7 @@
 ;;  * URI's are represented by strings (note: GNUnet FS URI's are
 ;;    always ASCII).
 
-(library (gnu gnunet directory)
+(library (gnu gnunet fs directory)
   (export meta-data-mark-directory
          make-directory-entry directory-entry?
          directory-entry-uri directory-entry-meta
@@ -57,7 +57,7 @@
          (rnrs bytevectors)
          (only (guile) floor/ 1+)
          (ice-9 receive)
-          (only (gnu gnunet fs-uri) chk-uri-file-length chk-uri-parse)
+          (only (gnu gnunet fs uri) chk-uri-file-length chk-uri-parse)
           (only (srfi srfi-43) vector-unfold)
          (only (gnu gnunet metadata) meta-data-extend)
          (prefix (only (gnu extractor metatypes)
diff --git a/gnu/gnunet/fs/struct.scm b/gnu/gnunet/fs/struct.scm
new file mode 100644
index 0000000..788383f
--- /dev/null
+++ b/gnu/gnunet/fs/struct.scm
@@ -0,0 +1,59 @@
+;; This file is part of Scheme-GNUnet.
+;; Copyright © 2003--2012 GNUnet e.V.
+;;
+;; Scheme-GNUnet is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU Affero General Public License as published
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+;;
+;; Scheme-GNUnet is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Affero General Public License for more details.
+;;
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;; SPDX-License-Identifier: AGPL-3.0-or-later
+
+;; C source file: fs/fs.h
+;; Network-related definitions for file-sharing
+;; Author: Igor Wronsky, Christian Grothoff
+;; Ported to Scheme-GNUnet by: Maxime Devos
+(define-library (gnu gnunet fs struct)
+  (export /:msg:fs:loc-sign)
+  (import (only (rnrs base) define begin * quote)
+         (only (gnu gnunet hashcode struct)
+               /hashcode:512)
+         (only (gnu gnunet util struct)
+               /:message-header /time-absolute)
+         (only (gnu gnunet netstruct procedural)
+               u32/big u64/big make-netprimitive)
+         (only (gnu gnunet netstruct syntactic)
+               define-type structure/packed))
+  (begin
+    ;; TODO: interaction with <content-hash-key>
+    (define-type /content-hash-key
+      (structure/packed
+       (synopsis "Content hash key")
+       (properties '((c-type . ContentHashKey)))
+       (field (key /hashcode:512)
+             (synopsis "Hash of the original content, used for encryption"))
+       (field (query /hashcode:512)
+             (synopsis "Hash of the encrypted content, used for querying"))))
+
+    (define-type /:msg:fs:request-loc-sign
+      (structure/packed
+       (synopsis "Message sent by a FS client to request a LOC signature.")
+       (properties '((message-symbol msg:fs:request-loc-signature)
+                    (c-type . RequestLocSignatureMessage)))
+       (field (header /:message-header))
+       (field (purpose u32/big)
+             (synopsis "Requested signature purpose")
+             (documentation "For now, always 
GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT"))
+       (field (expiration-time /time-absolute)
+             (synopsis "Requested expiration time"))
+       (field (content-hash-key /content-hash-key)
+             (synopsis "Information about the shared file (to be signed"))
+       (field (file-length u64/big)
+             (synopsis "Size of the shared file (to be signed)"))))))
diff --git a/gnu/gnunet/fs-uri.scm b/gnu/gnunet/fs/uri.scm
similarity index 99%
rename from gnu/gnunet/fs-uri.scm
rename to gnu/gnunet/fs/uri.scm
index 685c493..d2255d5 100644
--- a/gnu/gnunet/fs-uri.scm
+++ b/gnu/gnunet/fs/uri.scm
@@ -83,7 +83,7 @@
 ;; The encoding for hexadecimal values is defined in the hashing.c
 ;; module in the gnunetutil library and discussed there.
 
-(library (gnu gnunet fs-uri (1 1))
+(library (gnu gnunet fs uri (1 1))
   (export chk? make-chk chk-key chk-query
           chk-uri? make-chk-uri chk-uri-file-length chk-uri-chk
          chk-uri-parse)
diff --git a/gnu/gnunet/hashcode.scm b/gnu/gnunet/hashcode.scm
index ff36dfa..8ef9a06 100644
--- a/gnu/gnunet/hashcode.scm
+++ b/gnu/gnunet/hashcode.scm
@@ -16,11 +16,6 @@
 ;;   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ;;
 ;;   SPDX-License-Identifier: AGPL-3.0-or-later
-;;
-;;   As a special exception to the GNU Affero General Public License,
-;;   the file may be relicensed under any license used for
-;;   most source code of GNUnet 0.13.1, or later versions, as published by
-;;   GNUnet e.V.
 
 ;; Extracted from src/include/gnunet_common.h
 
diff --git a/gnu/gnunet/message/enum-fs.scmfrag 
b/gnu/gnunet/message/enum-fs.scmfrag
index 9f240eb..4d6e6c4 100644
--- a/gnu/gnunet/message/enum-fs.scmfrag
+++ b/gnu/gnunet/message/enum-fs.scmfrag
@@ -1,13 +1,13 @@
-;; -*- scheme -*- Copyright © 2001--2021 GNUnet e.V.
+;; -*- scheme -*- Copyright © 2001--2022 GNUnet e.V.
 ;; SPDX-License-Identifier: AGPL-3.0-or-later
 ;; * FS message types
 
 (value
- (symbol msg:fs:loc-sign)
+ (symbol msg:fs:request-loc-signature)
  (index 126)
  (documentation "Message sent by fs client to request LOC signature."))
 (value
- (symbol msg:fs:request-loc-signature)
+ (symbol msg:fs:response-loc-signature)
  (index 127)
  (documentation "Reply sent by fs service with LOC signature."))
 (value
diff --git a/gnu/gnunet/utils/bv-slice.scm b/gnu/gnunet/utils/bv-slice.scm
index 8676c52..72ab94d 100644
--- a/gnu/gnunet/utils/bv-slice.scm
+++ b/gnu/gnunet/utils/bv-slice.scm
@@ -60,6 +60,7 @@
          ;; Large operations
          slice-copy!
          slice-zero!
+         slice-copy/bytevector
          slice-copy/read-write
          slice-copy/read-only
 
@@ -356,6 +357,11 @@ Future modifications to @var{original} will not impact the 
returned slice.
 THe slice @var{originall} must be readable."
     (slice/read-only (slice-copy/read-write original)))
 
+  (define (slice-copy/bytevector original)
+    "Return a fresh bytevector with the same contents as the bytevector slice
+@var{original}.  The slice @var{original} must be readable."
+    (slice-bv (slice-copy/read-write original)))
+
   (define (slice-independent? x y)
     "Return @code{#true} if all changes to the bytes in @var{x} do not
 impact @var{y}, @code{#false} otherwise.  This is a symmetric relation.
diff --git a/tests/bv-slice.scm b/tests/bv-slice.scm
index 2deaefc..043f6af 100644
--- a/tests/bv-slice.scm
+++ b/tests/bv-slice.scm
@@ -223,6 +223,11 @@
     (slice-copy! copy (bv-slice/read-write bv))
     bv))
 
+(test-assert "return value of slice-copy/bytevector independent of original"
+  (let* ((original (make-slice/read-write 9))
+        (copy (slice-copy/bytevector original)))
+    (slice-independent? original (bv-slice/read-write copy))))
+
 (test-missing-caps
  "source of slice-copy/read-only must be readable"
  'original
@@ -230,6 +235,13 @@
  CAP_READ
  (slice-copy/read-only (slice/write-only (make-slice/read-write 9))))
 
+(test-missing-caps
+ "source of slice-copy/bytevector must be readable"
+ 'original
+ CAP_WRITE
+ CAP_READ
+ (slice-copy/bytevector (slice/write-only (make-slice/read-write 9))))
+
 (test-missing-caps
  "even if the size is zero"
  'original
diff --git a/tests/file-sharing.scm b/tests/file-sharing.scm
new file mode 100644
index 0000000..986db6c
--- /dev/null
+++ b/tests/file-sharing.scm
@@ -0,0 +1,34 @@
+;; This file is part of scheme-GNUnet, a partial Scheme port of GNUnet.
+;; Copyright © 2022 GNUnet e.V.
+;;
+;; scheme-GNUnet is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU Affero General Public License as published
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+;;
+;; scheme-GNUnet is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Affero General Public License for more details.
+;;
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;; SPDX-License-Identifier: AGPL-3.0-or-later
+(define-module (test-file-sharing))
+(import (gnu gnunet fs client)
+       (srfi srfi-64)
+       (tests utils))
+
+(test-begin "file-sharing")
+
+;; Standard tests
+(test-assert "close, not connected --> all fibers stop, no callbacks called"
+  (close-not-connected-no-callbacks "fs" (pk connect) disconnect!))
+(test-assert "garbage collectable"
+  (garbage-collectable "fs" connect))
+(test-assert "notify disconnected after end-of-file, after 'connected'"
+  (disconnect-after-eof-after-connected "fs" connect))
+(test-assert "reconnects"
+  (reconnects "fs" connect))
+(test-end "file-sharing")

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]