this is the purpose of the blocklistd service as recommended upthread.
Yes, this is the ready FreeBSD solution, described in the Handbook. I wonder how I could have missed it.
But in the end I decided not to use it.

First, they do not have any examples of using it with ipfw and I thought writing my own service would be easier than trying to find out how do that. Secondly, it requires the socket which it needs to decide if my service has the right to do what it wants to do. That is the socket I would rather close as soon as I can and I thought I only need a dumb servant who would silently carry out the order to block an address.
Yet, the acquaintance with this service lead me to the correct solution. The worst point in the approach that I pursued was that I was going to control the firewall from an http service. To control the firewall willy-nilly you need to run it as root and my partner point-blank refused to run an http service with this sort of privileges. The solution is obvious - to write a separate service which only listens on 127.0.0.1 for commands. One bonus is that now our service does not need to bother about timely unblocking - this is the task of the ancillary blocking service. Furthermore in the main service that would be done on the map of all addresses in work while the blocking service only knows about the blocked ones.
Finally, we do not add or delete rules, there is just one rule:
Code:
ipfw -q add 00200 deny tcp from 'table(BT0)' to 192.168.1.17 80 in via re0
The addresses are added to the table and deleted from it.
We monitor connections per second, packets per second, and requests for large documents per second. It works. In the last three days our service has blocked these addresses:
185.146.233.219
5.230.122.201
163.5.214.40
192.253.248.169
194.31.223.191
Once again I thank atax1a and SirDice for pointing me into the right direction.
-