git: 3745ef7406f7 - main - www/go-anubis: NEW PORT anti-scraper browser-based proof-of-work proxy

From: Dave Cottlehuber <dch_at_FreeBSD.org>
Date: Fri, 04 Apr 2025 12:15:16 UTC
The branch main has been updated by dch:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3745ef7406f7579cea610caaa755d676f4d7f7af

commit 3745ef7406f7579cea610caaa755d676f4d7f7af
Author:     Dave Cottlehuber <dch@FreeBSD.org>
AuthorDate: 2025-04-04 10:23:48 +0000
Commit:     Dave Cottlehuber <dch@FreeBSD.org>
CommitDate: 2025-04-04 12:14:25 +0000

    www/go-anubis: NEW PORT anti-scraper browser-based proof-of-work proxy
    
    Differential Revision:  https://reviews.freebsd.org/D49563
    Reviewed by:    diizzy
    Sponsored by:   SkunkWerks, GmbH
    Tested by:      dbaio, philip
---
 www/Makefile                  |  1 +
 www/go-anubis/Makefile        | 27 ++++++++++++++++++++
 www/go-anubis/distinfo        |  5 ++++
 www/go-anubis/files/anubis.in | 58 +++++++++++++++++++++++++++++++++++++++++++
 www/go-anubis/pkg-descr       | 16 ++++++++++++
 www/go-anubis/pkg-message     | 18 ++++++++++++++
 6 files changed, 125 insertions(+)

diff --git a/www/Makefile b/www/Makefile
index 82011589d55f..91d7aba25b4c 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -223,6 +223,7 @@
     SUBDIR += glassfish4
     SUBDIR += glpi
     SUBDIR += gnome-user-share
+    SUBDIR += go-anubis
     SUBDIR += go-www
     SUBDIR += gobuffalo
     SUBDIR += gohugo
diff --git a/www/go-anubis/Makefile b/www/go-anubis/Makefile
new file mode 100644
index 000000000000..ee3227e436a3
--- /dev/null
+++ b/www/go-anubis/Makefile
@@ -0,0 +1,27 @@
+PORTNAME=	anubis
+DISTVERSIONPREFIX=	v
+DISTVERSION=	1.15.1
+CATEGORIES=	www
+PKGNAMEPREFIX=	go-
+
+MAINTAINER=	dch@FreeBSD.org
+COMMENT=	Anti-scraper web proxy using browser-based proof-of-work challenges
+WWW=		https://anubis.techaro.lol/
+
+LICENSE=	BSD3CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+USES=		go:modules,1.24
+USE_RC_SUBR=	${PORTNAME}
+
+GO_MODULE=	github.com/techarohq/${PORTNAME}
+GO_TARGET=	./cmd/${PORTNAME}
+GO_BUILDFLAGS=	-ldflags="-X github.com/TecharoHQ/anubis.Version=v${DISTVERSION}"
+
+PLIST_FILES=	sbin/${PORTNAME}
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKDIR}/bin/${PORTNAME} \
+		${STAGEDIR}${PREFIX}/sbin/${PORTNAME}
+
+.include <bsd.port.mk>
diff --git a/www/go-anubis/distinfo b/www/go-anubis/distinfo
new file mode 100644
index 000000000000..fa33409aa6c7
--- /dev/null
+++ b/www/go-anubis/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1743692515
+SHA256 (go/www_go-anubis/anubis-v1.15.1/v1.15.1.mod) = c4060528e14abead94fa468734829fd9ce1c88b9bea06ae6fed02d94c804013b
+SIZE (go/www_go-anubis/anubis-v1.15.1/v1.15.1.mod) = 2190
+SHA256 (go/www_go-anubis/anubis-v1.15.1/v1.15.1.zip) = 7ca38367229c5cace57929a2fb7ff8ccbdde911e00bcf3ed7ef01b84a0902cd4
+SIZE (go/www_go-anubis/anubis-v1.15.1/v1.15.1.zip) = 1207282
diff --git a/www/go-anubis/files/anubis.in b/www/go-anubis/files/anubis.in
new file mode 100644
index 000000000000..9a20142a7bee
--- /dev/null
+++ b/www/go-anubis/files/anubis.in
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# PROVIDE: anubis
+# REQUIRE: DAEMON NETWORKING
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf to enable anubis:
+# anubis_enable (bool):        Set to "NO" by default.
+#                              Set it to "YES" to enable anubis.
+# anubis_user (user):          Set to "www" by default.
+#                              User to run anubis as.
+# anubis_group (group):        Set to "www" by default.
+#                              Group to run anubis as.
+# anubis_args (str):           Set to "" by default.
+#                              Extra flags passed to anubis.
+
+. /etc/rc.subr
+
+name=anubis
+rcvar=anubis_enable
+
+load_rc_config $name
+
+: ${anubis_enable:="NO"}
+: ${anubis_user:="www"}
+: ${anubis_group:="www"}
+: ${anubis_args:=""}
+
+pidfile="/var/run/${name}.pid"
+daemon_pidfile="/var/run/${name}-daemon.pid"
+procname="%%PREFIX%%/sbin/anubis"
+command="/usr/sbin/daemon"
+command_args="-f -c -R 5 -r -T ${name} -p ${pidfile} -P ${daemon_pidfile} ${procname} ${anubis_args}"
+
+start_precmd=anubis_startprecmd
+stop_postcmd=anubis_stoppostcmd
+
+anubis_startprecmd()
+{
+	if [ ! -e ${daemon_pidfile} ]; then
+		install -o ${anubis_user} -g ${anubis_group} /dev/null ${daemon_pidfile};
+	fi
+	if [ ! -e ${pidfile} ]; then
+		install -o ${anubis_user} -g ${anubis_group} /dev/null ${pidfile};
+	fi
+}
+
+
+anubis_stoppostcmd()
+{
+	if [ -f "${daemon_pidfile}" ]; then
+		pids=$( pgrep -F ${daemon_pidfile} 2>&1 )
+		_err=$?
+		[ ${_err} -eq 0 ] && kill -9 ${pids}
+	fi
+}
+
+run_rc_command "$1"
diff --git a/www/go-anubis/pkg-descr b/www/go-anubis/pkg-descr
new file mode 100644
index 000000000000..de3309496cee
--- /dev/null
+++ b/www/go-anubis/pkg-descr
@@ -0,0 +1,16 @@
+Anubis is a web proxy that protects upstream resources from scraper bots
+by using a short hash-based proof-of-work challenge. It "weighs the soul of
+your connection" to determine if you're a legitimate user or an automated bot.
+
+Anubis serves as a protective layer for websites that are being aggressively
+scraped by AI bots and other automated systems that don't respect robots.txt
+standards. It provides an alternative to services like Cloudflare when those
+options aren't available or desired.
+
+The proof-of-work system requires clients to solve a computational challenge
+before accessing protected content, effectively deterring most automated
+scrapers while allowing legitimate users through with minimal disruption.
+
+It should be noted that Anubis may cause problems for accessibility of
+protected websites, potentially confusing screen readers for blind users,
+or other problems for assisted interaction. Please consider carefully.
diff --git a/www/go-anubis/pkg-message b/www/go-anubis/pkg-message
new file mode 100644
index 000000000000..d4e9cfa3dc58
--- /dev/null
+++ b/www/go-anubis/pkg-message
@@ -0,0 +1,18 @@
+[
+{
+  type: install
+  message: <<EOM
+Anubis has been installed! Typically anubis is run behind a proxy, such as
+nginx, caddy, haproxy, or similar, that passes the `x-real-ip` header to
+anubis, which runs by default on port 8923. You will need to supply the
+target url that you are protecting.
+
+Amend rc.conf as required. For example:
+
+anubis_enable=YES
+anubis_args="-target http://localhost:4000/myapp -bind :8923"
+
+For more information, see https://anubis.techaro.lol/
+EOM
+}
+]