From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id SG1YKX3ej2aJRAAAqHPOHw:P1 (envelope-from ) for ; Thu, 11 Jul 2024 13:30:37 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id SG1YKX3ej2aJRAAAqHPOHw (envelope-from ) for ; Thu, 11 Jul 2024 15:30:37 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=Gq9pndhz; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1720704637; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=LxDKX6wD4Yge+LiW0LsacQAvCFwfYLzU/zDqNXPFwC0=; b=fUlIF0xcnwVS+eV+8kTsZbKCD41eCYWsfDRgBneWJyhaIW3DCATt4SkCqaNy703iewgf6k EQFMbRsmXTNbqBv4pJP7iamkJl1aLqRlu/YZNE4aXmUgbHi/Flwr2f/QP+uoMvaLDbgq8m WZ2Nx0jNa8qDqn3l7ku6nzKzfkICCTb4doHsJ8empXs8MWiflYcSOPrZvyVymNQ/Lr1HRu 9E2esL4abp0EVCUZptRVh2i1F4rJXdGPeW3IFRdbRGALq3fsW56m3H+aF3qwkRCWH1t9z9 ovAZY70U25KJptsCl63ibLYzumpQMKpJ3muzU+AVUVQVly9y7hxez8awyciRBw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1720704637; a=rsa-sha256; cv=none; b=ps2ZBfSAOmrh2hssjdRf10J9GaZ5G2IjaORk9+wjliULxXdQ7sMVWH4MchgElY6k+S2EGU wjUco3JoRWPCkdG3GIh3sELtxZV+dhkWgeCVbMIgzzcojUi3dU29JWqgpMGF3FWcw8uGSH r4EYRieXiNMASbkNsZITUTx+1/rX/QOLOhjf95Wzl6PeyFzPFA/puxbQAyLAqJh5zUM1P5 nsTs9NUVBQM4nZ3BlEbqfe2JaOFP6ydHs0A/V2zt576pmDviOyHXDi3QVjqmpAE5Nips1i TX/gxxtvyfGai4DnTdc4L5oc7gOGgLah5pq5cCeAXnPwSb3r/A0es0sJ9VyDXg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=Gq9pndhz; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7B94164F9C for ; Thu, 11 Jul 2024 15:30:37 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRtsR-0003yn-K5; Thu, 11 Jul 2024 09:30:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRts5-000317-Jt for guix-patches@gnu.org; Thu, 11 Jul 2024 09:30:09 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRts3-0002Th-IH; Thu, 11 Jul 2024 09:30:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sRts2-0004SO-TN; Thu, 11 Jul 2024 09:30:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70341] [PATCH v6] services: tor: Add support for pluggable transports. References: <11e72216f4be8b6559ecc04646fd722daa5dd09d.1712846897.git.nigko.yerden@gmail.com> In-Reply-To: <11e72216f4be8b6559ecc04646fd722daa5dd09d.1712846897.git.nigko.yerden@gmail.com> Resent-From: Nigko Yerden Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Thu, 11 Jul 2024 13:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70341 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70341@debbugs.gnu.org Cc: Nigko Yerden , Florian Pelz , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 70341-submit@debbugs.gnu.org id=B70341.172070459317095 (code B ref 70341); Thu, 11 Jul 2024 13:30:02 +0000 Received: (at 70341) by debbugs.gnu.org; 11 Jul 2024 13:29:53 +0000 Received: from localhost ([127.0.0.1]:51279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sRtrs-0004Re-GH for submit@debbugs.gnu.org; Thu, 11 Jul 2024 09:29:53 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:43089) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sRtro-0004RO-Dp for 70341@debbugs.gnu.org; Thu, 11 Jul 2024 09:29:51 -0400 Received: by mail-lf1-f66.google.com with SMTP id 2adb3069b0e04-52e9a550e9fso1947759e87.0 for <70341@debbugs.gnu.org>; Thu, 11 Jul 2024 06:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720704527; x=1721309327; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LxDKX6wD4Yge+LiW0LsacQAvCFwfYLzU/zDqNXPFwC0=; b=Gq9pndhzj22SuV8DA4Gh72tLGXatjnspiS2NW/+WSRKLFwvL5pifeDw5/1avsi97Kz eE+r9D0AclY1l6dM7yRIjbIFrAiU7t9Zd48jqBh5Oibybjc6yyeH6wQeqKcAKdEikpnw BKYDTK/RJv3qOnYh0bSBSjLZ0iax0C8FEVXfAVqcIFcoAXCWME3iLIDiuFA11ZVbFkm1 dfWu1K4nx0g9moOM7ThLcTtqlxuC4GYk/OFVfUOMnUVPtbWywYl9riuqTKg49G8DvTcL xEIUhNJR2fC/8/5Uqfv8XyzVKyA/Ns4OHj/OWEapX1OwhhozWVNEqbA4ePxAConbmHRz vGHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720704527; x=1721309327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LxDKX6wD4Yge+LiW0LsacQAvCFwfYLzU/zDqNXPFwC0=; b=NMbET7jIGxX+f0FJxq3WNLO/00Y2XcEURlh4RTuEI6OLd+6vnA+fue21G+ThIm8dCw lWe0cME34koN1s3S8fDb37H5JgJ60QjQiPUXsC563KKI2bEvUFmNAPuazEHiq9a/IGoJ m624StvttPp9DpIrwBaIUfKpgZHJd9Sn022IlGCB6RcXOqnCRZXxauCDD3PHJb+PLw31 cC4W9xyF9WWZ0VfZet0H0ydSBiYEtK02RatsOWXY2ob1SQUU7YBQEy9cWzmDYYxaayQC bseyyAVMqIg+3rKvAne90vrCewNy/HAR749n5MhkRJBKT+l9sq+zbAsy2RZR8v8M5FFl aTbg== X-Gm-Message-State: AOJu0YzlsZErt5tq6QNZoh/159nvrnywxr2icPgI4ph9suUGM7lBttIF U17IVWO51d9jW1B4mmbHPp6kxgYiImQnID5Cctvm9KguatMh0B3wmCC/Mf/w X-Google-Smtp-Source: AGHT+IETO0nPaYCrx0D4MfqkVK4AUhhKgdh58QuYhs3w268JZilZfy9ulMum6/kMdeMXR6s50AYeuw== X-Received: by 2002:a05:6512:32c2:b0:52b:bee8:e987 with SMTP id 2adb3069b0e04-52ec6e66494mr722570e87.3.1720704526574; Thu, 11 Jul 2024 06:28:46 -0700 (PDT) Received: from localhost.localdomain ([188.68.138.53]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52eb906e75dsm981911e87.270.2024.07.11.06.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 06:28:46 -0700 (PDT) From: Nigko Yerden Date: Thu, 11 Jul 2024 18:27:32 +0500 Message-ID: <11bf71bb5d31417eb7586e34e3e5e8b52eebf659.1720704452.git.nigko.yerden@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -0.30 X-Spam-Score: -0.30 X-Migadu-Queue-Id: 7B94164F9C X-Migadu-Scanner: mx11.migadu.com X-TUID: G49C9tRuvBSA Pluggable transports are programs that disguise Tor traffic, which can be useful in case Tor is censored. Pluggable transports cannot be configured by #:config-file file exclusively because Tor process is run via 'least-authority-wrapper' and cannot have access to transport plugin, which is a separate executable (Bug#70302, Bug#70332). Example configuration snippet to be appended to operation-system services (see https://bridges.torproject.org/ to get full bridge's lines): (service tor-service-type (tor-configuration (config-file (plain-file "torrc" "\ UseBridges 1 Bridge obfs4 ... Bridge obfs4 ...")) (transport-plugins (list (tor-transport-plugin (path-to-binary (file-append go-gitlab-torproject-org-tpo-anti-censorship-pluggable-transports-lyrebird "/bin/lyrebird"))))))) * doc/guix.texi (Networking Services): Document 'tor-transport-plugin' data type and 'transport-plugins' option for 'tor-configuration. * gnu/services/networking.scm: Export 'tor-configuration-transport-plugins', 'tor-transport-plugin', 'tor-transport-plugin?', 'tor-transport-plugin-role', 'tor-transport-plugin-protocol', and 'tor-transport-plugin-path'. (): Add 'transport-plugins' field. (): New variable. (tor-configuration->torrc): Add content to 'torrc' computed-file. (tor-shepherd-service): Add file-system-mapping(s). Change-Id: I1b0319358778c7aee650bc843e021a6803a1cf3a --- Just rebasing. doc/guix.texi | 47 +++++++++++++++++++++++++ gnu/services/networking.scm | 69 ++++++++++++++++++++++++++++++------- 2 files changed, 103 insertions(+), 13 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5b77c84b4a..ccaab5985c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -22006,6 +22006,13 @@ Networking Services @file{/var/run/tor/control-sock}, which will be made writable by members of the @code{tor} group. +@item @code{transport-plugins} (default: @code{'()}) +The list of @code{} records to use. +For any transport plugin you include in this list, appropriate +configuration line to enable transport plugin will be automatically +added to the default configuration file. + + @end table @end deftp @@ -22034,6 +22041,46 @@ Networking Services @end table @end deftp +@cindex pluggable transports, tor +@deftp {Data Type} tor-transport-plugin +Data type representing a Tor pluggable transport plugin in +@code{tor-configuration}. Plugguble transports are programs +that disguise Tor traffic, which can be useful in case Tor is +censored. See the the Tor project's +@url{https://tb-manual.torproject.org/circumvention/, +documentation} and +@url{https://spec.torproject.org/pt-spec/index.html, +specification} for more information. + +Each transport plugin corresponds either to +``ClientTransportPlugin ...'' or to +``ServerTransportPlugin ...'' line in the default +configuration file, see the @code{man tor}. +Available @code{tor-transport-plugin} fields are: + +@table @asis +@item @code{role} (default: @code{'client}) +This must be either @code{'client} or @code{'server}. Otherwise, +an error is raised. Set the @code{'server} value if you want to +run a bridge to help censored users connect to the Tor network, see +@url{https://community.torproject.org/relay/setup/bridge/, +the Tor project's brige guide}. Set the @code{'client} value +if you want to connect to somebody else's bridge, see +@url{https://bridges.torproject.org/, the Tor project's +``Get Bridges'' page}. In both cases the required +additional configuration should be provided via +@code{#:config-file} option of @code{tor-configuration}. +@item @code{protocol} (default: @code{"obfs4"}) +A string that specifies a pluggable transport protocol. +@item @code{path-to-binary} +This must be a ``file-like'' object or a string +pointing to the pluggable transport plugin executable. +This option allows the Tor daemon run inside the container +to access the executable and all the references +(e.g. package dependencies) attached to it. +@end table +@end deftp + The @code{(gnu services rsync)} module provides the following services: You might want an rsync daemon if you have files that you want available diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 12d8934e43..4b1b164845 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -160,10 +160,16 @@ (define-module (gnu services networking) tor-configuration-hidden-services tor-configuration-socks-socket-type tor-configuration-control-socket-path + tor-configuration-transport-plugins tor-onion-service-configuration tor-onion-service-configuration? tor-onion-service-configuration-name tor-onion-service-configuration-mapping + tor-transport-plugin + tor-transport-plugin? + tor-transport-plugin-role + tor-transport-plugin-protocol + tor-transport-plugin-path tor-hidden-service ; deprecated tor-service-type @@ -966,7 +972,9 @@ (define-record-type* (socks-socket-type tor-configuration-socks-socket-type ; 'tcp or 'unix (default 'tcp)) (control-socket? tor-configuration-control-socket-path - (default #f))) + (default #f)) + (transport-plugins tor-configuration-transport-plugins + (default '()))) (define %tor-accounts ;; User account and groups for Tor. @@ -996,10 +1004,24 @@ (define-configuration/no-serialization tor-onion-service-configuration @end lisp maps ports 22 and 80 of the Onion Service to the local ports 22 and 8080.")) +(define-record-type* + tor-transport-plugin make-tor-transport-plugin + tor-transport-plugin? + (role tor-transport-plugin-role + (default 'client) + (sanitize (lambda (value) + (if (memq value '(client server)) + value + (configuration-field-error #f 'role value))))) + (protocol tor-transport-plugin-protocol + (default "obfs4")) + (path-to-binary tor-transport-plugin-path)) + (define (tor-configuration->torrc config) "Return a 'torrc' file for CONFIG." (match-record config - (tor config-file hidden-services socks-socket-type control-socket?) + (tor config-file hidden-services socks-socket-type control-socket? + transport-plugins) (computed-file "torrc" (with-imported-modules '((guix build utils)) @@ -1038,6 +1060,20 @@ (define (tor-configuration->torrc config) (cons name mapping))) hidden-services)) + (for-each (match-lambda + ((role-string protocol path) + (format port "\ +~aTransportPlugin ~a exec ~a~%" + role-string protocol path))) + '#$(map (match-lambda + (($ role protocol path) + (list (if (eq? role 'client) + "Client" + "Server") + protocol + path))) + transport-plugins)) + (display "\ ### End of automatically generated lines.\n\n" port) @@ -1050,20 +1086,27 @@ (define (tor-configuration->torrc config) (define (tor-shepherd-service config) "Return a running Tor." (let* ((torrc (tor-configuration->torrc config)) + (transport-plugins (tor-configuration-transport-plugins config)) (tor (least-authority-wrapper (file-append (tor-configuration-tor config) "/bin/tor") #:name "tor" - #:mappings (list (file-system-mapping - (source "/var/lib/tor") - (target source) - (writable? #t)) - (file-system-mapping - (source "/var/run/tor") - (target source) - (writable? #t)) - (file-system-mapping - (source torrc) - (target source))) + #:mappings (append + (list (file-system-mapping + (source "/var/lib/tor") + (target source) + (writable? #t)) + (file-system-mapping + (source "/var/run/tor") + (target source) + (writable? #t)) + (file-system-mapping + (source torrc) + (target source))) + (map (lambda (plugin) + (file-system-mapping + (source (tor-transport-plugin-path plugin)) + (target source))) + transport-plugins)) #:namespaces (delq 'net %namespaces)))) (list (shepherd-service (provision '(tor)) base-commit: af4c90dc736295b19fda88cd8652f67f138409a1 -- 2.45.2