Aow DNS Caching

From: Admin Age of War (aowadmin@AGEOFWAR.ORG)
Date: 06/24/98


New DNS Caching code has been placed on
The README follows:

AOWDNS - AgeofWar Dynamic Name Service

AgeofWar.ORG is now seeing several hundred unique IP addresses each
day (and sometimes each hour).  Blocked gethostbyaddr() has had a significant
impact on performance.  While our own name servers are quite fast
the same is not true for other name servers out in the world.

After many iterations of "in mud caching" schemes involving linked
lists and such, I now feel that we have a stable solution which adequately
compromises the needs of performance and hostnames.

Experience has shown that an indexed file scheme is best.  It avoids the
problems of very long ordered link list structures, and avoids extreme
lag occuring when a mud tries to restart under heavy load (many blocked
gethostbyaddr() issued in quickly as people all log on at once).  The
indexed file scheme selected in our Linux 5.1 environment is NDBM.

Other implementation of DBM exist.  I assume that they too will work just
fine provimed that the API is consistent.  Other DBM implementations have
not been tested.

As good netizens, and in keeping with the unencumbered spirit of Linux
and open software in general (hint hint mud authors), I am releasing this
code into the net without any type of licensing requirement.  You are free
to use it, modify it, curse it (don't blame me if it breaks) or throw it
out as you like.  You may even use it to make money should such an
opportunity arise.  If it works, please leave my name intact, otherwise
remove my name :)

The ip to hostname translation is normally done in comm.c.  I have replaced
this comm.c code with a call to aowdns instead.  A sample hook is included
in the module comments.  Stock circle (at least to bpl11) captures only
30 bytes of the host name.  So, you might want to consider right justifying
the name plugged into descriptors by comm.c (if you need an example of
how to do this send me an email.

The ndbm.h header file includes another header file called db.h, unfortunately
this db.h conflicts with the db.h distributed with circle.  To get around the
problem compile aowdns.c seperately: gcc -c -o aowdns.o aowdns.c -g

Make the following changes to your make file:

  Change from:
     $(CC) -o $(BINDIR/circle) $(PROFILE) $(OBJFILES) -lcrypt

  Change to:
     $(CC) -o $(BINDIR/circle) $(PROFILE) $(OBJFILES) -lcrypt -lndbm aowdns.o

Touch comm.c and compile and link as normal.


The aowdns function creates a file called .../lib/dnscache.db (assuming
you are running ndbm and not some other dbm).  IP/Hostname entries are
added to the cache as they are discovered.  Once added they will be used
instead of gethostbyaddr().

It is not good that we leave entries on the cache forever.  Two problems
crop up: 1) the cache gets huge, and 2) Hostnames associated with specific
ip addresses sometimes change.

So, provisions have been made to automatically remove old entries.  The
#define of KEEP_DAYS specifies how long an entry is to be retained.  About
once an hour aowdns will scan the cache and delete entries created more
than KEEP_DAYS in the past.

A utility, called dnslist, is also provided which lists the contents
of the cache.

Feedback, good or bad, is appreciated.

Reed H. Petty, Server Admin (Coder only when things are desperate)
AgeofWar.ORG Port 4000

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST