gnu: onionshare: Replace pycrypto by pycryptodome.
[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 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
6 ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2017, 2018, 2019 Eric Bavier <bavier@member.fsf.org>
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.4.6")
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 "1p0zpqmbskygx0wmiijhprg8r45n2wqbbjl7kv4gbb83b0alq5az"))))
65 (build-system gnu-build-system)
66 (arguments
67 `(#:configure-flags
68 (list "--enable-lzma"
69 "--enable-zstd")))
70 (native-inputs
71 `(("pkg-config" ,pkg-config)
72 ("python" ,python))) ; for tests
73 (inputs
74 `(("libevent" ,libevent)
75 ("libseccomp" ,libseccomp)
76 ("openssl" ,openssl)
77 ("xz" ,xz)
78 ("zlib" ,zlib)
79 ("zstd" ,zstd "lib")))
80 (home-page "https://www.torproject.org/")
81 (synopsis "Anonymous network router to improve privacy on the Internet")
82 (description
83 "Tor protects you by bouncing your communications around a distributed
84 network of relays run by volunteers all around the world: it prevents
85 somebody watching your Internet connection from learning what sites you
86 visit, and it prevents the sites you visit from learning your physical
87 location. Tor works with many of your existing applications, including
88 web browsers, instant messaging clients, remote login, and other
89 applications based on the TCP protocol.
90
91 This package is the full featured @code{tor} which is needed for running
92 relays, bridges or directory authorities. If you just want to access the Tor
93 network or to setup an onion service you may install @code{tor-client}
94 instead.")
95 (license license:bsd-3)))
96
97 (define-public tor-client
98 (package
99 (inherit tor)
100 (name "tor-client")
101 (arguments
102 (substitute-keyword-arguments (package-arguments tor)
103 ((#:configure-flags flags)
104 (append flags
105 '("--disable-module-relay")))))
106 (synopsis "Client to the anonymous Tor network")
107 (description
108 "Tor protects you by bouncing your communications around a distributed
109 network of relays run by volunteers all around the world: it prevents
110 somebody watching your Internet connection from learning what sites you
111 visit, and it prevents the sites you visit from learning your physical
112 location. Tor works with many of your existing applications, including
113 web browsers, instant messaging clients, remote login, and other
114 applications based on the TCP protocol.
115
116 To @code{torify} applications (to take measures to ensure that an application,
117 which has not been designed for use with Tor such as ssh, will use only Tor for
118 internet connectivity, and also ensures that there are no leaks from DNS, UDP or
119 the application layer) you need to install @code{torsocks}.
120
121 This package only provides a client to the Tor Network.")))
122
123 (define-public torsocks
124 (package
125 (name "torsocks")
126 (version "2.3.0")
127 (source (origin
128 (method url-fetch)
129 (uri (string-append "https://people.torproject.org/~dgoulet/"
130 "torsocks/torsocks-" version ".tar.xz"))
131 (sha256
132 (base32
133 "08inrkap29gikb6sdmb58z43hw4abwrfw7ny40c4xzdkss0vkwdr"))))
134 (build-system gnu-build-system)
135 (inputs
136 `(("libcap" ,libcap)))
137 (arguments
138 `(#:phases (modify-phases %standard-phases
139 (add-after 'build 'absolutize
140 (lambda* (#:key inputs #:allow-other-keys)
141 (substitute* "src/bin/torsocks"
142 (("getcap=.*")
143 (string-append "getcap=" (which "getcap") "\n")))
144 #t)))))
145 (home-page "https://www.torproject.org/")
146 (synopsis "Use socks-friendly applications with Tor")
147 (description
148 "Torsocks allows you to use most socks-friendly applications in a safe
149 way with Tor. It ensures that DNS requests are handled safely and explicitly
150 rejects UDP traffic from the application you're using.")
151
152 ;; All the files explicitly say "version 2 only".
153 (license license:gpl2)))
154
155 (define-public privoxy
156 (package
157 (name "privoxy")
158 (version "3.0.29")
159 (source (origin
160 (method url-fetch)
161 (uri (string-append "mirror://sourceforge/ijbswa/Sources/"
162 version "%20%28stable%29/privoxy-"
163 version "-stable-src.tar.gz"))
164 (sha256
165 (base32
166 "17a8fbdyb0ixc0wwq68fg7xn7l6n7jq67njpq93psmxgzng0dii5"))))
167 (build-system gnu-build-system)
168 (arguments
169 '(;; The default 'sysconfdir' is $out/etc; change that to
170 ;; $out/etc/privoxy.
171 #:configure-flags (list (string-append "--sysconfdir="
172 (assoc-ref %outputs "out")
173 "/etc/privoxy")
174 "--localstatedir=/var"
175 "--with-brotli"
176 "--with-openssl")
177 #:tests? #f ; no test suite
178 #:phases
179 (modify-phases %standard-phases
180 (add-after 'unpack 'patch-default-logging
181 (lambda _
182 (with-fluids ((%default-port-encoding "ISO-8859-1"))
183 ;; Do not create /var/run nor /var/log/privoxy/logfile.
184 (substitute* "GNUmakefile.in"
185 (("(logfile \\|\\| exit )1" _ match)
186 (string-append match "0"))
187 (("(\\$\\(DESTDIR\\)\\$\\(SHARE_DEST\\)) \\\\" _ match)
188 match)
189 ((".*\\$\\(LOG_DEST\\) \\$\\(DESTDIR\\)\\$\\(PID_DEST\\).*")
190 ""))
191 ;; Disable logging in the default configuration to allow for
192 ;; non-root users using it as is.
193 (substitute* "config"
194 (("^logdir") "#logdir")
195 (("^logfile") "#logfile")))
196 #t)))))
197 (inputs
198 `(("brotli" ,brotli)
199 ("openssl" ,openssl)
200 ("pcre" ,pcre)
201 ("w3m" ,w3m)
202 ("zlib" ,zlib)))
203 (native-inputs
204 `(("autoconf" ,autoconf)
205 ("automake" ,automake)))
206 (home-page "https://www.privoxy.org")
207 (synopsis "Web proxy with advanced filtering capabilities for enhancing privacy")
208 (description
209 "Privoxy is a non-caching web proxy with advanced filtering capabilities
210 for enhancing privacy, modifying web page data and HTTP headers, controlling
211 access, and removing ads and other obnoxious Internet junk. Privoxy has a
212 flexible configuration and can be customized to suit individual needs and
213 tastes. It has application for both stand-alone systems and multi-user
214 networks.")
215 (license license:gpl2+)))
216
217 (define-public onionshare
218 (package
219 (name "onionshare")
220 (version "2.2")
221 (source
222 (origin
223 (method git-fetch)
224 (uri (git-reference
225 (url "https://github.com/micahflee/onionshare")
226 (commit (string-append "v" version))))
227 (file-name (git-file-name name version))
228 (sha256
229 (base32 "0m8ygxcyp3nfzzhxs2dfnpqwh1vx0aws44lszpnnczz4fks3a5j4"))))
230 (build-system python-build-system)
231 (arguments
232 `(#:phases
233 (modify-phases %standard-phases
234 (add-after 'unpack 'fix-install-path
235 (lambda* (#:key outputs #:allow-other-keys)
236 (let* ((out (assoc-ref outputs "out"))
237 (onionshare (string-append out "/share/onionshare")))
238 (substitute* '("setup.py" "onionshare/common.py")
239 (("sys.prefix,") (string-append "'" out "',")))
240 (substitute* "setup.py"
241 ;; For the nautilus plugin.
242 (("/usr/share/nautilus") "share/nautilus"))
243 (substitute* "install/org.onionshare.OnionShare.desktop"
244 (("/usr") out))
245 #t)))
246 (delete 'check)
247 (add-before 'strip 'check
248 ;; After all the patching we run the tests after installing.
249 (lambda _
250 (setenv "HOME" "/tmp") ; Some tests need a writable homedir
251 (invoke "pytest" "tests/")
252 #t)))))
253 (native-inputs
254 `(("python-pytest" ,python-pytest)))
255 (inputs
256 `(("python-pycryptodome" ,python-pycryptodome)
257 ("python-flask" ,python-flask)
258 ("python-flask-httpauth" ,python-flask-httpauth)
259 ("python-nautilus" ,python-nautilus)
260 ("python-sip" ,python-sip)
261 ("python-stem" ,python-stem)
262 ("python-pysocks" ,python-pysocks)
263 ("python-pyqt" ,python-pyqt)))
264 (home-page "https://onionshare.org/")
265 (synopsis "Securely and anonymously share files")
266 (description "OnionShare is a tool for securely and anonymously sending
267 and receiving files using Tor onion services. It works by starting a web
268 server directly on your computer and making it accessible as an unguessable
269 Tor web address that others can load in a Tor-enabled web browser to download
270 files from you, or upload files to you. It doesn't require setting up a
271 separate server, using a third party file-sharing service, or even logging
272 into an account.")
273 ;; Bundled, minified jquery is expat licensed.
274 (license (list license:gpl3+ license:expat))))
275
276 (define-public nyx
277 (package
278 (name "nyx")
279 (version "2.1.0")
280 (source
281 (origin
282 (method url-fetch)
283 (uri (pypi-uri name version))
284 (sha256
285 (base32
286 "02rrlllz2ci6i6cs3iddyfns7ang9a54jrlygd2jw1f9s6418ll8"))))
287 (build-system python-build-system)
288 (inputs
289 `(("python-stem" ,python-stem)))
290 (arguments
291 `(#:phases
292 (modify-phases %standard-phases
293 (add-after 'install 'install-man-page
294 (lambda* (#:key outputs #:allow-other-keys)
295 (let* ((out (assoc-ref outputs "out"))
296 (man (string-append out "/share/man")))
297 (install-file "nyx.1" (string-append man "/man1"))
298 #t)))
299 (add-after 'install 'install-sample-configuration
300 (lambda* (#:key outputs #:allow-other-keys)
301 (let* ((out (assoc-ref outputs "out"))
302 (doc (string-append out "/share/doc/" ,name "-" ,version)))
303 (install-file "web/nyxrc.sample" doc)
304 #t))))
305 ;; XXX The tests seem to require more of a real terminal than the build
306 ;; environment provides:
307 ;; _curses.error: setupterm: could not find terminal
308 ;; With TERM=linux, the tests try to move the cursor and still fail:
309 ;; _curses.error: cbreak() returned ERR
310 #:tests? #f))
311 (home-page "https://nyx.torproject.org/")
312 (synopsis "Tor relay status monitor")
313 (description
314 "Nyx monitors the performance of relays participating in the
315 @uref{https://www.torproject.org/, Tor anonymity network}. It displays this
316 information visually and in real time, using a curses-based terminal interface.
317 This makes Nyx well-suited for remote shell connections and servers without a
318 graphical display. It's like @command{top} for Tor, providing detailed
319 statistics and status reports on:
320
321 @enumerate
322 @item connections (with IP address, hostname, fingerprint, and consensus data),
323 @item bandwidth, processor, and memory usage,
324 @item the relay's current configuration,
325 @item logged events,
326 @item and much more.
327 @end enumerate
328
329 Potential client and exit connections are scrubbed of sensitive information.")
330 (license license:gpl3+)))