Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!, Exalead, Google

Members: 0
Guests: 3
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Enh] DNS Resolver
Forum Rules | Mark all | Recent Posts

[Enh] DNS Resolver
< Newer Topic :: Older Topic > Stop DNS lag now!

Pages:<< prev 1 next >>
Post is unread #1 Dec 2, 2006, 9:58 pm   Last edited Nov 25, 2007, 6:49 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

As outlined here: http://www.smaugmuds.org/index.php?a=topic&t=1945
The DNS resolver has been added to the code as of today.

For those who do not yet have this installed, these are the instructions:

Installation Instructions
-------------------------

** Note - if you are using the old slave code, remove it before starting this. **

1. Place the resolver.c, dns.c, and dns.h files in your src directory.

2. Open the Makefile

Add dns.c and dns.o to the appropriate sections.

Below your L_FLAGS line, add the following 2 lines:

#D_FLAGS : For the DNS Slave process. No need in linking all the extra libs for this.
D_FLAGS = -g2 -O $(PROF) $(SOLARIS_LINK)

Then, locate the following:
all:
$(MAKE) -s smaug

Below that, add:
$(MAKE) -s dns

Then, find the following section:

smaug: $(O_FILES)
rm -f smaug
$(CC) $(L_FLAGS) $(USE_IMC) -o smaug $(O_FILES)
chmod g+w smaug
chmod a+x smaug
chmod g+w $(O_FILES)

Below that, add the following section:

dns: resolver.o
rm -f resolver
$(CC) $(D_FLAGS) -o resolver resolver.o
chmod g+w resolver
chmod a+x resolver
chmod g+w resolver.o

3. Open mud.h and find the struct for descriptor_data.

Add the following 2 lines to the end:

int ifd;
pid_t ipid;

Then find the following section:

/*
* Structure for extended bitvectors -- Thoric
*/
struct extended_bitvector
{
unsigned int bits[XBI]; /* Needs to be unsigned to compile in Redhat 6 - Samson */
};

Directly below that, add:

#include "dns.h"

4. Open comm.c

In the includes section, add the following:

#include <sys/wait.h>

Then locate function new_descriptor.

In the declarations section, remove: struct hostent *from;

Then find the following:

dnew->port = ntohs( sock.sin_port );
dnew->user = STRALLOC("(unknown)";);
dnew->newstate = 0;
dnew->prevcolor = 0x07;

Directly below that, add the following:

dnew->ifd = -1; /* Descriptor pipes, used for DNS resolution and such */
dnew->ipid = -1;

Then a few lines below, locate the following:

strcpy( buf, inet_ntoa( sock.sin_addr ) );
sprintf( log_buf, "Sock.sinaddr: %s, port %hd.", buf, dnew->port );
log_string_plus( log_buf, LOG_COMM, sysdata.log_level );
if ( sysdata.NO_NAME_RESOLVING )
dnew->host = STRALLOC( buf );
else
{
from = gethostbyaddr( (char *) &sock.sin_addr, sizeof(sock.sin_addr), AF_INET );
dnew->host = STRALLOC( (char *)( from ? from->h_name : buf) );
}

Change it to read as follows:

strncpy( log_buf, inet_ntoa( sock.sin_addr ), MAX_STRING_LENGTH );
dnew->host = STRALLOC( log_buf );
if( !sysdata.NO_NAME_RESOLVING )
{
strncpy( buf, in_dns_cache( log_buf ), MAX_STRING_LENGTH );

if( buf[0] == '\0' )
resolve_dns( dnew, sock.sin_addr.s_addr );
else
{
STRFREE( dnew->host );
dnew->host = STRALLOC( buf );
}
}

Then locate function accept_new and find the following:

/*
* Poll all active descriptors.
*/
FD_ZERO( &in_set );
FD_ZERO( &out_set );
FD_ZERO( &exc_set );
FD_SET( ctrl, &in_set );
maxdesc = ctrl;
newdesc = 0;
for ( d = first_descriptor; d; d = d->next )
{
maxdesc = UMAX( maxdesc, d->descriptor );
FD_SET( d->descriptor, &in_set );
FD_SET( d->descriptor, &out_set );
FD_SET( d->descriptor, &exc_set );
if ( d == last_descriptor )
break;
}

Change that to read as follows:

/*
* Poll all active descriptors.
*/
FD_ZERO( &in_set );
FD_ZERO( &out_set );
FD_ZERO( &exc_set );
FD_SET( ctrl, &in_set );
maxdesc = ctrl;
newdesc = 0;
for( d = first_descriptor; d; d = d->next )
{
maxdesc = UMAX( maxdesc, d->descriptor );
FD_SET( d->descriptor, &in_set );
FD_SET( d->descriptor, &out_set );
FD_SET( d->descriptor, &exc_set );
if( d->ifd != -1 && d->ipid != -1 )
{
maxdesc = UMAX( maxdesc, d->ifd );
FD_SET( d->ifd, &in_set );
}
if( d == last_descriptor )
break;
}

Then locate function game_loop and find the following:

if ( d->character && d->character->wait > 0 )
{
--d->character->wait;
continue;
}

Directly ABOVE that, add the following:

/* check for input from the dns */
if( ( d->connected == CON_PLAYING || d->character != NULL ) && d->ifd != -1 && FD_ISSET( d->ifd, &in_set ) )
process_dns( d );

Then locate function close_socket and find the following:

/* flush outbuf */
if ( !force && dclose->outtop > 0 )
flush_buffer( dclose, FALSE );

Directly ABOVE that, add the following:

if( dclose->ipid != -1 )
{
int status;

kill( dclose->ipid, SIGKILL );
waitpid( dclose->ipid, &status, 0 );
}
if( dclose->ifd != -1 )
close( dclose->ifd );

5. Open db.c, and locate the following in boot_db:

/*
* Assign gsn's for skills which need them.
*/

Directly ABOVE that, add:

log_string( "Loading DNS cache..." ); /* Samson 1-30-02 */
load_dns();

6. Open update.c, and find the following in update_handler:

if ( --pulse_second <= 0 )
{
pulse_second = PULSE_PER_SECOND;
char_check( );
reboot_check(0);
}

Change it to read as follows:

if( --pulse_second <= 0 )
{
pulse_second = PULSE_PER_SECOND;
char_check( );
check_dns( );
reboot_check( 0 );
}

7. For users of copyover/hotboot only:

In copyover_recover/hotboot_recover, locate the following:

CREATE( d, DESCRIPTOR_DATA, 1 );

d->next = NULL;
d->descriptor = desc;
d->connected = CON_GET_NAME;
d->outsize = 2000;
d->idle = 0;
d->lines = 0;
d->scrlen = 24;
d->newstate = 0;
d->prevcolor = 0x07;

Directly below that, add the following:

d->ifd = -1;
d->ipid = -1;

8. Make clean, recompile.

9. Reboot.

10. Create a "cache" command.
Attached file:

Filename: dns.c
Size: 11 KB
Downloads: 4
Attached file:

Filename: dns.h
Size: 3 KB
Downloads: 3
Attached file:

Filename: resolver.c
Size: 4 KB
Downloads: 5
       
Pages:<< prev 1 next >>