-#! /bin/sh
+#! /usr/local/bin/bash
# libtool - Provide generalized library-building support services.
# Generated automatically by (GNU bopm 3.1.0)
# ### BEGIN LIBTOOL CONFIG
-# Libtool was configured on host fullers:
+# Libtool was configured on host thales.strtok.co.uk:
# Shell to use when invoking shell scripts.
-SHELL="/bin/sh"
+SHELL="/usr/local/bin/bash"
# Whether or not to build shared libraries.
build_libtool_libs=yes
build_old_libs=yes
# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=no
+build_libtool_need_lc=yes
# Whether or not to optimize for fast installation.
fast_install=yes
# The host system.
host_alias=
-host=i686-pc-linux-gnu
+host=i386-unknown-freebsd4.8
# An echo program that does not interpret backslashes.
echo="echo"
with_gcc=yes
# The linker used to build libraries.
-LD="/usr/i686-pc-linux-gnu/bin/ld"
+LD="/usr/libexec/elf/ld"
# Whether we need hard or soft links.
LN_S="ln -s"
thread_safe_flag_spec=""
# Library versioning type.
-version_type=linux
+version_type=freebsd-elf
# Format of library name prefix.
libname_spec="lib\$name"
# List of archive names. First name is the real one, the rest are links.
# The last name is the one that the linker finds with -lNAME.
-library_names_spec="\${libname}\${release}.so\$versuffix \${libname}\${release}.so\$major \$libname.so"
+library_names_spec="\${libname}\${release}.so\$versuffix \${libname}\${release}.so \$libname.so"
# The coded name of the library, if different from the real name.
-soname_spec="\${libname}\${release}.so\$major"
+soname_spec=""
# Commands used to build and install an old-style archive.
RANLIB="ranlib"
no_undefined_flag=""
# Commands used to finish a libtool library installation in a directory.
-finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir"
+finish_cmds=""
# Same as above, but a single script fragment to be evaled but not shown.
finish_eval=""
--- /dev/null
+#!/usr/bin/perl
+#Copyright (C) 2002 Erik Fears
+#
+#This program is free software; you can redistribute it and/or
+#modify it under the terms of the GNU General Public License
+#as published by the Free Software Foundation; either version 2
+#of the License, or (at your option) any later version.
+#
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+#along with this program; if not, write to the Free Software
+#
+# Foundation, Inc.
+# 59 Temple Place - Suite 330
+# Boston, MA 02111-1307, USA.
+
+
+
+use strict;
+use Event;
+use Socket;
+use IO::Select;
+use IO::Socket::INET;
+
+
+
+#Options
+my %BOPM = (
+ HOSTNAME => 'bopm.scanner', #Our bopm hostname
+ IP => '127.0.0.1', #Our bopm's introduced IP
+
+ PORT => 5555,
+ PASS => 'bopm', #Our bopm's password
+ );
+
+
+my %IRC = (
+ NAME => 'bopm.blitzed.org', #Our server name
+ HOST => 'localhost', #Remote server we're linking to
+ PORT => '6667', #Port of remote server we're linking to
+ PASS => 'link', #Link password from C/N
+ );
+
+
+#Bahamut
+my %PROTOCOL = (
+ NICK => '{nick} 1 {ts} +o {username} {hostname} {server} 0 {ip} :{realname}',
+ CAPAB => 'TS3 NOQUIT SSJOIN BURST UNCONNECT NICKIP TSMODE',
+ );
+
+my %NICKFORMAT = (
+ NICK => 1,
+ USERNAME => 5,
+ HOSTNAME => 6,
+ SERVER => 7,
+ IP => 9,
+ REALNAME => 10,
+ );
+
+
+my %IRC_FUNCTIONS = (
+ '001' => \&m_perform,
+ 'PING' => \&m_ping,
+ 'PRIVMSG' => \&m_privmsg,
+ 'NICK' => \&m_nick,
+ );
+
+my %BOPM_FUNCTIONS = (
+ 'NICK' => \&bopm_nick,
+ 'USER' => \&bopm_user,
+ 'PASS' => \&bopm_pass,
+ );
+
+#Global Variables
+my $IRC_SOCKET; #IRC Connection
+my $IRC_DATA; #Data read from IRC
+
+my $BOPM_SOCKET; #Bopm connection
+my $BOPM_DATA; #Data read from BOPM
+my $BOPM_WAITING = 0; #bool, waiting for data?
+
+my $SELECT = new IO::Select;
+
+main();
+
+# main
+#
+# Main initializes the main listening socket
+# and handles the main daemon loop.
+
+sub main #()
+{
+ my $read;
+
+ bopm_listen();
+
+ irc_init();
+ irc_connect();
+
+ while(true)
+ {
+ irc_cycle();
+ }
+
+}
+
+
+# do_log
+#
+# Log!
+
+sub do_log #($data)
+{
+ my $data = $_[0];
+ print STDOUT "[" . scalar localtime() . "] " . $data . "\n";
+}
+
+
+# init
+#
+# Initialize IRC socket
+#
+
+sub irc_init #()
+{
+ if(!socket($IRC_SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp')))
+ {
+ do_log(sprintf('IRC -> Error initializing IRC socket: %s', $!));
+ die;
+ }
+
+ $SELECT->add($$IRC_SOCKET);
+}
+
+
+# irc_cycle
+#
+# Run select() on the IRC client and bopm connections to
+# check for new data. Reconnect if needed.
+
+sub irc_cycle #()
+{
+ my $handle;
+ my $newhandle;
+ my $dcc;
+ my @ready;
+ my @errored;
+
+ #do error events
+ @errored = $SELECT->has_error(0);
+
+ foreach $handle (@errored)
+ {
+ if($handle == $$IRC_SOCKET)
+ {
+ do_log('IRC -> IRC socket has_error');
+ irc_reconnect();
+ next;
+ }
+
+ if($handle == $BOPM_SOCKET)
+ {
+ do_log('BOPM -> BOPM socket has_error');
+ bopm_listen();
+ next;
+ }
+ }
+
+
+ #do read events
+ @ready = $SELECT->can_read(.1);
+
+ foreach $handle (@ready)
+ {
+ #Data from IRC server
+ if($handle == $$IRC_SOCKET)
+ {
+ irc_read();
+ next;
+ }
+
+ #Connect to $BOPM_LISTEN
+ if(($handle == $BOPM_SOCKET) && $BOPM_WAITING)
+ {
+ do_log('BOPM -> Got connection');
+ $SELECT->remove($BOPM_SOCKET);
+ $BOPM_SOCKET = $BOPM_SOCKET->accept();
+ $SELECT->add($BOPM_SOCKET);
+ $BOPM_WAITING = 0;
+ next
+ }
+
+ if($handle == $BOPM_SOCKET)
+ {
+ bopm_read();
+ next;
+ }
+ }
+}
+
+# irc_connect
+#
+# Connect to IRC and send registration data
+#
+
+sub irc_connect #()
+{
+ if(!connect($$IRC_SOCKET, sockaddr_in($IRC{PORT}, inet_aton($IRC{HOST}))))
+ {
+ do_log(sprintf('IRC -> Error connecting to IRC host: %s', $!));
+ }
+
+ irc_send(sprintf('PASS %s', $IRC{PASS}));
+ irc_send(sprintf('CAPAB %s',$PROTOCOL{CAPAB}));
+ irc_send(sprintf('SERVER %s', $IRC{NAME}));
+}
+
+
+
+# irc_reconnect
+#
+# Reconnct to IRC server
+#
+
+sub irc_reconnect #()
+{
+
+ do_log('IRC -> Reconnecting to server');
+
+ close($$IRC_SOCKET);
+ $SELECT->remove($$IRC_SOCKET);
+
+ sleep(30);
+
+ if(!socket($IRC_SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp')))
+ {
+ do_log(sprintf('IRC -> Error initializing IRC socket: %s', $!));
+ die;
+ }
+
+ irc_connect();
+}
+
+
+
+# irc_send
+#
+# Send data to IRC server
+#
+# $_[0] IRC Data to send
+
+sub irc_send #($data)
+{
+ my $data = $_[0];
+
+
+ do_log(sprintf('IRC SEND -> %s', $data));
+
+ $data .= "\n\n";
+
+ if(!send($$IRC_SOCKET, $data, 0))
+ {
+ do_log(sprintf('IRC -> send() error: %s', $!));
+ irc_reconnect();
+ }
+}
+
+
+# irc_read
+#
+# Read data from IRC server
+#
+
+sub irc_read #()
+{
+ my $data;
+ my $pos;
+ my $line;
+
+ if(sysread($$IRC_SOCKET, $data, 512) == 0)
+ {
+ do_log('IRC -> Read error from server');
+ irc_reconnect();
+ return;
+ }
+
+ $data = $IRC_DATA . $data;
+
+ while(($pos = index($data, "\n")) != -1)
+ {
+ $line = substr($data, 0, $pos + 1, "");
+ chomp $line;
+ irc_parse($line);
+ }
+ $IRC_DATA = $data;
+}
+
+
+
+sub irc_parse #($line)
+{
+ my $line = $_[0];
+
+ my @parv;
+ my $command;
+ my $message;
+ my %source;
+
+ chomp $line;
+
+ do_log(sprintf('IRC READ -> %s', $line));
+
+ @parv = split(/\s+/, substr($line, 0, index($line, ':', 1)));
+ $message = substr($line, index($line, ':', 1) + 1, length($line));
+
+ push @parv, $message;
+
+ if($parv[0] =~ /:/)
+ {
+ $parv[0] = substr($parv[0], 1, length($parv[0]));
+ }
+ else
+ {
+ unshift @parv, $IRC{HOST};
+ }
+
+ #parse the nick!user@host if it exists
+ if($parv[0] =~ /([^!]+)!([^@]+)@(.*)/)
+ {
+ $source{nickname} = $1;
+ $source{username} = $2;
+ $source{hostname} = $3;
+ $source{is_user} = 1;
+ }
+ else { $source{is_user} = 0; }
+
+
+ if(exists($IRC_FUNCTIONS{$parv[1]}))
+ {
+ $IRC_FUNCTIONS{$parv[1]}(\@parv, \%source);
+ }
+}
+
+
+# m_ping
+#
+# PING from server.
+#
+# parv[0] = SOURCE
+# parv[1] = PING
+# parv[2] = PACKAGE
+#
+
+sub m_ping # \@parv, \%source
+{
+ my $parv = $_[0];
+ irc_send(sprintf('PONG :%s', $$parv[2]));
+}
+
+
+
+# m_perform
+#
+# Successfull connection (perform)
+#
+
+sub m_perform # \@parv, \%source
+{
+ my $parv = $_[0];
+}
+
+
+# m_privmsg
+#
+# privmsg to channel OR user
+#
+# parv[0] source
+# parv[1] PRIVMSG
+# parv[2] target
+# parv[3] message
+
+sub m_privmsg #\@parv, \%source
+{
+ my $parv = $_[0];
+ my $source = $_[1];
+}
+
+# m_nick
+#
+
+sub m_nick
+{
+ my $parv = $_[0];
+ my $conn;
+
+ if(@$parv <= 3)
+ {
+ return;
+ }
+ shift @$parv;
+
+ $conn = sprintf(':%s NOTICE %s :*** Notice -- Client connecting: %s (%s@%s) [%s] {class}',
+ $IRC{HOST},
+ $BOPM{NICK},
+ $$parv[$NICKFORMAT{NICK}],
+ $$parv[$NICKFORMAT{USERNAME}],
+ $$parv[$NICKFORMAT{HOSTNAME}],
+ inet_ntoa(pack("N", $$parv[$NICKFORMAT{IP}])),
+ );
+ #send hybrid connection notice
+ bopm_send($conn);
+}
+
+
+########################################## BOPM #####################################################
+
+sub bopm_listen
+{
+
+ if($BOPM_SOCKET)
+ {
+ bopm_close();
+ }
+
+ $BOPM_SOCKET = new IO::Socket::INET( Proto => "tcp",
+ Listen => 1,
+ LocalPort => $BOPM{PORT});
+ $SELECT->add($BOPM_SOCKET);
+
+ if(!$BOPM_SOCKET)
+ {
+ do_log(sprintf('BOPM -> Could not bind to port %d', $BOPM{PORT}));
+ exit;
+ }
+
+ $BOPM_WAITING = 1;
+}
+
+sub bopm_close
+{
+ $SELECT->remove($BOPM_SOCKET);
+ close($BOPM_SOCKET);
+
+ irc_send(sprintf(':%s QUIT :Dead', $BOPM{NICK}))
+}
+
+
+# bopm_read
+#
+# Read data from bopm
+#
+
+sub bopm_read #()
+{
+ my $data;
+ my $pos;
+ my $line;
+
+ if(sysread($BOPM_SOCKET, $data, 512) == 0)
+ {
+ do_log('BOPM -> Read error from bopm');
+ bopm_listen();
+ return;
+ }
+
+ $data = $BOPM_DATA . $data;
+
+ while(($pos = index($data, "\n")) != -1)
+ {
+ $line = substr($data, 0, $pos + 1, "");
+ chomp $line;
+ bopm_parse($line);
+ }
+ $BOPM_DATA = $data;
+}
+
+
+sub bopm_parse
+{
+ my $line = $_[0];
+
+ my @parv;
+ my $command;
+ my $message;
+ my %source;
+
+ chomp $line;
+
+ do_log(sprintf('BOPM READ -> %s', $line));
+
+ @parv = split(/\s+/, substr($line, 0, index($line, ':')));
+ $message = substr($line, index($line, ':') + 1, length($line));
+
+ push @parv, $message;
+
+ if(exists($BOPM_FUNCTIONS{$parv[0]}))
+ {
+ $BOPM_FUNCTIONS{$parv[0]}(\@parv);
+ }
+ else
+ {
+ irc_send(sprintf(':%s %s', $BOPM{NICK}, $line));
+ }
+}
+
+# bopm_send
+#
+# Send data to bopm
+
+sub bopm_send #($data)
+{
+ my $data = $_[0];
+
+ return if($BOPM_WAITING);
+
+ do_log(sprintf('BOPM SEND -> %s', $data));
+
+ $data .= "\n\n";
+
+ if(!send($BOPM_SOCKET, $data, 0))
+ {
+ do_log(sprintf('BOPM -> send() error: %s', $!));
+ bopm_listen();
+ }
+}
+
+sub bopm_introduce
+{
+ my $nick;
+
+ #Form NICK line
+ $nick = $PROTOCOL{NICK};
+
+ $nick =~ s/\{nick\}/$BOPM{NICK}/g;
+ $nick =~ s/\{username\}/$BOPM{USERNAME}/g;
+ $nick =~ s/\{hostname\}/$BOPM{HOSTNAME}/g;
+ $nick =~ s/\{server\}/$IRC{NAME}/g;
+ $nick =~ s/\{ip\}/69/g;
+ $nick =~ s/\{realname\}/$BOPM{REALNAME}/g;
+ $nick =~ s/\{ts\}/1/g;
+
+ irc_send(sprintf('NICK %s', $nick));
+}
+
+
+sub bopm_nick
+{
+ my $parv = $_[0];
+ $BOPM{NICK} = $$parv[1];
+}
+
+sub bopm_user
+{
+ my $parv = $_[0];
+
+ $BOPM{USERNAME} = $$parv[1];
+ $BOPM{REALNAME} = $$parv[4];
+ bopm_introduce();
+ bopm_send("001 Welcome to BOPM!");
+}