mirror of
https://codeberg.org/cage/tinmop/
synced 2025-01-20 03:08:54 +01:00
- refactoring TOFU error recovery.
This commit is contained in:
parent
4dae983197
commit
f39e396762
@ -663,23 +663,13 @@
|
||||
(push-url-to-history specials:*message-window* actual-iri)
|
||||
(gemini-client:request-dispatch url gemini-client::dispatch-table)))))
|
||||
(gemini-client:gemini-tofu-error (e)
|
||||
(let ((host (gemini-client:host e)))
|
||||
(flet ((on-input-complete (maybe-accepted)
|
||||
(when (ui::boolean-input-accepted-p maybe-accepted)
|
||||
(db-utils:with-ready-database (:connect nil)
|
||||
(db:tofu-delete host)
|
||||
(request url
|
||||
:enqueue enqueue
|
||||
:certificate certificate
|
||||
:certificate-key certificate-key
|
||||
:do-nothing-if-exists-in-db
|
||||
do-nothing-if-exists-in-db)))))
|
||||
(ui:ask-string-input #'on-input-complete
|
||||
:prompt
|
||||
(format nil
|
||||
(_ "Host ~s signature changed! This is a potential security risk! Ignore this warning? [y/N] ")
|
||||
host)
|
||||
:priority program-events:+standard-event-priority+))))
|
||||
(gemini-client:with-ask-input-on-tofu-error (e)
|
||||
(request url
|
||||
:enqueue enqueue
|
||||
:certificate certificate
|
||||
:certificate-key certificate-key
|
||||
:do-nothing-if-exists-in-db
|
||||
do-nothing-if-exists-in-db)))
|
||||
(conditions:not-implemented-error (e)
|
||||
(ui:notify (format nil (_ "Error: ~a") e)
|
||||
:as-error t))
|
||||
|
@ -523,3 +523,18 @@ TODO: Add client certificate."
|
||||
:ignore-warning t)
|
||||
(request-dispatch url dispatch-table))
|
||||
(fs:slurp-file url :convert-to-string nil))))
|
||||
|
||||
(defmacro with-ask-input-on-tofu-error ((condition) &body body)
|
||||
(with-gensyms (host)
|
||||
`(let ((,host (gemini-client:host ,condition)))
|
||||
(flet ((on-input-complete (maybe-accepted)
|
||||
(when (ui::boolean-input-accepted-p maybe-accepted)
|
||||
(db-utils:with-ready-database (:connect nil)
|
||||
(db:tofu-delete ,host)
|
||||
,@body))))
|
||||
(ui:ask-string-input #'on-input-complete
|
||||
:prompt
|
||||
(format nil
|
||||
(_ "Host ~s signature changed! This is a potential security risk! Ignore this warning? [y/N] ")
|
||||
,host)
|
||||
:priority program-events:+standard-event-priority+)))))
|
||||
|
@ -147,7 +147,8 @@
|
||||
:with-request-dispatch-table
|
||||
:fetch-cached-certificate
|
||||
:build-redirect-iri
|
||||
:slurp-gemini-url))
|
||||
:slurp-gemini-url
|
||||
:with-ask-input-on-tofu-error))
|
||||
|
||||
(defpackage :gemini-subscription
|
||||
(:use
|
||||
|
@ -86,15 +86,5 @@ be subscribed before (see: 'gemini-subscription:subcribe'"
|
||||
date
|
||||
nil))))))
|
||||
(gemini-client:gemini-tofu-error (e)
|
||||
(let ((host (gemini-client:host e)))
|
||||
(flet ((on-input-complete (maybe-accepted)
|
||||
(when (ui::boolean-input-accepted-p maybe-accepted)
|
||||
(db-utils:with-ready-database (:connect nil)
|
||||
(db:tofu-delete host)
|
||||
(refresh url)))))
|
||||
(ui:ask-string-input #'on-input-complete
|
||||
:prompt
|
||||
(format nil
|
||||
(_ "Host ~s signature changed! This is a potential security risk! Ignore this warning? [y/N] ")
|
||||
host)
|
||||
:priority program-events:+standard-event-priority+))))))
|
||||
(with-ask-input-on-tofu-error (e)
|
||||
(refresh url)))))
|
||||
|
Loading…
Reference in New Issue
Block a user