gnu: tor: Update to 0.4.6.5.
[jackhill/guix/guix.git] / gnu / packages / tor.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016, 2017, 2018, 2020, 2021 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 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
20 ;;;
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
25 ;;;
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29 (define-module (gnu packages tor)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix utils)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system python)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages base)
39 #:use-module (gnu packages libevent)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages check)
42 #:use-module (gnu packages compression)
43 #:use-module (gnu packages pcre)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages python-crypto)
47 #:use-module (gnu packages python-web)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages qt)
50 #:use-module (gnu packages autotools)
51 #:use-module (gnu packages tls)
52 #:use-module (gnu packages w3m))
53
54 (define-public tor
55 (package
56 (name "tor")
57 (version "0.4.6.5")
58 (source (origin
59 (method url-fetch)
60 (uri (string-append "https://dist.torproject.org/tor-"
61 version ".tar.gz"))
62 (sha256
63 (base32
64 "1yacd7h7wg8n6wwrjmx2g9xjj24kj08j5sai9g7fm4cp1m73avbv"))
65 (patches (search-patches "tor-fix-build-with-gcc-7.patch"))))
66 (build-system gnu-build-system)
67 (arguments
68 `(#:configure-flags
69 (list "--enable-lzma"
70 "--enable-zstd")
71 #:phases
72 (modify-phases %standard-phases
73 (add-before 'check 'skip-practracker
74 ;; This is a style linter. It doesn't get to throw fatal errors.
75 (lambda _
76 (setenv "TOR_DISABLE_PRACTRACKER" "set")
77 #t)))))
78 (native-inputs
79 `(("pkg-config" ,pkg-config)
80 ("python" ,python))) ; for tests
81 (inputs
82 `(("libevent" ,libevent)
83 ("libseccomp" ,libseccomp)
84 ("openssl" ,openssl)
85 ("xz" ,xz)
86 ("zlib" ,zlib)
87 ("zstd" ,zstd "lib")))
88 (home-page "https://www.torproject.org/")
89 (synopsis "Anonymous network router to improve privacy on the Internet")
90 (description
91 "Tor protects you by bouncing your communications around a distributed
92 network of relays run by volunteers all around the world: it prevents
93 somebody watching your Internet connection from learning what sites you
94 visit, and it prevents the sites you visit from learning your physical
95 location. Tor works with many of your existing applications, including
96 web browsers, instant messaging clients, remote login, and other
97 applications based on the TCP protocol.
98
99 This package is the full featured @code{tor} which is needed for running
100 relays, bridges or directory authorities. If you just want to access the Tor
101 network or to setup an onion service you may install @code{tor-client}
102 instead.")
103 (license license:bsd-3)))
104
105 (define-public tor-client
106 (package
107 (inherit tor)
108 (name "tor-client")
109 (arguments
110 (substitute-keyword-arguments (package-arguments tor)
111 ((#:configure-flags flags)
112 (append flags
113 '("--disable-module-relay")))))
114 (synopsis "Client to the anonymous Tor network")
115 (description
116 "Tor protects you by bouncing your communications around a distributed
117 network of relays run by volunteers all around the world: it prevents
118 somebody watching your Internet connection from learning what sites you
119 visit, and it prevents the sites you visit from learning your physical
120 location. Tor works with many of your existing applications, including
121 web browsers, instant messaging clients, remote login, and other
122 applications based on the TCP protocol.
123
124 To @code{torify} applications (to take measures to ensure that an application,
125 which has not been designed for use with Tor such as ssh, will use only Tor for
126 internet connectivity, and also ensures that there are no leaks from DNS, UDP or
127 the application layer) you need to install @code{torsocks}.
128
129 This package only provides a client to the Tor Network.")))
130
131 (define-public torsocks
132 (package
133 (name "torsocks")
134 (version "2.3.0")
135 (source (origin
136 (method url-fetch)
137 (uri (string-append "https://people.torproject.org/~dgoulet/"
138 "torsocks/torsocks-" version ".tar.xz"))
139 (sha256
140 (base32
141 "08inrkap29gikb6sdmb58z43hw4abwrfw7ny40c4xzdkss0vkwdr"))))
142 (build-system gnu-build-system)
143 (inputs
144 `(("libcap" ,libcap)))
145 (arguments
146 `(#:phases (modify-phases %standard-phases
147 (add-after 'build 'absolutize
148 (lambda* (#:key inputs #:allow-other-keys)
149 (substitute* "src/bin/torsocks"
150 (("getcap=.*")
151 (string-append "getcap=" (which "getcap") "\n")))
152 #t)))))
153 (home-page "https://www.torproject.org/")
154 (synopsis "Use socks-friendly applications with Tor")
155 (description
156 "Torsocks allows you to use most socks-friendly applications in a safe
157 way with Tor. It ensures that DNS requests are handled safely and explicitly
158 rejects UDP traffic from the application you're using.")
159
160 ;; All the files explicitly say "version 2 only".
161 (license license:gpl2)))
162
163 (define-public privoxy
164 (package
165 (name "privoxy")
166 (version "3.0.32")
167 (source (origin
168 (method url-fetch)
169 (uri (string-append "mirror://sourceforge/ijbswa/Sources/"
170 version "%20%28stable%29/privoxy-"
171 version "-stable-src.tar.gz"))
172 (sha256
173 (base32
174 "1mzfxwnvnf1jkvfcrsivm6mjwdzjrc3h89qziz0mwi32ih0f87f6"))))
175 (build-system gnu-build-system)
176 (arguments
177 '(;; The default 'sysconfdir' is $out/etc; change that to
178 ;; $out/etc/privoxy.
179 #:configure-flags (list (string-append "--sysconfdir="
180 (assoc-ref %outputs "out")
181 "/etc/privoxy")
182 "--localstatedir=/var"
183 "--with-brotli"
184 "--with-openssl")
185 #:tests? #f ; no test suite
186 #:phases
187 (modify-phases %standard-phases
188 (add-after 'unpack 'patch-default-logging
189 (lambda _
190 (with-fluids ((%default-port-encoding "ISO-8859-1"))
191 ;; Do not create /var/run nor /var/log/privoxy/logfile.
192 (substitute* "GNUmakefile.in"
193 (("(logfile \\|\\| exit )1" _ match)
194 (string-append match "0"))
195 (("(\\$\\(DESTDIR\\)\\$\\(SHARE_DEST\\)) \\\\" _ match)
196 match)
197 ((".*\\$\\(LOG_DEST\\) \\$\\(DESTDIR\\)\\$\\(PID_DEST\\).*")
198 ""))
199 ;; Disable logging in the default configuration to allow for
200 ;; non-root users using it as is.
201 (substitute* "config"
202 (("^logdir") "#logdir")
203 (("^logfile") "#logfile")))
204 #t)))))
205 (inputs
206 `(("brotli" ,brotli)
207 ("openssl" ,openssl)
208 ("pcre" ,pcre)
209 ("w3m" ,w3m)
210 ("zlib" ,zlib)))
211 (native-inputs
212 `(("autoconf" ,autoconf)
213 ("automake" ,automake)))
214 (home-page "https://www.privoxy.org")
215 (synopsis "Web proxy with advanced filtering capabilities for enhancing privacy")
216 (description
217 "Privoxy is a non-caching web proxy with advanced filtering capabilities
218 for enhancing privacy, modifying web page data and HTTP headers, controlling
219 access, and removing ads and other obnoxious Internet junk. Privoxy has a
220 flexible configuration and can be customized to suit individual needs and
221 tastes. It has application for both stand-alone systems and multi-user
222 networks.")
223 (license license:gpl2+)))
224
225 (define-public onionshare-cli
226 (package
227 (name "onionshare-cli")
228 (version "2.3.1")
229 (source
230 (origin
231 (method git-fetch)
232 (uri (git-reference
233 (url "https://github.com/micahflee/onionshare")
234 (commit (string-append "v" version))))
235 (file-name (git-file-name name version))
236 (sha256
237 (base32 "1llvnvb676s2cs6a4y7isxdj75ddfvskw1p93v5m35vsw7f72kqz"))))
238 (build-system python-build-system)
239 (native-inputs
240 `(("python-pytest" ,python-pytest)))
241 (inputs
242 ;; TODO: obfs4proxy
243 `(("python-click" ,python-click)
244 ("python-eventlet" ,python-eventlet)
245 ("python-flask" ,python-flask)
246 ("python-flask-httpauth" ,python-flask-httpauth)
247 ("python-flask-socketio" ,python-flask-socketio)
248 ("python-psutil" ,python-psutil)
249 ("python-pycryptodome" ,python-pycryptodome)
250 ("python-pysocks" ,python-pysocks)
251 ("python-requests" ,python-requests)
252 ("python-stem" ,python-stem)
253 ("python-unidecode" ,python-unidecode)
254 ("python-urllib3" ,python-urllib3)
255 ("tor" ,tor)))
256 (arguments
257 `(#:phases
258 (modify-phases %standard-phases
259 (add-after 'unpack 'bake-tor
260 (lambda* (#:key inputs #:allow-other-keys)
261 (substitute* (list "cli/onionshare_cli/common.py"
262 "desktop/src/onionshare/gui_common.py")
263 (("shutil\\.which\\(\\\"tor\\\"\\)")
264 (string-append "\"" (which "tor") "\"")))
265 #t))
266 (add-before 'build 'change-directory
267 (lambda _ (chdir "cli") #t))
268 (replace 'check
269 (lambda _
270 (setenv "HOME" "/tmp")
271 ;; Greendns is not needed for testing, and if eventlet tries to
272 ;; load it, an OSError is thrown when getprotobyname is called.
273 ;; Thankfully there is an environment variable to disable the
274 ;; greendns import, so use it:
275 (setenv "EVENTLET_NO_GREENDNS" "yes")
276 (invoke "pytest" "-v" "./tests"))))))
277 (home-page "https://onionshare.org/")
278 (synopsis "Securely and anonymously share files")
279 (description "OnionShare lets you securely and anonymously share files,
280 host websites, and chat with friends using the Tor network.
281
282 This package contains @code{onionshare-cli}, a command-line interface to
283 OnionShare.")
284 ;; Bundled, minified jquery and socket.io are expat licensed.
285 (license (list license:gpl3+ license:expat))))
286
287 (define-public onionshare
288 (package (inherit onionshare-cli)
289 (name "onionshare")
290 (arguments
291 (substitute-keyword-arguments (package-arguments onionshare-cli)
292 ((#:phases phases)
293 `(modify-phases ,phases
294 (replace 'change-directory
295 (lambda _ (chdir "desktop/src") #t))
296 (add-after 'unpack 'patch-tests
297 (lambda _
298 ;; Disable tests that require starting servers, which will hang
299 ;; during build:
300 ;; - test_autostart_and_autostop_timer_mismatch
301 ;; - test_autostart_timer
302 ;; - test_autostart_timer_too_short
303 ;; - test_autostop_timer_too_short
304 (substitute* "desktop/tests/test_gui_share.py"
305 (("( *)def test_autost(art|op)_(timer(_too_short)?|and_[^(]*)\\(" & >)
306 (string-append > "@pytest.mark.skip\n" &)))
307 ;; - test_13_quit_with_server_started_should_warn
308 (substitute* "desktop/tests/test_gui_tabs.py"
309 (("( *)def test_13" & >)
310 (string-append > "@pytest.mark.skip\n" &)))
311 ;; Remove multiline load-path adjustment, so that onionshare-cli
312 ;; modules are loaded from input
313 (use-modules (ice-9 regex)
314 (ice-9 rdelim))
315 (with-atomic-file-replacement "desktop/tests/conftest.py"
316 (let ((start-rx (make-regexp "^# Allow importing")))
317 (lambda (in out)
318 (let loop ()
319 (let ((line (read-line in 'concat)))
320 (if (regexp-exec start-rx line)
321 (begin ; slurp until closing paren
322 (let slurp ()
323 (let ((line (read-line in 'concat)))
324 (if (string=? line ")\n")
325 (dump-port in out) ; done
326 (slurp)))))
327 (begin
328 (display line out)
329 (loop))))))))))
330 (replace 'check
331 (lambda _
332 ;; Some tests need a writable homedir:
333 (setenv "HOME" "/tmp")
334 ;; Ensure installed modules can be found:
335 (setenv "PYTHONPATH"
336 (string-append %output "/lib/python"
337 ,(version-major+minor (package-version python))
338 "/site-packages:"
339 (getenv "PYTHONPATH")))
340 ;; Avoid `getprotobyname` issues:
341 (setenv "EVENTLET_NO_GREENDNS" "yes")
342 ;; Make Qt render "offscreen":
343 (setenv "QT_QPA_PLATFORM" "offscreen")
344 ;; Must be run from "desktop" dir:
345 (chdir "..")
346 (invoke "./tests/run.sh")))
347 (add-after 'install 'install-data
348 (lambda* (#:key outputs #:allow-other-keys)
349 (let* ((out (assoc-ref outputs "out"))
350 (share (string-append out "/share")))
351 (install-file "org.onionshare.OnionShare.svg"
352 (string-append share "/icons/hicolor/scalable/apps"))
353 (install-file "org.onionshare.OnionShare.desktop"
354 (string-append share "/applications"))
355 #t)))))))
356 (native-inputs
357 `(("python-pytest" ,python-pytest)))
358 (inputs
359 ;; TODO: obfs4proxy
360 `(("onionshare-cli" ,onionshare-cli)
361 ("python-shiboken-2" ,python-shiboken-2)
362 ("python-pyside-2" ,python-pyside-2)
363 ("python-qrcode" ,python-qrcode)
364 ;; The desktop client uses onionshare-cli like a python module. But
365 ;; propagating onionshare-cli's inputs is not great, since a user would
366 ;; not expect to have those installed when using onionshare-cli as a
367 ;; standalone utility. So add onionshare-cli's inputs here.
368 ,@(package-inputs onionshare-cli)))
369 (description "OnionShare lets you securely and anonymously share files,
370 host websites, and chat with friends using the Tor network.")))
371
372 (define-public nyx
373 (package
374 (name "nyx")
375 (version "2.1.0")
376 (source
377 (origin
378 (method url-fetch)
379 (uri (pypi-uri name version))
380 (sha256
381 (base32
382 "02rrlllz2ci6i6cs3iddyfns7ang9a54jrlygd2jw1f9s6418ll8"))))
383 (build-system python-build-system)
384 (inputs
385 `(("python-stem" ,python-stem)))
386 (arguments
387 `(#:phases
388 (modify-phases %standard-phases
389 (add-after 'install 'install-man-page
390 (lambda* (#:key outputs #:allow-other-keys)
391 (let* ((out (assoc-ref outputs "out"))
392 (man (string-append out "/share/man")))
393 (install-file "nyx.1" (string-append man "/man1"))
394 #t)))
395 (add-after 'install 'install-sample-configuration
396 (lambda* (#:key outputs #:allow-other-keys)
397 (let* ((out (assoc-ref outputs "out"))
398 (doc (string-append out "/share/doc/" ,name "-" ,version)))
399 (install-file "web/nyxrc.sample" doc)
400 #t))))
401 ;; XXX The tests seem to require more of a real terminal than the build
402 ;; environment provides:
403 ;; _curses.error: setupterm: could not find terminal
404 ;; With TERM=linux, the tests try to move the cursor and still fail:
405 ;; _curses.error: cbreak() returned ERR
406 #:tests? #f))
407 (home-page "https://nyx.torproject.org/")
408 (synopsis "Tor relay status monitor")
409 (description
410 "Nyx monitors the performance of relays participating in the
411 @uref{https://www.torproject.org/, Tor anonymity network}. It displays this
412 information visually and in real time, using a curses-based terminal interface.
413 This makes Nyx well-suited for remote shell connections and servers without a
414 graphical display. It's like @command{top} for Tor, providing detailed
415 statistics and status reports on:
416
417 @enumerate
418 @item connections (with IP address, hostname, fingerprint, and consensus data),
419 @item bandwidth, processor, and memory usage,
420 @item the relay's current configuration,
421 @item logged events,
422 @item and much more.
423 @end enumerate
424
425 Potential client and exit connections are scrubbed of sensitive information.")
426 (license license:gpl3+)))