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>
14 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
60 (uri (string-append "https://dist.torproject.org/tor-"
64 "1yacd7h7wg8n6wwrjmx2g9xjj24kj08j5sai9g7fm4cp1m73avbv"))
65 (patches (search-patches "tor-fix-build-with-gcc-7.patch"))))
66 (build-system gnu-build-system)
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.
76 (setenv "TOR_DISABLE_PRACTRACKER" "set")
79 `(("pkg-config" ,pkg-config)
80 ("python" ,python))) ; for tests
82 `(("libevent" ,libevent)
83 ("libseccomp" ,libseccomp)
87 ("zstd" ,zstd "lib")))
88 (home-page "https://www.torproject.org/")
89 (synopsis "Anonymous network router to improve privacy on the Internet")
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.
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}
103 (license license:bsd-3)))
105 (define-public tor-client
110 (substitute-keyword-arguments (package-arguments tor)
111 ((#:configure-flags flags)
113 '("--disable-module-relay")))))
114 (synopsis "Client to the anonymous Tor network")
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.
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}.
129 This package only provides a client to the Tor Network.")))
131 (define-public torsocks
137 (uri (string-append "https://people.torproject.org/~dgoulet/"
138 "torsocks/torsocks-" version ".tar.xz"))
141 "08inrkap29gikb6sdmb58z43hw4abwrfw7ny40c4xzdkss0vkwdr"))))
142 (build-system gnu-build-system)
144 `(("libcap" ,libcap)))
146 `(#:phases (modify-phases %standard-phases
147 (add-after 'build 'absolutize
148 (lambda* (#:key inputs #:allow-other-keys)
149 (substitute* "src/bin/torsocks"
151 (string-append "getcap=" (which "getcap") "\n")))
153 (home-page "https://www.torproject.org/")
154 (synopsis "Use socks-friendly applications with Tor")
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.")
160 ;; All the files explicitly say "version 2 only".
161 (license license:gpl2)))
163 (define-public privoxy
169 (uri (string-append "mirror://sourceforge/ijbswa/Sources/"
170 version "%20%28stable%29/privoxy-"
171 version "-stable-src.tar.gz"))
174 "1mzfxwnvnf1jkvfcrsivm6mjwdzjrc3h89qziz0mwi32ih0f87f6"))))
175 (build-system gnu-build-system)
177 '(;; The default 'sysconfdir' is $out/etc; change that to
179 #:configure-flags (list (string-append "--sysconfdir="
180 (assoc-ref %outputs "out")
182 "--localstatedir=/var"
185 #:tests? #f ; no test suite
187 (modify-phases %standard-phases
188 (add-after 'unpack 'patch-default-logging
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)
197 ((".*\\$\\(LOG_DEST\\) \\$\\(DESTDIR\\)\\$\\(PID_DEST\\).*")
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")))
212 `(("autoconf" ,autoconf)
213 ("automake" ,automake)))
214 (home-page "https://www.privoxy.org")
215 (synopsis "Web proxy with advanced filtering capabilities for enhancing privacy")
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
223 (license license:gpl2+)))
225 (define-public onionshare-cli
227 (name "onionshare-cli")
233 (url "https://github.com/micahflee/onionshare")
234 (commit (string-append "v" version))))
235 (file-name (git-file-name name version))
237 (base32 "1llvnvb676s2cs6a4y7isxdj75ddfvskw1p93v5m35vsw7f72kqz"))))
238 (build-system python-build-system)
240 `(("python-pytest" ,python-pytest)))
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)
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") "\"")))
266 (add-before 'build 'change-directory
267 (lambda _ (chdir "cli") #t))
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.
282 This package contains @code{onionshare-cli}, a command-line interface to
284 ;; Bundled, minified jquery and socket.io are expat licensed.
285 (license (list license:gpl3+ license:expat))))
287 (define-public onionshare
288 (package (inherit onionshare-cli)
291 (substitute-keyword-arguments (package-arguments onionshare-cli)
293 `(modify-phases ,phases
294 (replace 'change-directory
295 (lambda _ (chdir "desktop/src") #t))
296 (add-after 'unpack 'patch-tests
298 ;; Disable tests that require starting servers, which will hang
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)
315 (with-atomic-file-replacement "desktop/tests/conftest.py"
316 (let ((start-rx (make-regexp "^# Allow importing")))
319 (let ((line (read-line in 'concat)))
320 (if (regexp-exec start-rx line)
321 (begin ; slurp until closing paren
323 (let ((line (read-line in 'concat)))
324 (if (string=? line ")\n")
325 (dump-port in out) ; done
332 ;; Some tests need a writable homedir:
333 (setenv "HOME" "/tmp")
334 ;; Ensure installed modules can be found:
336 (string-append %output "/lib/python"
337 ,(version-major+minor (package-version python))
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:
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"))
357 `(("python-pytest" ,python-pytest)))
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.")))
379 (uri (pypi-uri name version))
382 "02rrlllz2ci6i6cs3iddyfns7ang9a54jrlygd2jw1f9s6418ll8"))))
383 (build-system python-build-system)
385 `(("python-stem" ,python-stem)))
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"))
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)
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
407 (home-page "https://nyx.torproject.org/")
408 (synopsis "Tor relay status monitor")
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:
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,
425 Potential client and exit connections are scrubbed of sensitive information.")
426 (license license:gpl3+)))