#!/usr/local/bin/perl # This software is Copyright (c) 1996 Jeff Weisberg # Other than removing this notice, do with this code as you wish... # snnd (SillyNetNewsDaemon) # keep all of the alt.nudie.pictures and alt.| Date: $date EOH ; $body = <> $logfile"); log_info(); print "200 op.net SillyNetNews NNRP server SNN 1.4unoff4 05-Mar-96 ready (posting ok).\r\n"; # change ^^^^^^ this to your site while( <> ){ s/\r//g; print LOG "$$: ($host): $_"; alarm( 300 ); if( /^list/i ){ print "215 list of newsgroups follows\r\n"; open( ACTIVE, $active ); while( ){ chop; print "$_\r\n"; } close ACTIVE; print ".\r\n"; }elsif( /^quit/i ){ print "205 Bye Bye!\r\n"; exit; }elsif( /^group/i ){ split; print "211 8723 146926 155649 $_[1]\r\n"; }elsif( /^article/i ){ print "220 123456 article retrieved - head and body follow\r\n$head\r\n$body.\r\n"; }elsif( /^head/i ){ print "221 123456 article retrieved - head follows\r\n$head.\r\n"; }elsif( /^body/i ){ print "222 123456 article retrieved - body follows\r\n$body.\r\n"; }elsif( /^stat/i ){ print "223 123456 article retrieved - request text separately\r\n"; }elsif( /^help/i ){ print "100\r\n"; print "HELP prints this message\r\nAnd nothing more\r\n.\r\n"; }elsif( /^post/i ){ print "340 send article to be posted. End with .\r\n"; while( <> !~ /^\.\s*$/ ){ ; } print "240 article posted ok\r\n"; }else{ print "500 error\r\n"; } } sub log_info { # get remote address for logfile # most connections come from dialup ppp connections # so we don't bother trying to get ident info $rsa = getpeername( STDIN ); ($family, $rport, $raddr) = unpack('S n a4', $rsa); ($name, $aliases, $addrtype, $length, $address) = gethostbyaddr($raddr, 2); @octets = unpack ("CCCC", $raddr); # use dotted quad if lookup failed $name = join ('.', @octets[0..3]) unless $name; $host = $name; print LOG "\n$$: $host ", `date`; }