gnu: r-zellkonverter: Update to 1.6.5.
[jackhill/guix/guix.git] / gnu / packages / tor.scm
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>
16 ;;;
17 ;;; This file is part of GNU Guix.
18 ;;;
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.
23 ;;;
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.
28 ;;;
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/>.
31
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))
60
61 (define-public tor
62 (package
63 (name "tor")
64 (version "0.4.7.10")
65 (source (origin
66 (method url-fetch)
67 (uri (string-append "https://dist.torproject.org/tor-"
68 version ".tar.gz"))
69 (sha256
70 (base32
71 "0nss8g6hx42nqiir6l03dj15r433fvygq9r00nmnv8wylpgmczk4"))))
72 (build-system gnu-build-system)
73 (arguments
74 (list #:configure-flags
75 #~(list "--enable-lzma"
76 "--enable-zstd")
77 #:phases
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")
86 "true")
87 (("exec 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.
91 (lambda _
92 (setenv "TOR_DISABLE_PRACTRACKER" "set")))
93 #$@(if (or (target-x86-64?)
94 (target-x86-32?))
95 '()
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
103 (lambda _
104 (substitute* "src/test/test_include.sh"
105 ((".*Sandbox 1.*") ""))
106 (substitute* "src/test/test.c"
107 ((".*sandbox_tests.*") "")))))))))
108 (native-inputs
109 (list pkg-config python)) ; for tests
110 (inputs
111 (list libevent
112 libseccomp
113 openssl
114 torsocks
115 xz
116 zlib
117 `(,zstd "lib")))
118 (home-page "https://www.torproject.org/")
119 (synopsis "Anonymous network router to improve privacy on the Internet")
120 (description
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.
128
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}
132 instead.")
133 (license license:bsd-3)))
134
135 (define-public tor-client
136 (package
137 (inherit tor)
138 (name "tor-client")
139 (arguments
140 (substitute-keyword-arguments (package-arguments tor)
141 ((#:configure-flags flags #~'())
142 #~(append #$flags
143 (list "--disable-module-relay")))))
144 (synopsis "Client to the anonymous Tor network")
145 (description
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.
153
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}.
158
159 This package only provides a client to the Tor Network.")))
160
161 (define-public torsocks
162 (package
163 (name "torsocks")
164 (version "2.4.0")
165 (source
166 (origin
167 (method url-fetch)
168 (uri (string-append
169 "https://gitlab.torproject.org/tpo/core/torsocks/-/archive/v"
170 version "/torsocks-v" version ".tar.bz2"))
171 (sha256
172 (base32
173 "1a7k3njdhp7dz603knhisna1zvxw35j3g213p6dvczv9bcjy7cjl"))))
174 (build-system gnu-build-system)
175 (inputs
176 (list libcap))
177 (native-inputs
178 (list autoconf automake libtool))
179 (arguments
180 `(#:phases
181 (modify-phases %standard-phases
182 (add-after 'build 'absolutize
183 (lambda* (#:key inputs #:allow-other-keys)
184 (substitute* "src/bin/torsocks"
185 (("getcap=.*")
186 (string-append "getcap=" (which "getcap") "\n"))))))))
187 (home-page "https://www.torproject.org/")
188 (synopsis "Transparently route an application's traffic through Tor.")
189 (description
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.")
193
194 ;; All the files explicitly say "version 2 only".
195 (license license:gpl2)))
196
197 (define-public privoxy
198 (package
199 (name "privoxy")
200 (version "3.0.33")
201 (source (origin
202 (method url-fetch)
203 (uri (string-append "mirror://sourceforge/ijbswa/Sources/"
204 version "%20%28stable%29/privoxy-"
205 version "-stable-src.tar.gz"))
206 (sha256
207 (base32
208 "1bhzi2ddv3g1z9h7lhxy7p0wibqg4m5nh46ikldmcqdc1pkh9c84"))))
209 (build-system gnu-build-system)
210 (arguments
211 '(;; The default 'sysconfdir' is $out/etc; change that to
212 ;; $out/etc/privoxy.
213 #:configure-flags (list (string-append "--sysconfdir="
214 (assoc-ref %outputs "out")
215 "/etc/privoxy")
216 "--localstatedir=/var"
217 "--with-brotli"
218 "--with-openssl")
219 #:tests? #f ; no test suite
220 #:phases
221 (modify-phases %standard-phases
222 (add-after 'unpack 'patch-default-logging
223 (lambda _
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)
230 match)
231 ((".*\\$\\(LOG_DEST\\) \\$\\(DESTDIR\\)\\$\\(PID_DEST\\).*")
232 ""))
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"))))))))
238 (inputs
239 (list brotli openssl pcre w3m zlib))
240 (native-inputs
241 (list autoconf automake))
242 (home-page "https://www.privoxy.org")
243 (synopsis "Web proxy with advanced filtering capabilities for enhancing privacy")
244 (description
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
250 networks.")
251 (license license:gpl2+)))
252
253 (define-public onionshare-cli
254 (package
255 (name "onionshare-cli")
256 (version "2.5")
257 (source
258 (origin
259 (method git-fetch)
260 (uri (git-reference
261 (url "https://github.com/onionshare/onionshare")
262 (commit (string-append "v" version))))
263 (file-name (git-file-name name version))
264 (sha256
265 (base32 "16m5ll0v0qjbirwwzbzxg53kq4ry1n3ay5x0h8zkij73v3x0q864"))))
266 (build-system python-build-system)
267 (native-inputs
268 (list python-pytest))
269 (inputs
270 ;; TODO: obfs4proxy
271 (list python-click
272 python-colorama
273 python-eventlet
274 python-flask
275 python-flask-httpauth
276 python-flask-socketio
277 python-pynacl
278 python-psutil
279 python-pycryptodome
280 python-pysocks
281 python-requests
282 python-stem
283 python-unidecode
284 python-urllib3
285 tor))
286 (arguments
287 (list
288 #:phases
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"
297 (("/usr/share/tor")
298 (search-input-directory inputs "share/tor")))))
299 (add-before 'build 'change-directory
300 (lambda _ (chdir "cli")))
301 (replace 'check
302 (lambda* (#:key tests? #:allow-other-keys)
303 (when tests?
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.
315
316 This package contains @code{onionshare-cli}, a command-line interface to
317 OnionShare.")
318 ;; Bundled, minified jquery and socket.io are expat licensed.
319 (license (list license:gpl3+ license:expat))))
320
321 (define-public onionshare
322 (package
323 (inherit onionshare-cli)
324 (name "onionshare")
325 (arguments
326 (substitute-keyword-arguments (package-arguments onionshare-cli)
327 ((#:phases phases)
328 #~(modify-phases #$phases
329 (replace 'change-directory
330 (lambda _ (chdir "desktop/")))
331 (add-after 'install 'install-data
332 (lambda _
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"))))
339 (replace 'check
340 (lambda* (#:key tests? #:allow-other-keys)
341 (when tests?
342 ;; Remove multiline load-path adjustment, so that
343 ;; onionshare-cli modules are loaded from input
344 (substitute* "tests/conftest.py"
345 (("\"cli\",")
346 "\"/nonexistent\""))
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).
358 ((#:tests? _ #f)
359 #f)))
360 (native-inputs
361 (list python-pytest))
362 (inputs
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
369 python-shiboken-2
370 python-pyside-2
371 python-qrcode
372 xvfb-run)))
373 (description "OnionShare lets you securely and anonymously share files,
374 host websites, and chat with friends using the Tor network.")))
375
376 (define-public nyx
377 (package
378 (name "nyx")
379 (version "2.1.0")
380 (source
381 (origin
382 (method url-fetch)
383 (uri (pypi-uri name version))
384 (sha256
385 (base32
386 "02rrlllz2ci6i6cs3iddyfns7ang9a54jrlygd2jw1f9s6418ll8"))))
387 (build-system python-build-system)
388 (inputs
389 (list python-stem))
390 (arguments
391 `(#:phases
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"))
398 #t)))
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)
404 #t))))
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
410 #:tests? #f))
411 (home-page "https://nyx.torproject.org/")
412 (synopsis "Tor relay status monitor")
413 (description
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:
420
421 @enumerate
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,
425 @item logged events,
426 @item and much more.
427 @end enumerate
428
429 Potential client and exit connections are scrubbed of sensitive information.")
430 (license license:gpl3+)))
431
432 (define-public tractor
433 (package
434 (name "tractor")
435 (version "3.14")
436 (source
437 (origin
438 (method url-fetch)
439 (uri (pypi-uri "traxtor" version))
440 (sha256
441 (base32
442 "06jhsg179rfckagrpk9r8wqp44anf1bchm3ins2saf5806f0n5lw"))))
443 (build-system python-build-system)
444 (native-inputs
445 `(("glib:bin" ,glib "bin"))) ; for glib-compile-schemas.
446 (inputs
447 (list python-fire
448 python-psutil
449 python-pygobject
450 python-requests
451 python-stem
452 python-termcolor))
453 (arguments
454 `(#:phases
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)
461 #t)))
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)
467 #t))))))
468 (home-page "https://framagit.org/tractor")
469 (synopsis "Setup an onion routing proxy")
470 (description
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+)))