projects
/
rrq
/
hourglass.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
bc22f1c
)
add net option and minor code polishing
author
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Sat, 1 Jan 2022 11:01:55 +0000
(22:01 +1100)
committer
Ralph Ronnquist
<ralph.ronnquist@gmail.com>
Sat, 1 Jan 2022 11:01:55 +0000
(22:01 +1100)
ipset-control.lsp
patch
|
blob
|
history
diff --git
a/ipset-control.lsp
b/ipset-control.lsp
index 9c9bf9393d378051677d6aa34f2f0a11bb913b8c..899e37af2fbec9f633b39d3f57b0b628d6dabb56 100644
(file)
--- a/
ipset-control.lsp
+++ b/
ipset-control.lsp
@@
-1,15
+1,18
@@
# Should load from "ipset.cfg"
# Should load from "ipset.cfg"
-(constant 'TABLE "TIMO" 'NET "192.168.104.0/24"
- 'IPSET "/sbin/ipset" )
+(constant 'IPSET "/sbin/ipset" 'TABLE "TIMO" )
-# Apply "add" or "del" on the controllable as needed, and exit
+;; Return current low-leve "close" or "open" status
+(define (current-status)
+ (if (exec (format "%s list %s | grep %s" IPSET TABLE NET)) "close" "open"))
+
+;; Ensure low-level setting is "close" or "open" as given
(define (control cmd reason)
(define (control cmd reason)
- (
let ((a (case cmd ("open" "del") ("close" "add") (true "XXX"))
))
- (
when (!= cmd (if (exec (format "%s list %s | grep %s" IPSET TABLE NET
))
-
"close" "open")
)
-
(! (println (date-value)
(format " ipset-control (%s): " reason)
- (format "%s %s %s %s" IPSET
a
TABLE NET)))))
-
(exit 0)
)
+ (
when (!= cmd (current-status
))
+ (
let ((todo (case cmd ("open" "del") ("close" "add") (true "XXX"))
))
+
(! (println (date-value
)
+
(format " ipset-control (%s): " reason)
+ (format "%s %s %s %s" IPSET
todo
TABLE NET)))))
+ )
"ipset-control.lsp"
"ipset-control.lsp"