diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2024-08-11 06:58:44 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2024-08-11 06:58:44 -0400 |
| commit | 391ec733bf265e3dd0a142123e021f8ab384d9b2 (patch) | |
| tree | 781ca83f717867df1bffa07d9d4e06584b0b546e /jakob/dynamic | |
| parent | 2a6edfb9341e510dfdc304772906e696064e08a2 (diff) | |
[dynamic] Guard some functions behind %debug-enabled
Diffstat (limited to 'jakob/dynamic')
| -rw-r--r-- | jakob/dynamic/notify.scm | 4 | ||||
| -rw-r--r-- | jakob/dynamic/util.scm | 19 |
2 files changed, 15 insertions, 8 deletions
diff --git a/jakob/dynamic/notify.scm b/jakob/dynamic/notify.scm index ff8763c..cdd2209 100644 --- a/jakob/dynamic/notify.scm +++ b/jakob/dynamic/notify.scm @@ -15,6 +15,7 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (jakob dynamic notify) + #:use-module (jakob dynamic config) #:use-module (json) #:use-module (web client) #:export (notify)) @@ -28,4 +29,5 @@ (format #f "https://~a/message?token=~a" gotify-base-url gotify-token)) (define body (scm->json-string `((priority . ,priority) (title . ,title) (message . ,message)))) - (http-post url #:headers '((content-type . (application/json))) #:body body)) + (unless (%debug-enabled) + (http-post url #:headers '((content-type . (application/json))) #:body body))) diff --git a/jakob/dynamic/util.scm b/jakob/dynamic/util.scm index e34ae91..f18c497 100644 --- a/jakob/dynamic/util.scm +++ b/jakob/dynamic/util.scm @@ -16,6 +16,7 @@ (define-module (jakob dynamic util) #:use-module (ice-9 match) + #:use-module (jakob dynamic config) #:use-module (rnrs bytevectors) #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) @@ -117,16 +118,20 @@ to express my God-given constitutional rights!" (define (from-tor? request) "Return whether or not REQUEST was sent by the Tor daemon" - (let ((originating-ip (assoc-ref (request-headers request) 'x-forwarded-for))) - (or (string=? "127.0.0.1" originating-ip) - (string=? "::1" originating-ip)))) + (if (%debug-enabled) + #f + (let ((originating-ip (assoc-ref (request-headers request) 'x-forwarded-for))) + (or (string=? "127.0.0.1" originating-ip) + (string=? "::1" originating-ip))))) (define (from-i2p? request) "Return whether or not REQUEST was sent by i2pd" - (let ((originating-ip (assoc-ref (request-headers request) 'x-forwarded-for))) - (and (or (string-prefix? "127." originating-ip) - (string-suffix? ":1" originating-ip)) - (not (from-tor? request))))) + (if (%debug-enabled) + #f + (let ((originating-ip (assoc-ref (request-headers request) 'x-forwarded-for))) + (and (or (string-prefix? "127." originating-ip) + (string-suffix? ":1" originating-ip)) + (not (from-tor? request)))))) (define (from-darknet? request) "Return whether or not REQUEST was sent by a darknet tunnel" |