summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-05-19 18:05:31 -0400
committerJune McEnroe <june@causal.agency>2021-05-19 18:05:31 -0400
commit21b5983bfbebf24da5b62c1dab8ce96e76e07d43 (patch)
tree3a43ce50c2601f6e0550e95ca3f6793a49ccecee
parentReplace freenode with tilde.chat (diff)
downloadscooper-21b5983bfbebf24da5b62c1dab8ce96e76e07d43.tar.gz
scooper-21b5983bfbebf24da5b62c1dab8ce96e76e07d43.zip
Add -h flag to hide user hostnames 1.2
Diffstat (limited to '')
-rw-r--r--html.c6
-rw-r--r--scooper.110
-rw-r--r--server.c4
-rw-r--r--server.h1
4 files changed, 17 insertions, 4 deletions
diff --git a/html.c b/html.c
index 21dca9f..f300813 100644
--- a/html.c
+++ b/html.c
@@ -28,6 +28,7 @@
 
 #include "server.h"
 
+bool htmlHideHost;
 const char *htmlStylesheet = "stylesheet.css";
 
 static enum kcgi_err htmlCSS(struct khtmlreq *html, struct kreq *req) {
@@ -372,7 +373,10 @@ eventNick(struct khtmlreq *html, const struct Event *event) {
 		class, sizeof(class), "fg%02d",
 		hash(strcmp(event->user, "*") ? event->user : event->nick)
 	);
-	asprintf(&mask, "%s!%s@%s", event->nick, event->user, event->host);
+	asprintf(
+		&mask, "%s!%s@%s",
+		event->nick, event->user, (htmlHideHost ? "*" : event->host)
+	);
 	if (!mask) err(EX_OSERR, "asprintf");
 	const char *format = "%s";
 	switch (event->type) {
diff --git a/scooper.1 b/scooper.1
index cb0c292..383b6ec 100644
--- a/scooper.1
+++ b/scooper.1
@@ -1,4 +1,4 @@
-.Dd July 12, 2020
+.Dd May 19, 2021
 .Dt SCOOPER 1
 .Os
 .
@@ -8,7 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
-.Op Fl p
+.Op Fl hp
 .Op Fl g Ar gap
 .Op Fl l Ar limit
 .Op Fl o Ar overlap
@@ -54,6 +54,9 @@ Set the time in seconds between events
 after which to indicate a gap.
 The default is 3600 (one hour).
 .
+.It Fl h
+Hide user hostnames.
+.
 .It Fl l Ar limit
 Limit the number of events
 to be displayed on one page.
@@ -97,6 +100,9 @@ database.
 .It Ev SCOOPER_GAP
 Equivalent to
 .Fl g .
+.It Ev SCOOPER_HIDE_HOST
+Equivalent to
+.Fl h .
 .It Ev SCOOPER_LIMIT
 Equivalent to
 .Fl l .
diff --git a/server.c b/server.c
index 6cb0611..6280b4d 100644
--- a/server.c
+++ b/server.c
@@ -87,16 +87,18 @@ int main(int argc, char *argv[]) {
 	const char *val;
 	if ((val = getenv(ENV "DATABASE"))) path = val;
 	if ((val = getenv(ENV "GAP"))) eventsGap = strtol(val, NULL, 10);
+	if ((val = getenv(ENV "HIDE_HOST"))) htmlHideHost = (val[0] != '0');
 	if ((val = getenv(ENV "LIMIT"))) eventsLimit = strtol(val, NULL, 10);
 	if ((val = getenv(ENV "OVERLAP"))) eventsOverlap = strtol(val, NULL, 10);
 	if ((val = getenv(ENV "PUBLIC"))) contextsPublic = (val[0] != '0');
 	if ((val = getenv(ENV "RECENT"))) contextsRecent = strtol(val, NULL, 10);
 	if ((val = getenv(ENV "STYLESHEET"))) htmlStylesheet = val;
 
-	for (int opt; 0 < (opt = getopt(argc, argv, "cg:l:o:pr:s:"));) {
+	for (int opt; 0 < (opt = getopt(argc, argv, "cg:hl:o:pr:s:"));) {
 		switch (opt) {
 			break; case 'c': test = true;
 			break; case 'g': eventsGap = strtol(optarg, NULL, 10);
+			break; case 'h': htmlHideHost = true;
 			break; case 'l': eventsLimit = strtol(optarg, NULL, 10);
 			break; case 'o': eventsOverlap = strtol(optarg, NULL, 10);
 			break; case 'p': contextsPublic = true;
diff --git a/server.h b/server.h
index bd39526..8a5318d 100644
--- a/server.h
+++ b/server.h
@@ -163,6 +163,7 @@ struct Event {
 	const char *message;
 };
 
+extern bool htmlHideHost;
 extern const char *htmlStylesheet;
 enum kcgi_err htmlHead(
 	struct khtmlreq *html, struct kreq *req, const char *title