;;; tor.el -- tor utilities -*- lexical-binding: t -*- ;; Copyright (C) 2025 Free Software Foundation, Inc. ;; Author: Yuchen Pei ;; 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 . ;;; 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