/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
/*
 * This will be a udp channel...
 * We will only accept messages from certain sources.
 * Once we get a message we do a reverse lookup to see if they are
 * allowed to send messages to us.  If not, well.  We send them back
 * a intercreator message saying they are not allowed to do this.
 * We also don't send back intercreator messages to the person who
 * send it.
 * Ok.  There are also two types of intercreator server :)
 * The server server (this one) and the message handler.  It just
 * tells messages to everyone on, checking first to see if it came
 * from the server...
 */
#include "intercreator.h"
#include "inet.h"

string *allowed;

void    create()
{
    allowed = ({ "NewMoon", "bing", "nanvaent" });
}				/* create() */

void    read_callback( int fd, string mess, string addr )
{
    string  mud_name;

    TP( "Got this with " + addr + ", " + mess + "\n" );
    sscanf( mess, "%s %s", mud_name, mess );
    NAMESERVER->lookup_mud( mud_name, "finish_lookup", ({ addr, mess }) );
}				/* read_callback() */

void    finish_lookup( string name, string addr, mixed *args )
{
    string  j_addr1, j_addr2, *blue;
    int     i;

    TP( "Done this...\n" );
    if( !addr )
    {
	TP( "Address " + name + " failed to be looked up.\n" );
	return;
    }
/* First lets see if the mud is who they say they are... */
    sscanf( addr, "%s %s", j_addr1 );
    TP( "p1" );
    sscanf( args[ 0 ], "%s %s", j_addr2 );
    TP( "p2" );
/* If they arent, ignore the message totaly. */
    if( j_addr1 != j_addr2 )
    {
	TP( "Addresses did not match " + j_addr1 + " " + j_addr2 + "\n" );
	return;
    }
    TP( "p3" );
    if( member_array( name, allowed ) == -1 )
    {
	INETD->datagram_message( "intercreator", name, MUD_NAME + ":" +
				 "intercreator_server@" + MUD_NAME + " says: You are " +
				 "not allowed to send messages to this channel.\n" );
	return;
    }
/* They are allowed! */
    TP( "p4" );
    blue = allowed - ({ name, MUD_NAME });
    TP( "p5" );
    for( i = 0; i < sizeof( blue ); i++ )
	INETD->datagram_message( "intercreator", blue[ i ], name + " " + args[ 1 ] );
    TP( "p6" );
    if( name != MUD_NAME && member_array( MUD_NAME, allowed ) != -1 )
    {
	TP( "p7" );
	IN_CREATOR->finish_lookup( MUD_NAME, 0, ({ "", name + " " + args[ 1 ] }), 1 );
    }
    TP( "p8" );
}				/* finish_revese() */