blob: 9ed7d5ffd790d018580f9efedb1e1c9592b96f25 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
;;; tor.el -- tor utilities -*- lexical-binding: t -*-
;; Copyright (C) 2025 Free Software Foundation, Inc.
;; Author: Yuchen Pei <id@ypei.org>
;; Package-Requires: ((emacs "30.1"))
;; This file is part of dotted.
;; dotted is free software: you can redistribute it and/or modify it under
;; the terms of the GNU Affero General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; dotted is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
;; Public License for more details.
;; You should have received a copy of the GNU Affero General Public
;; License along with dotted. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; tor utilities.
;;; Code:
(defun my-call-process-with-torsocks (no-tor program
&optional infile destination display
&rest args)
(if no-tor
(apply 'call-process
(append (list program infile destination display) args))
(apply 'call-process
(append (list "torsocks" infile destination display program) args))))
(defun my-start-process-with-torsocks (no-tor name buffer program
&rest program-args)
(if no-tor
(apply 'start-process (append (list name buffer program) program-args))
(apply 'start-process
(append (list name buffer "torsocks" program) program-args))))
(defun tor-parse-check-dom (dom)
(let ((content (dom-by-class dom "content")))
(format "%s\n%s"
(string-trim (dom-text (dom-by-tag content 'h1)))
(string-trim (dom-texts (car (dom-by-tag content 'p)))))))
(defun tor-check (&optional no-tor)
(require 'my-wget)
(tor-parse-check-dom (my-wget-dom "https://check.torproject.org/" no-tor)))
(provide 'tor)
;;; tor.el ends here
|