[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: services (Re: ircd FAQ)



On Feb 16, Bjorn Reese wrote:
| Are there any services available now?

/lusers shows what's available to you.
I'm not aware of any service currently running on ircnet.
And if there is, a bug in 2.9.2 prevents its propagation on
the net.

[..]
| Server services seems to be the salvation for me. Unfortunately the
| documentation (at least in ircd2.9.2) is somewhat defective, and it is
| difficult to get an overview of the capabilites of services by reverse
| engineering ircd.

doc/INSTALL is about all you can get if you dont want to
RTFS.
include/service.h shows what the service can be allowed to
receive and ircd/s_service.c is all the code about services.

| I would like to obtain as much information as possible about these,
| including existing examples/sourcecode if possible. I would also like to

It takes 5 minutes to write, see my attachment.

Christophe
#/usr/local/bin/perl -w

require 5.002;

use Socket;
 
#
# configuration parameters for the service
#

# server to connect to
$server="millennium";
$passwd="passwd";
$port=6667;

# information about the service
$myname = "toto";
$mydist = "*";
$mytype = 0;
$myinfo = "Sample Service";
$admin = "name <e-mail>";

#
# set up connection
#
$iaddr = inet_aton($server) || die "no host: $server";
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(SOCK, $paddr) || die "connect: $!";
print "connected\n";

select SOCK; $| = 1;
select STDOUT;

print SOCK "PASS $passwd\nSERVICE $myname $server $mydist $mytype 0 :$myinfo\n";

while (<SOCK>)
{
	chop;
	if ( /^ERROR/ )
	{
		print "$_\n";
	}
	elsif ( /:(\S*) SQUERY \S* :(.*)$/ )
	{
		($nick , $query) = ($1, $2);
		print "Query from $nick: $query\n";	
		if ( $query =~ /^HELP/i )
		{
			print SOCK "NOTICE $nick :I'm a dumb service\n";
			print SOCK "NOTICE $nick :Commands: HELP, ADMIN\n";
		}
		elsif ( $query =~ /^ADMIN/i )
		{
			print SOCK "NOTICE $nick :Admin: $admin\n";
		}
		else
		{
			print SOCK "NOTICE $nick :Command not understood, try HELP\n";
		}
	}
	else
	{
		print "Unknown data: $_\n";
	}
}

close (SOCK) || die "close: $!";
exit;