unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Bruno Victal <mirai@makinata.eu>
To: 61789@debbugs.gnu.org
Cc: Bruno Victal <mirai@makinata.eu>
Subject: [bug#61789] [PATCH 11/27] services: tor: Deprecate 'tor-hidden-service' procedure.
Date: Sat, 25 Feb 2023 18:57:57 +0000	[thread overview]
Message-ID: <55d9d97eabbb72cf59713b31015e654d028d8623.1677350249.git.mirai@makinata.eu> (raw)
In-Reply-To: <cover.1677350249.git.mirai@makinata.eu>

Due to (now renamed) 'hidden-service' record type not being exported,
the only way hidden services could have worked is through the now deprecated
'tor-hidden-service' procedure which also had the issue that it can only
be used once since the returned service always had the same name.

This commit fixes the Tor service documentation and
deprecates 'tor-hidden-service' procedure, correcting some inconsistencies along the way.

* doc/guix.texi (Networking Services): Add examples for Tor hidden services.
Document <tor-hidden-service-configuration>. Remove mention of 'tor-hidden-service' procedure.
* gnu/services/networking.scm: Export tor-configuration-tor, tor-configuration-config-file,
tor-configuration-hidden-services, tor-configuration-socks-socket-type,
tor-configuration-control-socket-path, tor-hidden-service-configuration,
tor-hidden-service-configuration?, tor-hidden-service-configuration-name,
tor-hidden-service-configuration-mapping.
(<tor-configuration>)[control-socket?]: Rename accessor.
(<hidden-service>): Rename to ...
(<tor-hidden-service-configuration>): ... this.
(tor-configuration->torrc): Update record-type name.
(tor-activation): Ditto.
(tor-service-type): Tweak comment.
(tor-hidden-service-type): Remove variable.
(tor-hidden-service): Deprecate procedure.
---
 doc/guix.texi               | 55 +++++++++++++++++++++++--------------
 gnu/services/networking.scm | 47 +++++++++++++++++--------------
 2 files changed, 61 insertions(+), 41 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index f9ca809e47..eeb2efa488 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20494,11 +20494,21 @@ Networking Services
 
 @cindex Tor
 @defvar tor-service-type
-This is the type for a service that runs the @uref{https://torproject.org,
-Tor} anonymous networking daemon.  The service is configured using a
+Type for a service that runs the @uref{https://torproject.org, Tor}
+anonymous networking daemon.  The service is configured using a
 @code{<tor-configuration>} record.  By default, the Tor daemon runs as the
 @code{tor} unprivileged user, which is a member of the @code{tor} group.
 
+In addition to adding Tor @dfn{hidden service}s records to the service
+configuration directly, this service can be extended by other services to add
+hidden services, as in this example:
+
+@lisp
+(simple-service 'my-extra-hidden-service tor-service-type
+                (list (tor-hidden-service-configuration
+                        (name "extra-hidden-service")
+                        (mapping '((80 "127.0.0.1:8080"))))))
+@end lisp
 @end defvar
 
 @deftp {Data Type} tor-configuration
@@ -20517,11 +20527,10 @@ Networking Services
 syntax.
 
 @item @code{hidden-services} (default: @code{'()})
-The list of @code{<hidden-service>} records to use.  For any hidden service
-you include in this list, appropriate configuration to enable the hidden
-service will be automatically added to the default configuration file.  You
-may conveniently create @code{<hidden-service>} records using the
-@code{tor-hidden-service} procedure described below.
+The list of @code{<tor-hidden-service-configuration>} records to use.
+For any hidden service you include in this list, appropriate
+configuration to enable the hidden service will be automatically added to
+the default configuration file.
 
 @item @code{socks-socket-type} (default: @code{'tcp})
 The default socket type that Tor should use for its SOCKS socket.  This must
@@ -20546,26 +20555,32 @@ Networking Services
 @end table
 @end deftp
 
-@cindex hidden service
-@deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
-Define a new Tor @dfn{hidden service} called @var{name} and implementing
-@var{mapping}.  @var{mapping} is a list of port/host tuples, such as:
+@cindex hidden service, tor
+@deftp {Data Type} tor-hidden-service-configuration
+Data Type representing a Tor @dfn{hidden service} configuration.
+See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
+project's documentation} for more information.
+
+@table @asis
+@item @code{name} (type: string)
+Name for the Tor @dfn{hidden service}.
+This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory,
+where the @file{hostname} file contains the @samp{.onion} host name for
+the hidden service.
+
+@item @code{mapping} (type: list-of-list)
+List of host---@dfn{hidden-service} port mappings, such as:
 
 @example
- '((22 "127.0.0.1:22")
-   (80 "127.0.0.1:8080"))
+'((22 "127.0.0.1:22")
+  (80 "127.0.0.1:8080"))
 @end example
 
 In this example, port 22 of the hidden service is mapped to local port 22, and
 port 80 is mapped to local port 8080.
 
-This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
-the @file{hostname} file contains the @code{.onion} host name for the hidden
-service.
-
-See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
-project's documentation} for more information.
-@end deffn
+@end table
+@end deftp
 
 The @code{(gnu services rsync)} module provides the following services:
 
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index dacf64c2d1..d6e1877ef5 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -138,7 +138,16 @@ (define-module (gnu services networking)
 
             tor-configuration
             tor-configuration?
-            tor-hidden-service
+            tor-configuration-tor
+            tor-configuration-config-file
+            tor-configuration-hidden-services
+            tor-configuration-socks-socket-type
+            tor-configuration-control-socket-path
+            tor-hidden-service-configuration
+            tor-hidden-service-configuration?
+            tor-hidden-service-configuration-name
+            tor-hidden-service-configuration-mapping
+            tor-hidden-service  ; deprecated
             tor-service-type
 
             network-manager-configuration
@@ -919,7 +928,7 @@ (define-record-type* <tor-configuration>
                     (default '()))
   (socks-socket-type tor-configuration-socks-socket-type ; 'tcp or 'unix
                      (default 'tcp))
-  (control-socket?  tor-control-socket-path
+  (control-socket?  tor-configuration-control-socket-path
                     (default #f)))
 
 (define %tor-accounts
@@ -933,11 +942,11 @@ (define %tor-accounts
          (home-directory "/var/empty")
          (shell (file-append shadow "/sbin/nologin")))))
 
-(define-record-type <hidden-service>
-  (hidden-service name mapping)
-  hidden-service?
-  (name    hidden-service-name)                   ;string
-  (mapping hidden-service-mapping))               ;list of port/address tuples
+(define-record-type <tor-hidden-service-configuration>
+  (tor-hidden-service-configuration name mapping)
+  tor-hidden-service-configuration?
+  (name    tor-hidden-service-configuration-name)      ;string
+  (mapping tor-hidden-service-configuration-mapping))  ;list of port/address tuples
 
 (define (tor-configuration->torrc config)
   "Return a 'torrc' file for CONFIG."
@@ -977,7 +986,7 @@ (define (tor-configuration->torrc config)
                                                 tcp-port host))
                                       ports hosts)))
                          '#$(map (match-lambda
-                                   (($ <hidden-service> name mapping)
+                                   (($ <tor-hidden-service-configuration> name mapping)
                                     (cons name mapping)))
                                  hidden-services))
 
@@ -1064,7 +1073,7 @@ (define (tor-activation config)
       (chmod "/var/lib" #o755)
 
       (for-each initialize
-                '#$(map hidden-service-name
+                '#$(map tor-hidden-service-configuration-name
                         (tor-configuration-hidden-services config)))))
 
 (define tor-service-type
@@ -1077,7 +1086,7 @@ (define tor-service-type
                        (service-extension activation-service-type
                                           tor-activation)))
 
-                ;; This can be extended with hidden services.
+                ;; This can be extended with tor hidden services.
                 (compose concatenate)
                 (extend (lambda (config services)
                           (tor-configuration
@@ -1090,15 +1099,8 @@ (define tor-service-type
                  "Run the @uref{https://torproject.org, Tor} anonymous
 networking daemon.")))
 
-(define tor-hidden-service-type
-  ;; A type that extends Tor with hidden services.
-  (service-type (name 'tor-hidden-service)
-                (extensions
-                 (list (service-extension tor-service-type list)))
-                (description
-                 "Define a new Tor @dfn{hidden service}.")))
-
-(define (tor-hidden-service name mapping)
+(define-deprecated (tor-hidden-service name mapping)
+  #f
   "Define a new Tor @dfn{hidden service} called @var{name} and implementing
 @var{mapping}.  @var{mapping} is a list of port/host tuples, such as:
 
@@ -1116,8 +1118,11 @@ (define (tor-hidden-service name mapping)
 
 See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
 project's documentation} for more information."
-  (service tor-hidden-service-type
-           (hidden-service name mapping)))
+  (simple-service 'tor-hidden-service
+                  tor-service-type
+                  (list (tor-hidden-service-configuration
+                         (name name)
+                         (mapping mapping)))))
 
 \f
 ;;;
-- 
2.39.1





  parent reply	other threads:[~2023-02-25 18:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-25 18:53 [bug#61789] [PATCH 00/27] Deprecate old-style services Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 01/27] services: base: Deprecate 'host-name-service' procedure Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 02/27] services: base: Deprecate 'login-service' procedure Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 03/27] services: base: Deprecate 'mingetty-service' procedure Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 04/27] services: base: Deprecate 'agetty-service' procedure Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 05/27] doc: kmscon-service-type: Use @defvar @-command Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 06/27] services: base: Deprecate 'nscd-service' procedure Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 07/27] services: base: Deprecate 'syslog-service' procedure Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 08/27] services: base: Deprecate 'udev-service' procedure Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 09/27] services: base: Deprecate 'rngd-service' procedure Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 10/27] services: base: Deprecate 'pam-limits-service' procedure Bruno Victal
2023-03-03 16:40   ` [bug#61789] [PATCH 00/27] Deprecate old-style services Ludovic Courtès
2023-02-25 18:57 ` Bruno Victal [this message]
2023-03-03 16:43   ` [bug#61789] ‘tor-hidden-service’ deprecation Ludovic Courtès
2023-03-05 17:51     ` Bruno Victal
2023-03-06 16:05       ` Ludovic Courtès
2023-02-25 18:57 ` [bug#61789] [PATCH 12/27] services: ssh: Deprecate 'lsh-service' procedure Bruno Victal
2023-02-25 18:57 ` [bug#61789] [PATCH 13/27] services: ssh: Deprecate 'dropbear-service' procedure Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 14/27] services: xorg: Deprecate 'screen-locker-service' procedure Bruno Victal
2023-03-03 16:45   ` [bug#61789] ‘screen-locker-service’ deprecation Ludovic Courtès
2023-03-06 14:36     ` Bruno Victal
2023-03-06 22:32       ` Ludovic Courtès
2023-02-25 18:58 ` [bug#61789] [PATCH 15/27] services: desktop: Deprecate 'elogind-service' procedure Bruno Victal
2023-03-03 16:48   ` [bug#61789] ‘elogind-configuration’ documentation needs love Ludovic Courtès
2023-02-25 18:58 ` [bug#61789] [PATCH 16/27] services: elogind-configuration: Do not ignore 'handle-hibernate-key' by default Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 17/27] services: desktop: Deprecate 'accountsservice-service' procedure Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 18/27] services: dbus: Deprecate 'polkit-service' procedure Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 19/27] services: desktop: Deprecate 'udisks-service' procedure Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 20/27] services: desktop: Deprecate 'geoclue-service' procedure Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 21/27] services: desktop: Deprecate 'bluetooth-service' procedure Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 22/27] services: mail: Deprecate 'dovecot-service' procedure Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 23/27] services: vpn: Deprecate 'openvpn-client-service' & 'openvpn-server-service' procedures Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 24/27] services: lirc: Deprecate 'lirc-service' procedure Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 25/27] services: spice: Deprecate 'spice-vdagent-service' procedure Bruno Victal
2023-02-25 18:58 ` [bug#61789] [PATCH 26/27] services: dict: Deprecate 'dicod-service' procedure Bruno Victal
2023-03-03 16:52   ` [bug#61789] ‘dicod-service’ deprecation Ludovic Courtès
2023-02-25 18:58 ` [bug#61789] [PATCH 27/27] services: dbus: Deprecate 'dbus-service' procedure Bruno Victal
2023-03-03 17:09 ` [bug#61789] [PATCH 00/27] Deprecate old-style services Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55d9d97eabbb72cf59713b31015e654d028d8623.1677350249.git.mirai@makinata.eu \
    --to=mirai@makinata.eu \
    --cc=61789@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).