1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2021 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016, 2017, 2018, 2020, 2021, 2022 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
6 ;;; Copyright © 2017–2021 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2017, 2018, 2019, 2021 Eric Bavier <bavier@posteo.net>
8 ;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
9 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
10 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
11 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
12 ;;; Copyright © 2020 André Batista <nandre@riseup.net>
13 ;;; Copyright © 2021-2022 Danial Behzadi <dani.behzi@ubuntu.com>
14 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
15 ;;; Copyright © 2022 Jim Newsome <jnewsome@torproject.org>
17 ;;; This file is part of GNU Guix.
19 ;;; GNU Guix is free software; you can redistribute it and/or modify it
20 ;;; under the terms of the GNU General Public License as published by
21 ;;; the Free Software Foundation; either version 3 of the License, or (at
22 ;;; your option) any later version.
24 ;;; GNU Guix is distributed in the hope that it will be useful, but
25 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ;;; GNU General Public License for more details.
29 ;;; You should have received a copy of the GNU General Public License
30 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
32 (define-module (gnu packages tor)
33 #:use-module (guix gexp)
34 #:use-module ((guix licenses) #:prefix license:)
35 #:use-module (guix packages)
36 #:use-module (guix utils)
37 #:use-module (guix download)
38 #:use-module (guix git-download)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix build-system python)
41 #:use-module (gnu packages)
42 #:use-module (gnu packages base)
43 #:use-module (gnu packages libevent)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages check)
46 #:use-module (gnu packages compression)
47 #:use-module (gnu packages pcre)
48 #:use-module (gnu packages glib)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages python)
51 #:use-module (gnu packages python-check)
52 #:use-module (gnu packages python-crypto)
53 #:use-module (gnu packages python-web)
54 #:use-module (gnu packages python-xyz)
55 #:use-module (gnu packages qt)
56 #:use-module (gnu packages autotools)
57 #:use-module (gnu packages tls)
58 #:use-module (gnu packages w3m)
59 #:use-module (gnu packages xorg))
67 (uri (string-append "https://dist.torproject.org/tor-"
71 "0nss8g6hx42nqiir6l03dj15r433fvygq9r00nmnv8wylpgmczk4"))))
72 (build-system gnu-build-system)
74 (list #:configure-flags
75 #~(list "--enable-lzma"
78 #~(modify-phases %standard-phases
79 (add-before 'build 'adjust-torify
80 (lambda* (#:key inputs #:allow-other-keys)
81 ;; Record in 'torify' the absolute file name of 'torsocks'.
82 (let ((torsocks (search-input-file
83 inputs "/bin/torsocks")))
84 (substitute* "contrib/client-tools/torify"
85 (("pathfind torsocks")
88 (string-append "exec " torsocks))))))
89 (add-before 'check 'skip-practracker
90 ;; This is a style linter. It doesn't get to throw fatal errors.
92 (setenv "TOR_DISABLE_PRACTRACKER" "set")))
93 #$@(if (or (target-x86-64?)
96 ;; Work around upstream issues relating to libseccomp,
97 ;; sandboxing and glibc-2.33. This is similar to the issue
98 ;; the tor-sandbox-i686 patch fixes but for other architectures.
99 ;; https://gitlab.torproject.org/tpo/core/tor/-/issues/40381
100 ;; https://gitlab.torproject.org/tpo/core/tor/-/issues/40599
101 ;; https://gitlab.torproject.org/tpo/core/tor/-/merge_requests/446
102 `((add-before 'check 'adjust-test-suite
104 (substitute* "src/test/test_include.sh"
105 ((".*Sandbox 1.*") ""))
106 (substitute* "src/test/test.c"
107 ((".*sandbox_tests.*") "")))))))))
109 (list pkg-config python)) ; for tests
118 (home-page "https://www.torproject.org/")
119 (synopsis "Anonymous network router to improve privacy on the Internet")
121 "Tor protects you by bouncing your communications around a distributed
122 network of relays run by volunteers all around the world: it prevents
123 somebody watching your Internet connection from learning what sites you
124 visit, and it prevents the sites you visit from learning your physical
125 location. Tor works with many of your existing applications, including
126 web browsers, instant messaging clients, remote login, and other
127 applications based on the TCP protocol.
129 This package is the full featured @code{tor} which is needed for running
130 relays, bridges or directory authorities. If you just want to access the Tor
131 network or to setup an onion service you may install @code{tor-client}
133 (license license:bsd-3)))
135 (define-public tor-client
140 (substitute-keyword-arguments (package-arguments tor)
141 ((#:configure-flags flags #~'())
143 (list "--disable-module-relay")))))
144 (synopsis "Client to the anonymous Tor network")
146 "Tor protects you by bouncing your communications around a distributed
147 network of relays run by volunteers all around the world: it prevents
148 somebody watching your Internet connection from learning what sites you
149 visit, and it prevents the sites you visit from learning your physical
150 location. Tor works with many of your existing applications, including
151 web browsers, instant messaging clients, remote login, and other
152 applications based on the TCP protocol.
154 To @code{torify} applications (to take measures to ensure that an application,
155 which has not been designed for use with Tor such as ssh, will use only Tor for
156 internet connectivity, and also ensures that there are no leaks from DNS, UDP or
157 the application layer) you need to install @code{torsocks}.
159 This package only provides a client to the Tor Network.")))
161 (define-public torsocks
169 "https://gitlab.torproject.org/tpo/core/torsocks/-/archive/v"
170 version "/torsocks-v" version ".tar.bz2"))
173 "1a7k3njdhp7dz603knhisna1zvxw35j3g213p6dvczv9bcjy7cjl"))))
174 (build-system gnu-build-system)
178 (list autoconf automake libtool))
181 (modify-phases %standard-phases
182 (add-after 'build 'absolutize
183 (lambda* (#:key inputs #:allow-other-keys)
184 (substitute* "src/bin/torsocks"
186 (string-append "getcap=" (which "getcap") "\n"))))))))
187 (home-page "https://www.torproject.org/")
188 (synopsis "Transparently route an application's traffic through Tor.")
190 "Torsocks allows you to use most applications in a safe way with Tor. It
191 ensures that DNS requests are handled safely and explicitly rejects UDP
192 traffic from the application you're using.")
194 ;; All the files explicitly say "version 2 only".
195 (license license:gpl2)))
197 (define-public privoxy
203 (uri (string-append "mirror://sourceforge/ijbswa/Sources/"
204 version "%20%28stable%29/privoxy-"
205 version "-stable-src.tar.gz"))
208 "1bhzi2ddv3g1z9h7lhxy7p0wibqg4m5nh46ikldmcqdc1pkh9c84"))))
209 (build-system gnu-build-system)
211 '(;; The default 'sysconfdir' is $out/etc; change that to
213 #:configure-flags (list (string-append "--sysconfdir="
214 (assoc-ref %outputs "out")
216 "--localstatedir=/var"
219 #:tests? #f ; no test suite
221 (modify-phases %standard-phases
222 (add-after 'unpack 'patch-default-logging
224 (with-fluids ((%default-port-encoding "ISO-8859-1"))
225 ;; Do not create /var/run nor /var/log/privoxy/logfile.
226 (substitute* "GNUmakefile.in"
227 (("(logfile \\|\\| exit )1" _ match)
228 (string-append match "0"))
229 (("(\\$\\(DESTDIR\\)\\$\\(SHARE_DEST\\)) \\\\" _ match)
231 ((".*\\$\\(LOG_DEST\\) \\$\\(DESTDIR\\)\\$\\(PID_DEST\\).*")
233 ;; Disable logging in the default configuration to allow for
234 ;; non-root users using it as is.
235 (substitute* "config"
236 (("^logdir") "#logdir")
237 (("^logfile") "#logfile"))))))))
239 (list brotli openssl pcre w3m zlib))
241 (list autoconf automake))
242 (home-page "https://www.privoxy.org")
243 (synopsis "Web proxy with advanced filtering capabilities for enhancing privacy")
245 "Privoxy is a non-caching web proxy with advanced filtering capabilities
246 for enhancing privacy, modifying web page data and HTTP headers, controlling
247 access, and removing ads and other obnoxious Internet junk. Privoxy has a
248 flexible configuration and can be customized to suit individual needs and
249 tastes. It has application for both stand-alone systems and multi-user
251 (license license:gpl2+)))
253 (define-public onionshare-cli
255 (name "onionshare-cli")
261 (url "https://github.com/onionshare/onionshare")
262 (commit (string-append "v" version))))
263 (file-name (git-file-name name version))
265 (base32 "16m5ll0v0qjbirwwzbzxg53kq4ry1n3ay5x0h8zkij73v3x0q864"))))
266 (build-system python-build-system)
268 (list python-pytest))
275 python-flask-httpauth
276 python-flask-socketio
289 #~(modify-phases %standard-phases
290 (add-after 'unpack 'bake-tor
291 (lambda* (#:key inputs #:allow-other-keys)
292 (substitute* (list "cli/onionshare_cli/common.py"
293 "desktop/onionshare/gui_common.py")
294 (("shutil\\.which\\(\\\"tor\\\"\\)")
295 (format #f "~s" (search-input-file inputs "bin/tor"))))
296 (substitute* "cli/tests/test_cli_common.py"
298 (search-input-directory inputs "share/tor")))))
299 (add-before 'build 'change-directory
300 (lambda _ (chdir "cli")))
302 (lambda* (#:key tests? #:allow-other-keys)
304 (setenv "HOME" "/tmp")
305 ;; Greendns is not needed for testing, and if eventlet tries to
306 ;; load it, an OSError is thrown when getprotobyname is called.
307 ;; Thankfully there is an environment variable to disable the
308 ;; greendns import, so use it:
309 (setenv "EVENTLET_NO_GREENDNS" "yes")
310 (invoke "pytest" "-v" "./tests")))))))
311 (home-page "https://onionshare.org/")
312 (synopsis "Securely and anonymously share files")
313 (description "OnionShare lets you securely and anonymously share files,
314 host websites, and chat with friends using the Tor network.
316 This package contains @code{onionshare-cli}, a command-line interface to
318 ;; Bundled, minified jquery and socket.io are expat licensed.
319 (license (list license:gpl3+ license:expat))))
321 (define-public onionshare
323 (inherit onionshare-cli)
326 (substitute-keyword-arguments (package-arguments onionshare-cli)
328 #~(modify-phases #$phases
329 (replace 'change-directory
330 (lambda _ (chdir "desktop/")))
331 (add-after 'install 'install-data
333 (install-file "org.onionshare.OnionShare.svg"
334 (string-append #$output
335 "/share/icons/hicolor/scalable/apps"))
336 (install-file "org.onionshare.OnionShare.desktop"
337 (string-append #$output
338 "/share/applications"))))
340 (lambda* (#:key tests? #:allow-other-keys)
342 ;; Remove multiline load-path adjustment, so that
343 ;; onionshare-cli modules are loaded from input
344 (substitute* "tests/conftest.py"
347 ;; Avoid `getprotobyname` issues:
348 (setenv "EVENTLET_NO_GREENDNS" "yes")
349 ;; Make Qt render "offscreen":
350 (setenv "QT_QPA_PLATFORM" "offscreen")
351 (setenv "HOME" "/tmp")
352 (apply invoke "xvfb-run" "pytest" "-vv"
353 (find-files "tests" "^test_gui.*\\.py$")))))))
354 ;; Most tests fail: "2 failed, 8 warnings, 44 errors in 6.06s", due to
355 ;; error "RuntimeError: Please destroy the Application singleton before
356 ;; creating a new Application instance." (see:
357 ;; https://github.com/onionshare/onionshare/issues/1603).
361 (list python-pytest))
363 ;; The desktop client uses onionshare-cli like a python module. But
364 ;; propagating onionshare-cli's inputs is not great, since a user would
365 ;; not expect to have those installed when using onionshare-cli as a
366 ;; standalone utility. So add onionshare-cli's inputs here.
367 (modify-inputs (package-inputs onionshare-cli)
368 (prepend onionshare-cli ;TODO: package obfs4proxy
373 (description "OnionShare lets you securely and anonymously share files,
374 host websites, and chat with friends using the Tor network.")))
383 (uri (pypi-uri name version))
386 "02rrlllz2ci6i6cs3iddyfns7ang9a54jrlygd2jw1f9s6418ll8"))))
387 (build-system python-build-system)
392 (modify-phases %standard-phases
393 (add-after 'install 'install-man-page
394 (lambda* (#:key outputs #:allow-other-keys)
395 (let* ((out (assoc-ref outputs "out"))
396 (man (string-append out "/share/man")))
397 (install-file "nyx.1" (string-append man "/man1"))
399 (add-after 'install 'install-sample-configuration
400 (lambda* (#:key outputs #:allow-other-keys)
401 (let* ((out (assoc-ref outputs "out"))
402 (doc (string-append out "/share/doc/" ,name "-" ,version)))
403 (install-file "web/nyxrc.sample" doc)
405 ;; XXX The tests seem to require more of a real terminal than the build
406 ;; environment provides:
407 ;; _curses.error: setupterm: could not find terminal
408 ;; With TERM=linux, the tests try to move the cursor and still fail:
409 ;; _curses.error: cbreak() returned ERR
411 (home-page "https://nyx.torproject.org/")
412 (synopsis "Tor relay status monitor")
414 "Nyx monitors the performance of relays participating in the
415 @uref{https://www.torproject.org/, Tor anonymity network}. It displays this
416 information visually and in real time, using a curses-based terminal interface.
417 This makes Nyx well-suited for remote shell connections and servers without a
418 graphical display. It's like @command{top} for Tor, providing detailed
419 statistics and status reports on:
422 @item connections (with IP address, hostname, fingerprint, and consensus data),
423 @item bandwidth, processor, and memory usage,
424 @item the relay's current configuration,
429 Potential client and exit connections are scrubbed of sensitive information.")
430 (license license:gpl3+)))
432 (define-public tractor
439 (uri (pypi-uri "traxtor" version))
442 "06jhsg179rfckagrpk9r8wqp44anf1bchm3ins2saf5806f0n5lw"))))
443 (build-system python-build-system)
445 `(("glib:bin" ,glib "bin"))) ; for glib-compile-schemas.
455 (modify-phases %standard-phases
456 (add-after 'install 'install-man-page
457 (lambda* (#:key outputs #:allow-other-keys)
458 (let* ((out (assoc-ref outputs "out"))
459 (man1 (string-append out "/share/man/man1")))
460 (install-file "tractor/man/tractor.1" man1)
462 (add-after 'install 'install-gschema
463 (lambda* (#:key outputs #:allow-other-keys)
464 (let* ((out (assoc-ref outputs "out"))
465 (schemas (string-append out "/share/glib-2.0/schemas")))
466 (install-file "tractor/tractor.gschema.xml" schemas)
468 (home-page "https://framagit.org/tractor")
469 (synopsis "Setup an onion routing proxy")
471 "This package uses Python stem library to provide a connection through
472 the onion proxy and sets up proxy in user session, so you don't have to mess
473 up with TOR on your system anymore.")
474 (license license:gpl3+)))