From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id AKCRFNXetWZLJgEAe85BDQ:P1 (envelope-from ) for ; Fri, 09 Aug 2024 09:18:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id AKCRFNXetWZLJgEAe85BDQ (envelope-from ) for ; Fri, 09 Aug 2024 11:18:13 +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=pPAeYGe5; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=WoBjfJtl; 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=1723195092; 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=lmUqyD4zIXm3sD8deFGZixqvR6wh8S7U6X2jyUSymCQ=; b=JQxpEkh+CfXCFCoKNjlTz/S+QYh+nG+Cro63Mm3+vQ4JEUXCRFid8fGJZJdCZ4coGS+3Ld WI3rZ8IlW+HxJYhJR6MDX8zcAZUJR5QqkVdcfVIhH9cpQp+UnXO2YrRYBRnQx5oftmJ2q+ kX4dBR+9ccaQ1Sp0TCv3wYWJYtadRiz7ONxp4puNWDSo/QPb9iOJxylff8HAoGWxihjdpI UlZ6ImMkDW2Jx+E1aYNb+6l75zpSGYvj7x6ADYb35aAmfd+k2rK/DRbbJPg4uWCdUseoMc cclq+pIFgmm6o5XKyGdwoaALLv4oFWzFy8TuyXPcNvgEURLzZ7MwhSxEEWIOIA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=pPAeYGe5; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=WoBjfJtl; 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=1723195092; a=rsa-sha256; cv=none; b=J771L+BA2SMP3ZepLHokvBQrzAoL34cDLPWw9r0qtckFqCT+sIuER38WQiDEB1w4jPz+T4 Bo1sjoDeuWCcVLgPjeSLHygEZgIbLcrrOTrl1O2Wk462Ql/Ph0zP73SyE63waK3Lsn4wgU +wY5DaWoTTIeCk3fjBTgn74IgQaaX7dGn0srBNFBJr3VKJD9EWsheXiPVa6YypX+dZDnce yPv7yr9Y/tDwCumAymjb6mYRmvx1MR0U/Dh+9Jcr6/pihLNPVIuQ+M93yRTlEE1R25vsfB JKxgmy7SJoUXKY2Vu2YUjbWpdt2jVXPzx3L4KTfIQQ6QD3tNdTdrCi2AT1cB2g== 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 6B19F5707D for ; Fri, 9 Aug 2024 11:18:12 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1scLkw-0003nK-Pm; Fri, 09 Aug 2024 05:17: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 1scLkj-0002uh-1S for guix-patches@gnu.org; Fri, 09 Aug 2024 05:17:43 -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 1scLkg-0006wZ-HD; Fri, 09 Aug 2024 05:17:40 -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=lmUqyD4zIXm3sD8deFGZixqvR6wh8S7U6X2jyUSymCQ=; b=pPAeYGe5ttd4qb5Xky4B2RktekduJZaw3vGYP1UqvLSgil/1Stj6qK7EvHCSO34H8PgfPKELIkUlDajM5PcEw4LFwJ12U7AloqC7TUXP0Hs7wozVaSAghuj+MGfpIHCUP2griW7nOxiWEiL0gb8HO/EESb/qwmIKNQheczhrqKkI48WPLcNdZX9O9QDXaUF5NEgHo7ITspRGD+rqd/EWikXwar6C5d+Oqla/8Y4A2nVdTDgGMRcQla4GXdg4k7TUum+ZY9XnXr4REo55447jHKacb/vE/kaVGPbAYse8+nnJBGUYsiUF6QIK/pNUs7bS/KHd7Q57dxxU+VQSMxrugA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1scLl4-00018K-9g; Fri, 09 Aug 2024 05:18:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70341] [PATCH v7] 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: Fri, 09 Aug 2024 09:18: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.17231950564315 (code B ref 70341); Fri, 09 Aug 2024 09:18:02 +0000 Received: (at 70341) by debbugs.gnu.org; 9 Aug 2024 09:17:36 +0000 Received: from localhost ([127.0.0.1]:37672 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1scLkd-00017W-KE for submit@debbugs.gnu.org; Fri, 09 Aug 2024 05:17:36 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:59744) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1scLkZ-00017G-BZ for 70341@debbugs.gnu.org; Fri, 09 Aug 2024 05:17:33 -0400 Received: by mail-lf1-f66.google.com with SMTP id 2adb3069b0e04-530d0882370so1778106e87.3 for <70341@debbugs.gnu.org>; Fri, 09 Aug 2024 02:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723194957; x=1723799757; 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=lmUqyD4zIXm3sD8deFGZixqvR6wh8S7U6X2jyUSymCQ=; b=WoBjfJtlDvld4ULHiMhGwzTORlQNIN8+ZnL/68Sd4Z1KfuN8lj90rjN/bncr+38cPe V+TV57BB5EYGA2SnHR0PwQkRWP0yx/QUj24JH9pGQSCaDzAWyBXDTfZRjUyF9JCyEckt 4hLhuMNqpma6pBTEYbhG8yZbdMigpXcUr8ORzTKpEnJJwe6yiBsSvCtQblbA+lvMqA1O kMWMkutgF6peq84rBH6H9/9F7bgGnjQH7pwxagNmL1nR5GKQxU/I/JTI+lenyWkYAhzb 7R/OPVrcxVwxDhvm7M4EZdSWyuulGzpi+r0zUFxLQdiKf4jUpMoXKmpN5mImrrxFUSL/ 7VQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723194957; x=1723799757; 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=lmUqyD4zIXm3sD8deFGZixqvR6wh8S7U6X2jyUSymCQ=; b=ROlhmKPxBjgD0+nUpgeAdNgJU55rD5zdMn+7ohvJpPg/Ufe0ZU2p3wp/Ox8o6TemsB 0r9BFmP9Xg4VFrK2fMBVdHQcRPMnwLU+vqH4h1ZF8uwkWB2RG9QMFPK1ffXu0TmEaWrz iGfDcS6nzInGd0zdW6WSdFLXM7fto9KWl/50ITiyQlbjYHIYHesVype6NywlXrml6/qk VR7tRArcFaqosyzpEF/rAdqfYTRUYromhDoyi+3OUxP9exf/0MPyb9HpeF3n2o6xGBSt EUe6rRysLzfIUEYpPW0qNCDY2iLq1ZowaBZDFT4v04tFo0xJcDThWqnsnWQMqOqmgyKD ae+A== X-Gm-Message-State: AOJu0YyL6n0naNne9ON+3P3V2c0yeO9JkS253j2uyGERr5ZtIC06fEhU ZBgGuUrorzx1IdoL5lkTqpc0kW+0b6ulLlFXJcO4omKO6FSUOhG8943WkJd7 X-Google-Smtp-Source: AGHT+IGs45b8CymRsZiEWM/3RNBXalKa7gHq+2sq2SQ0OklBadoTCai6OWSO2+4ocDMdSbNnPcSi/w== X-Received: by 2002:a05:6512:1597:b0:52e:934c:8e76 with SMTP id 2adb3069b0e04-530ee9e13f2mr700187e87.41.1723194956652; Fri, 09 Aug 2024 02:15:56 -0700 (PDT) Received: from localhost.localdomain ([188.168.200.73]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-530de457b6dsm915350e87.166.2024.08.09.02.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 02:15:56 -0700 (PDT) From: Nigko Yerden Date: Fri, 9 Aug 2024 14:15:27 +0500 Message-ID: <6bcd7fab071edaf6c8ffbbfd86fef286ee7e38e7.1723194927.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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: 6B19F5707D X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -8.39 X-Spam-Score: -8.39 X-TUID: beZZEzzWIlXd 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 --- 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 b7eb8fd346..0319003b20 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: 20dbf225f332ccc707578263ed710dcf2a8fb78e -- 2.45.2