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 eMFDIyOE6WaMfgEAqHPOHw:P1 (envelope-from ) for ; Tue, 17 Sep 2024 13:29:07 +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 eMFDIyOE6WaMfgEAqHPOHw (envelope-from ) for ; Tue, 17 Sep 2024 15:29:07 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=WroOetlc; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=eN3ZCgdh; 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"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1726579747; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=p3WMi7N+akGeMTF04UA5IN1ZXwyV5p6SGd6MyrD/I3Y=; b=p2KG0bEdknl4qr+Z5ElCRysSyK4WuTAGG6gG4/SQ1wu6zCVgBvecRvWLTzY67jcP0asghZ Oz2HMvEilXT/xsu6ij4xERmBRfQahMjz/kk9IlQX5PHcQmT07GliVY0fVFY62r7UTTj7M5 JPRsfA1RHCCgT5KlyATRbTaMASHBU2D/70D2PuLUp86wWsON9w1yKzl1Zr24NKusGFa7vu jh1S2OMpEyrSf3mxyAIBaPq6YWagjCBnaeevfRqimZGasplVNhXGCdtBiZqco+0IOKMgMW dgsj7E/GM3GyOK3NrvcqwUoCyMV77xLGSQQSJ/EvMLyJAL4IAtkyDmPR9gjP8Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=WroOetlc; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=eN3ZCgdh; 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"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1726579747; a=rsa-sha256; cv=none; b=Ax4JosT8z614oP8nTSp/pktJv7xGdsrV+XbiAYq8jpTcqWSgT/tPQumqX6nd7LP9wYVo15 IZX+OI8AymtD4r5S7CQgOOh1oMaBUmcWLkpa79xdp/eVMYdnx/2UA58DSW/9QBrRX+K9cd hNRwhTHECUakr/g1CfTaztR5IcmmgodTsjAcDmN6D9Rce53D10hNyp6vLvVhvOMkGEll0o 9n4WocM1yhueyJJ2s0A/BoBtsch8DvIoON8/HhDrCK8wrzuDJuJSI8+Zy7GM4OFeWF4jPR ZNOdVDYqilGWEXTBhSgTKXju0SQepv+krySOiVJ7Gg39XXU+Iyj9j2ts0Ddvdg== 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 551EB65C8 for ; Tue, 17 Sep 2024 15:29:07 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sqYGF-0004Ab-9l; Tue, 17 Sep 2024 09:28:55 -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 1sqYG8-0004A1-FA for guix-patches@gnu.org; Tue, 17 Sep 2024 09:28:48 -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 1sqYG8-0001Xv-5D; Tue, 17 Sep 2024 09:28:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=p3WMi7N+akGeMTF04UA5IN1ZXwyV5p6SGd6MyrD/I3Y=; b=WroOetlcpiWljtJWIMgnuAFhngPnMg5IiinQQBBP7VFgNTaHiUCa6J2CtyhnRs0JzJEk8HcPd1QJkVBqJ8bPShh0NoKw4SzZ9+UhgQeOjyb2WeUrP+RLRxcTGdflm55YXdWaNYFB60Q/xjt16WEdYFX3YKmrrZkwFTKVVopYRF2woIo3jBwaKb2K+K6fnsL8P9YaFwKYr6wUltiTaJq+zKoPglIYCy+lx4WDLllYTvCojME2s/W8ovDJwsBMzDSSJPmngvAOiqP34tbQQ6mfKq87DTAagMDgrtURTBYM8dkRHaK4Pr/Ds3cP1+y6z1hZxejhtoIaWzFA10FarNT37A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sqYGL-0004hm-MO; Tue, 17 Sep 2024 09:29:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70341] [PATCH v8] 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, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Tue, 17 Sep 2024 13:29:01 +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: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Nigko Yerden , Florian Pelz , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 70341-submit@debbugs.gnu.org id=B70341.172657972618057 (code B ref 70341); Tue, 17 Sep 2024 13:29:01 +0000 Received: (at 70341) by debbugs.gnu.org; 17 Sep 2024 13:28:46 +0000 Received: from localhost ([127.0.0.1]:54244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqYG5-0004h9-0u for submit@debbugs.gnu.org; Tue, 17 Sep 2024 09:28:46 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:60854) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqYG0-0004gq-R6 for 70341@debbugs.gnu.org; Tue, 17 Sep 2024 09:28:43 -0400 Received: by mail-lf1-f67.google.com with SMTP id 2adb3069b0e04-5365cf5de24so7179921e87.1 for <70341@debbugs.gnu.org>; Tue, 17 Sep 2024 06:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726579640; x=1727184440; 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=p3WMi7N+akGeMTF04UA5IN1ZXwyV5p6SGd6MyrD/I3Y=; b=eN3ZCgdhbZ9vlgZc/MzMashTkpdLbrxguxVN7N8ERDnsmdJn0E9XEKbXcLul9c/3Kj pkJ9ZKdDnwy1fnJhMuqZoTnvPX8k+6cV3K7Lokz83ry3xTiGO7qM5PYt/SXMlLjDol8P w0YH13gD6V2qjn9vc2R0KGIMkFzQKhKjtP5gJ8096WhCoLDwMP69+Ua2lZPW3U46TdWs MYp74jszzYvXKTQvUAfWrk/s40gwRhaMEnC73kWOqX/e3/pqt9QYTFoiPC51nPdpBiUL xE9s2wAXm14GNQ+2MsXNJgzE2Gwn/9Yop3lFxmeBLV8hVzqMErxAyCnMjoLW+XSb2FcQ iDug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726579640; x=1727184440; 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=p3WMi7N+akGeMTF04UA5IN1ZXwyV5p6SGd6MyrD/I3Y=; b=VYsRFLgev+Co38xLJbuUlclCXIxJ5IuV29f/cdjJpl71i4Mc7CqvzKkNffaH7g5Uct gSj4h+WAXLD8Sb2AGJVB6rptIXleEyaIN6m8g3Dr1BJyi91bi/v+bgLo6u90LAjIrUHK +ktoI2029buTHiAb/sGJzxAZZ30bbaWhUCH0jxd9xHxbgNsweItrL/YzAd5l8kxGiVvX anj5/Ww1UtYQDIrdCgIn3smzHa9yvQ6b6O1kbpmyAt/Ektk5V5132rrUsZRcGLaJTUFO NQ+AEyO8+4G1CH2ucizCwHXe9i+Z3BQjXvxsGrh1Etb2+CjAgkyzM7NJmL1TPWLMtNKP PdDQ== X-Gm-Message-State: AOJu0YwojlbYzu3xXwJFqUb7Rgxhl+UeuJMSd5J/v2SRsAvcICqNBKHY b8D9bLe7KEEzx+H/itPv5xQyk/YwWilgKZEZK9+7w6ZiWowkSUnVPiTcHWiJ X-Google-Smtp-Source: AGHT+IFNqb+Xmqtl+/n+c5E+GZmKciVT63P6UTcsdRLjnbXbls94f38wVYMPyDKv3glQBAOHli2Tzw== X-Received: by 2002:a05:6512:3b22:b0:536:553f:3eec with SMTP id 2adb3069b0e04-53678faa045mr10569447e87.5.1726579639074; Tue, 17 Sep 2024 06:27:19 -0700 (PDT) Received: from localhost.localdomain ([188.168.141.132]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-536870bb955sm1196986e87.301.2024.09.17.06.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2024 06:27:18 -0700 (PDT) From: Nigko Yerden Date: Tue, 17 Sep 2024 18:11:28 +0500 Message-ID: X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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-Queue-Id: 551EB65C8 X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -8.94 X-Migadu-Spam-Score: -8.94 X-TUID: hdbpCIxMCkR7 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). ;;; Copyright © 2024 Nigko Yerden * 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-plugin-role', 'tor-plugin-protocol', and 'tor-plugin-program'. (): 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 --- Hello Ludo, Thanks for looking at and sorry for delay. I have made corrections in accordance with your suggestions: 1. Move example from commit message to doc/guix.tex. 2. Replace 'path-to-binary' field with 'program'. 3. Replace 'tor-transport-plugin-{role,protocol,path-to-binary}' accessors with 'tor-plugin-{role,protocol,program}'. 4. Use @code{ClientTransportPlugin ...} instead of quotes and @command{man tor} instead of @code{man tor}. Regards, Nigko doc/guix.texi | 68 ++++++++++++++++++++++++++++++++++++ gnu/services/networking.scm | 69 ++++++++++++++++++++++++++++++------- 2 files changed, 124 insertions(+), 13 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index bc4d306c2d..ad785f97e6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -22045,6 +22045,12 @@ 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 @@ -22073,6 +22079,68 @@ 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 +@code{ClientTransportPlugin ...} or to +@code{ServerTransportPlugin ...} line in the default +configuration file, see @command{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{program} +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 + +Suppose you would like Tor daemon to use obfs4 type obfuscation and +to connect to Tor network via obfs4 bridge (a nonpublic Tor relay with +support for obfs4 type obfuscation). Then you may go to +@url{https://bridges.torproject.org/, https://bridges.torproject.org/} +and get there a couple of bridge lines (each starts with @code{obfs4 ...}) +and use these lines in tor-service-type configuration as follows: +@lisp +(service tor-service-type + (tor-configuration + (config-file (plain-file "torrc" + "\ +UseBridges 1 +Bridge obfs4 ... +Bridge obfs4 ...")) + (transport-plugins + (list (tor-transport-plugin + (program + (file-append + go-gitlab-torproject-org-tpo-anti-censorship-pluggable-transports-lyrebird + "/bin/lyrebird"))))))) +@end lisp +@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..5a4e3a960d 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-plugin-role + tor-plugin-protocol + tor-plugin-program 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-plugin-role + (default 'client) + (sanitize (lambda (value) + (if (memq value '(client server)) + value + (configuration-field-error #f 'role value))))) + (protocol tor-plugin-protocol + (default "obfs4")) + (program tor-plugin-program)) + (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 program) + (format port "\ +~aTransportPlugin ~a exec ~a~%" + role-string protocol program))) + '#$(map (match-lambda + (($ role protocol program) + (list (if (eq? role 'client) + "Client" + "Server") + protocol + program))) + 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-plugin-program plugin)) + (target source))) + transport-plugins)) #:namespaces (delq 'net %namespaces)))) (list (shepherd-service (provision '(tor)) base-commit: 8dae6b47542b906682f83b06b0478fcbd0776fd6 -- 2.45.2