Page MenuHomeFreeBSD

www/go-anubis: NEW PORT anti-scraper browser-based proof-of-work proxy
ClosedPublic

Authored by dch on Mar 28 2025, 11:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 27, 9:54 PM
Unknown Object (File)
Thu, Jun 26, 3:22 PM
Unknown Object (File)
Thu, Jun 26, 10:58 AM
Unknown Object (File)
Tue, Jun 24, 11:16 PM
Unknown Object (File)
Tue, Jun 24, 6:56 AM
Unknown Object (File)
Mon, Jun 23, 11:03 AM
Unknown Object (File)
Sun, Jun 22, 6:31 PM
Unknown Object (File)
Sat, Jun 21, 12:18 PM
Subscribers

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 63307
Build 60191: arc lint + arc unit

Event Timeline

dch requested review of this revision.Mar 28 2025, 11:41 PM
dch created this revision.

I needed this too, https://anubis.techaro.lol/

  • works on amd64 already, probably does on arm64 too, but my builder is still catching up

It has 1 problem, service stop anubis ... doesn't. If you can suggest
a fix that would be fantastic.

Thank you for doing this work! At a glance, this looks good enough to give a test-drive on the cluster.

I'll try to figure out what's up with "service stop" either today or tomorrow.

Hi, thanks for the port @dch

I found these issues when testing:

FATAL: Makefile: The package base name "anubis" is already in use by the "mail/anubis" port. Choose another PORTNAME or use a PKGNAMEPREFIX or PKGNAMESUFFIX.
WARN: files/anubis.in: this file is executable and likely does not need to be.
1 fatal error and 1 warning found.

for the name collision, we had the same issue with hugo. It was decided back then to rename the port to gohugo and add this prefix PKGNAMEPREFIX= go to it.
maybe do the same here? or just the prefix.

chmod -x www/anubis/files/anubis.in

...

For the rc file's stop command, when using the -R X, I noticed that on other ports that use this, the stop behavior is always modified.
I think this way will be cleaner:

$ git diff .
diff --git a/www/anubis/files/anubis.in b/www/anubis/files/anubis.in
old mode 100755
new mode 100644
index 45e91d8bf593..606dd3dc64cb
--- a/www/anubis/files/anubis.in
+++ b/www/anubis/files/anubis.in
@@ -27,17 +27,31 @@ load_rc_config $name
 : ${anubis_args:=""}

 pidfile="/var/run/${name}.pid"
+daemon_pidfile="/var/run/${name}-daemon.pid"
 procname="%%PREFIX%%/bin/anubis"
 command="/usr/sbin/daemon"
-command_args="-f -c -R 5 -r -T ${name} -P ${pidfile} ${procname} ${anubis_args}"
+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
+}
+

BTW I think daemon is broken, https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=285742 I tried on 14.2-RELEASE, 15.0-CURRENT, and a 14-STABLE from today, none of them will shut down as expected.

With the change I've sent before, service stop and start works fine:

command_args="-f -c -R 5 -r -T ${name} -p ${pidfile} -P ${daemon_pidfile} ${procname} ${anubis_args}"

even without -R 5.

If I kill the daemon manually, the child is also killed:

# service anubis start
Starting anubis.

# ps ax | grep anubis
 8560  -  Ss       0:00.00 daemon: /usr/local/bin/anubis[8589] (daemon)
 8589  -  S        0:00.02 /usr/local/bin/anubis

# kill 8560
# ps ax | grep anubis
null

If I kill only the child, it's restarted after 5 seconds, as desired.

# service anubis start
Starting anubis.

# ps ax | grep anubis
49700  -  Ss       0:00.00 daemon: /usr/local/bin/anubis[50013] (daemon)
50013  -  S        0:00.01 /usr/local/bin/anubis

# kill 50013

# ps ax | grep anubis
49700  -  Ss       0:00.00 daemon: /usr/local/bin/anubis[50013] (daemon)

# ps ax | grep anubis
49700  -  Ss       0:00.00 daemon: /usr/local/bin/anubis[56238] (daemon)
56238  -  S        0:00.02 /usr/local/bin/anubis

Without the change, I see this:

# service anubis start
Starting anubis.

# ps ax | grep anubis
 1327  -  Ss       0:00.00 daemon: /usr/local/bin/anubis[2187] (daemon)
 2187  -  S        0:00.01 /usr/local/bin/anubis

# cat /var/run/anubis.pid
1327

# service anubis stop
anubis not running? (check /var/run/anubis.pid).

# ps ax | grep anubis
 1327  -  Ss       0:00.00 daemon: /usr/local/bin/anubis[2187] (daemon)
 2187  -  S        0:00.01 /usr/local/bin/anubis

the service tries to match the pid with the child, and not the daemon's daemon:

parts of the debug:

+ eval 'rc_pid=$(check_pidfile' /var/run/anubis.pid /usr/local/bin/anubis ')'
+ check_pidfile /var/run/anubis.pid /usr/local/bin/anubis
+ _pidfile=/var/run/anubis.pid


+ local _pidmsg
+ [ -n /var/run/anubis.pid ]
+ _pidmsg=' (check /var/run/anubis.pid).'
+ echo 'anubis not running? (check /var/run/anubis.pid).'
anubis not running? (check /var/run/anubis.pid).
+ return 1

so, this seems to me not a daemon issue.

diizzy added inline comments.
www/anubis/Makefile
1 ↗(On Diff #152825)

Clashes with mail/anubis

18 ↗(On Diff #152825)

Perferably we should get https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=285251 adjusted and committed.
...or for now simply patch https://github.com/TecharoHQ/anubis/blob/main/anubis.go#L8

www/anubis/Makefile
20 ↗(On Diff #152825)

Same here-ish (sbin vs bin)

s/anubis/go-anubis

  • add dbiao fix for daemonic success
  • add diizzy polishing
dch retitled this revision from www/anubis: NEW PORT anti-scraper browser-based proof-of-work proxy to www/go-anubis: NEW PORT anti-scraper browser-based proof-of-work proxy.Apr 3 2025, 3:10 PM

fix the fixed plist oh the shame

Great, thank you so much for this port.

This revision is now accepted and ready to land.Apr 3 2025, 5:02 PM
www/go-anubis/Makefile
20

For consistency thtat should be DISTVERSION

26

Ordering, this should be above do sections.

This looks good to me -- modulo @diizzy's comments.

Thank you for making this port. I look forward to seeing how it improves life on the FreeBSD.org cluster.