DAILY BLOCKS - HOSTING AN INTERBBS LEAGUE
======================================================================

A league is one small program, dbserver, running somewhere the BBSes
can reach.  It hands every door that connects the league's board
number and rules, takes in their scores and hands everyone's scores
back out.  No database, no web server, nothing else to install.

Sysops who only want to JOIN a league do not need this file - see
INTERBBS LEAGUES in README.TXT (three lines in dblocks.ini).


STARTING ONE
----------------------------------------------------------------------
1. Put dbserver (bin/linux, bin/win32 or bin/win64) 
   in a directory of its own.  It keeps its files there.
2. Run it.  The first run writes dbserver.ini with a random board
   number and these defaults, then starts listening:

     Port=3255            the TCP port doors connect to
     LeagueName=Daily Blocks League
     MakeupDays=30        how far back a missed day can be made up
     PlayAheadDay=22      rest of the month can be played from this day
     PiecesPerDay=50      )
     SpecialBoards=1      )  the boards - fixed for the life of a league
     BoardSeed=<random>   )

   Stop it (Ctrl-C), edit the name and anything else you want different,
   and start it again.  Decide PiecesPerDay and SpecialBoards NOW.
   THE FIRST DAY.  Created= in dbserver.ini is the league's first day:
   the day the server first ran.  A BBS that joins gets league boards
   from that day on, so its callers can make up what they missed.  To
   let everyone start from the 1st of the month, set it back
   (Created=20261001) and restart the server.  Earlier is always safe,
   and doors already in the league follow along; do not move it later
   once scores are in.
3. Let TCP port 3255 through your firewall and forward it on your
   router, like you did for telnet.
4. Tell the sysops your address.  They put it in dblocks.ini, and their
   doors do the rest.  Your own BBS joins the same way; if the server
   is on the same machine, LeagueServer=127.0.0.1 will do.

There is no DOS version of the server.  A DOS board cannot host or
join; Windows and Linux boards (x86 or ARM) can do both.


KEEPING IT RUNNING
----------------------------------------------------------------------
It is a console program that runs until stopped.  Every score is
written to disk as it arrives, so stopping it at any moment is safe.

Linux, with systemd - /etc/systemd/system/dbserver.service:

    [Unit]
    Description=Daily Blocks league server
    After=network.target

    [Service]
    WorkingDirectory=/home/bbs/dbleague
    ExecStart=/home/bbs/dbleague/dbserver
    User=bbs
    Restart=always

    [Install]
    WantedBy=multi-user.target

  then:  systemctl enable --now dbserver

Windows: run it in a console window, start it from Task Scheduler "at
startup", or wrap it as a service with a tool such as NSSM.

    dbserver            run the league
    dbserver -list      show the BBSes that have joined, and exit
                        (fine while the server is running)


THE FILES
----------------------------------------------------------------------
  dbserver.ini   settings
  league.dat     every score (a 64-byte header, then 72 bytes a score)
  league.bbs     the BBSes that have joined - plain text, one per line:
                 number, key, first seen, last seen, last address, name
  banned.ini     who is shut out (below)
  dbserver.log   what happened; rolls over to dbserver.log.old at 5 MB

Back up league.dat, league.bbs and dbserver.ini together.


WHO CAN JOIN, AND SHUTTING SOMEONE OUT
----------------------------------------------------------------------
The league is open: any BBS that knows the address can join.  The first
door to use a BBS name is given a key for it, and from then on the name
only works with that key, so nobody can post scores as somebody else's
BBS.

If a board misbehaves, put it in banned.ini, one entry per line:

    Cheaters Paradise BBS          a BBS name, as shown in league.bbs
    203.0.113.45                   or an IP address

The server notices the change within a couple of seconds - no restart.
A banned BBS can no longer post, and the scores it has posted vanish
from every scoreboard in the league the next time each door checks in.
Nothing is deleted: take the line out and they come back.

A banned sysop can join again under a new name from a new key; the
answer is another line in banned.ini.  The log shows every new BBS and
the address it came from.

A sysop who has lost their LeagueKey (a reinstall without a backup)
will be told the name is taken.  To release it: stop the server, blank
out the key (second column) on that BBS's line in league.bbs, start it
again.  Their next call claims the name with a fresh key and their old
scores stay theirs.


CHANGING THINGS LATER
----------------------------------------------------------------------
LeagueName, MakeupDays and PlayAheadDay can be changed whenever you
like (stop, edit, start).  Doors pick the new values up the next time
they connect.

PiecesPerDay, SpecialBoards and BoardSeed cannot: they decide which
pieces everyone gets, and every score already posted was made with
them.  The server refuses to start if they no longer match league.dat.

STARTING OVER.  To wipe the league and begin a new one: stop the
server, delete league.dat and league.bbs, delete the LeagueID line (and
BoardSeed, for new boards) from dbserver.ini, start it.  Each door
notices at its next call, drops what it had collected and joins the new
league by itself, starting the day after its callers' last played day.
Days they played on the old league's boards stay as they were, as local
history.


WHAT IT WILL AND WILL NOT DO
----------------------------------------------------------------------
* It serves one door at a time.  A conversation is a few lines and
  takes a fraction of a second; none is allowed more than 30 seconds,
  and one address is limited to 60 connections a minute.
* It refuses scores that are impossible on the league's boards, dates
  outside the league, and lines that are not the protocol.  Beyond that
  it has to believe what a door tells it, like every BBS league.
* Days are local to each BBS.  A board in a later time zone reaches
  "tomorrow" first; its scores for that day are kept back from boards
  that are not there yet.
