From 30dfa8ed48bceb1df62c4accf5b7a680d1b20634 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Sat, 1 Jan 2022 22:05:11 +1100 Subject: [PATCH] revised to have dat files in local dir --- manager/controls-update.lsp | 2 +- manager/controls.lsp | 7 ++++--- manager/history.lsp | 4 ++-- manager/usage.lsp | 12 +++++------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/manager/controls-update.lsp b/manager/controls-update.lsp index cd7d2cc..7eff0b9 100644 --- a/manager/controls-update.lsp +++ b/manager/controls-update.lsp @@ -27,7 +27,7 @@ (time-parse (lookup (string "limit" i) v)) (time-parse (lookup (string "end" i) v)) ) c -1)) - (write-file "../control.dat" + (write-file "control.dat" (append (format "; Updated at %s\n(" (date)) (join (map string c) "\n " true) ")\n")) diff --git a/manager/controls.lsp b/manager/controls.lsp index b4779ae..60c00b5 100644 --- a/manager/controls.lsp +++ b/manager/controls.lsp @@ -1,4 +1,4 @@ -; Load and present ../controls.dat +; Load and present control.dat (load "expand-string.lsp") @@ -9,13 +9,14 @@ ) (constant - 'CONTROLFILE "../control.dat" + 'CONTROLFILE "control.dat" 'CONTROL (read-expr (read-file CONTROLFILE)) 'GAP (or (lookup 'gap CONTROL) 5) 'CLIP (or (lookup 'clip CONTROL) 5) - 'INCL (or (lookup control CONTROL) "ipset-control.lsp") + 'INCL (or (lookup 'control CONTROL) "ipset-control.lsp") 'TIMES (map (fn (n) (or (assoc n CONTROL) '(1 timed (7 0) (3 0) (19 0)))) (sequence 1 7)) + 'NET (or (lookup 'net CONTROL) "10.0.0.0/8") ) (setf diff --git a/manager/history.lsp b/manager/history.lsp index 3002839..2192ac5 100644 --- a/manager/history.lsp +++ b/manager/history.lsp @@ -26,10 +26,10 @@ (define (usage-file dat) (clean null? (map usage - (parse (read-file (format "../activity/%s" dat)) "\n")))) + (parse (read-file (format "activity/%s" dat)) "\n")))) (setf - USAGE (sort (flat (map usage-file (directory "../activity" "^[^.]")) 1) <) + USAGE (sort (flat (map usage-file (directory "activity" "^[^.]")) 1) <) MAP '() ) diff --git a/manager/usage.lsp b/manager/usage.lsp index 89fc09a..e53a4ac 100644 --- a/manager/usage.lsp +++ b/manager/usage.lsp @@ -4,14 +4,13 @@ (load "usage-extra.lsp") ) -(define (get-remote-user) - (and (regex "^([^:]+):" (base64-dec (6 (env "HTTP_AUTHORIZATION"))) 0) $1)) +(define (get-remote-user) REMOTE_USER) (constant - 'ADMIN (member (get-remote-user) '("ralph" "lin")) - 'USAGE (read-expr (read-file "../usage.dat")) + 'ADMIN (member REMOTE_USER '("ralph" "lin")) + 'USAGE (read-expr (read-file "usage.dat")) 'extra-options '(0 10 30 60) - 'EXTRAFILE "../control-extra.dat" + 'EXTRAFILE "control-extra.dat" 'EXTRATM (file-info EXTRAFILE 6) 'TM (date-value) 'EXTRA (and (regex "([0-9]+) ([0-9]+)" (or (read-file EXTRAFILE) "") 0) @@ -19,8 +18,7 @@ ) (define (tm2time tm) - (if (> tm) - (letn ((m (/ tm 60)) (h (/ m 60))) (list h (- m (* 60 h)))) + (if (> tm) (letn ((m (/ tm 60)) (h (/ m 60))) (list h (- m (* 60 h)))) '(0 0)) ) -- 2.39.2