<commit_before>;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause

(uiop:define-package :nyxt/proxy-mode
  (:use :common-lisp :trivia :nyxt)
  (:shadow #:proxy) ; Because of exported slot of the same below.
  (:documentation "Proxy mode can be used to do all the networking (optionally
including downloads) via a proxy server.
It can also be configured to forward all the networking through local services
like Tor."))
(in-package :nyxt/proxy-mode)

(define-mode proxy-mode ()
  "Enable forwarding of all network requests to a specific host.
As for every mode, it only applies to the current buffer.  If you want to enable
a proxy for all buffers, add it to the list of default modes.

Example to use Tor as a proxy both for browsing and downloading:

\(define-configuration nyxt/proxy-mode:proxy-mode
  ((nyxt/proxy-mode:proxy (make-instance 'proxy
                                         :url (quri:uri \"socks5://localhost:9050\")
                                         :allowlist '(\"localhost\" \"localhost:8080\")
                                         :proxied-downloads-p t))))

\(define-configuration buffer
  ((default-modes (append '(proxy-mode) %slot-default%))))"
  ((proxy (make-instance 'nyxt:proxy
                         :url (quri:uri "socks5://localhost:9050")
                         :allowlist '("localhost" "localhost:8080")
                         :proxied-downloads-p t)
          :type nyxt:proxy)
   (destructor
    (lambda (mode)
      (setf (nyxt:proxy (buffer mode)) nil)))
   (constructor
    (lambda (mode)
      (setf (nyxt:proxy (buffer mode)) (proxy mode))
      (echo "Buffer ~a proxy set to ~a, allowlisting ~a."
            (id (buffer mode))
            (render-url (url (proxy mode)))
            (allowlist (proxy mode)))))))<commit_msg>proxy-mode: Use web-buffer for an example of proxy-setting.<commit_after>;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause

(uiop:define-package :nyxt/proxy-mode
  (:use :common-lisp :trivia :nyxt)
  (:shadow #:proxy) ; Because of exported slot of the same below.
  (:documentation "Proxy mode can be used to do all the networking (optionally
including downloads) via a proxy server.
It can also be configured to forward all the networking through local services
like Tor."))
(in-package :nyxt/proxy-mode)

(define-mode proxy-mode ()
  "Enable forwarding of all network requests to a specific host.
As for every mode, it only applies to the current buffer.  If you want to enable
a proxy for all buffers, add it to the list of default modes.

Example to use Tor as a proxy both for browsing and downloading:

\(define-configuration nyxt/proxy-mode:proxy-mode
  ((nyxt/proxy-mode:proxy (make-instance 'proxy
                                         :url (quri:uri \"socks5://localhost:9050\")
                                         :allowlist '(\"localhost\" \"localhost:8080\")
                                         :proxied-downloads-p t))))

\(define-configuration web-buffer
  ((default-modes (append '(proxy-mode) %slot-default%))))"
  ((proxy (make-instance 'nyxt:proxy
                         :url (quri:uri "socks5://localhost:9050")
                         :allowlist '("localhost" "localhost:8080")
                         :proxied-downloads-p t)
          :type nyxt:proxy)
   (destructor
    (lambda (mode)
      (setf (nyxt:proxy (buffer mode)) nil)))
   (constructor
    (lambda (mode)
      (setf (nyxt:proxy (buffer mode)) (proxy mode))
      (echo "Buffer ~a proxy set to ~a, allowlisting ~a."
            (id (buffer mode))
            (render-url (url (proxy mode)))
            (allowlist (proxy mode)))))))
{'fraction_non_alphanumeric': 0.11945945945945946, 'fraction_numerical': 0.01027027027027027, 'mean_word_length': 2.4686035613870665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1742284', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1016, 'n_words': 364}