summaryrefslogtreecommitdiffstats
path: root/squark-auth-ip.c
diff options
context:
space:
mode:
Diffstat (limited to 'squark-auth-ip.c')
-rw-r--r--squark-auth-ip.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/squark-auth-ip.c b/squark-auth-ip.c
index dff4f8d..6993e85 100644
--- a/squark-auth-ip.c
+++ b/squark-auth-ip.c
@@ -17,9 +17,10 @@
#include "blob.h"
#include "authdb.h"
-#define DO_LOGIN -1
-#define DO_OVERRIDE -2
-#define DO_PRINT -3
+#define DO_LOGIN -1
+#define DO_OVERRIDE -2
+#define DO_PRINT -3
+#define DO_LOGOUT -4
static int running = 1;
static struct authdb adb;
@@ -106,7 +107,7 @@ int main(int argc, char **argv)
sockaddr_any ipaddr = { .any.sa_family = AF_UNSPEC };
blob_t ip = BLOB_NULL, username = BLOB_NULL;
- while ((opt = getopt(argc, argv, "i:u:olp")) != -1) {
+ while ((opt = getopt(argc, argv, "i:u:olpL")) != -1) {
switch (opt) {
case 'i':
ip = BLOB_STRLEN(optarg);
@@ -128,6 +129,9 @@ int main(int argc, char **argv)
case 'p':
running = DO_PRINT;
break;
+ case 'L':
+ running = DO_LOGOUT;
+ break;
}
}
@@ -168,13 +172,28 @@ int main(int argc, char **argv)
fprintf(stdout,
"IP-address: %s\n"
"Username: %s\n"
+ "MAC-address: %02x:%02x:%02x:%02x:%02x:%02x\n"
+ "Soft block mask: %016llx\n"
+ "Hard block mask: %016llx\n"
"Login time: %s"
"Override time: %s",
ip.ptr,
- username.ptr,
+ entry.p.login_name,
+ entry.p.mac_address[0],
+ entry.p.mac_address[1],
+ entry.p.mac_address[2],
+ entry.p.mac_address[3],
+ entry.p.mac_address[4],
+ entry.p.mac_address[5],
+ entry.p.block_categories,
+ entry.p.hard_block_categories,
entry.u.login_time ? ctime_r(&entry.u.login_time, buf1) : "<none>\n",
entry.u.override_time ? ctime_r(&entry.u.override_time, buf2) : "<none>\n");
break;
+ case DO_LOGOUT:
+ if (authdb_check_login(token, &entry, username, now))
+ authdb_commit_logout(token);
+ break;
}
} else {
while (running)