Setting up Component::External
Guillermo Roditi
groditi at gmail.com
Thu Dec 6 17:17:45 UTC 2007
Hello everyone,
I am trying to set up Component::External to listen in for the python
AIM transport but I am having trouble just getting it to open the
port. I don't use a config file, so I attached my code below.
The code is fairly simple, all it really does is get some config
options and start a couple of custom components and then initiate a
bunch of vhosts. Everything works fine, I just can't get the
Component::External thing to open the port. Curiously, it opens port
5269. The port I assigned it is 5270. I don't know if this has
anything to do with it, but i found it a curious coincidence. If
anyone could please tell me what I am doing wrong I'd be forever
grateful.
Part of me thinks that the plugin is never being registered. As in
$plugin->register is just never happeneing. I know the contructor
calls the register calls for all the plugins, but I am registering the
plugin afterwards through register subdomain. I am pretty confused.
The relevant code is directly below and the whole executable is below
that in case you are curious about it.
#@domains is a list of the domains we are starting vhosts for
#%vhost_args includes all the arguments that are global to all vhosts
(logging, auth, roster storage)
#$server is the server, duh.
for( @domains ){
my $aim = DJabberd::Component::External->new(
listenport => 5270,
secret => 'some_secret',
);
$aim->finalize;
my $vhost = DJabberd::VHost->new( %vhost_args, server_name => $_,);
$vhost->register_subdomain("aim", $aim);
$server->add_vhost($vhost);
}
--------------------------------------------------------------
#!/usr/bin/perl -w
BEGIN {
$ENV{LOGLEVEL} = "ERROR";
$^P |= 0x01 if $ENV{TRACE_DJABBERD};
use FindBin qw($Bin);
}
use strict;
use lib "${Bin}\/lib";
use DJabberd;
use Getopt::Long;
use Config::Simple;
use DJabberd::Delivery::Local;
use DJabberd::PresenceChecker::Local;
use Cantella::Jabber::RosterStorage;
use Cantella::Jabber::Authentication;
use Cantella::Jabber::Delivery;
use Cantella::Jabber::Schema;
use DJabberd::Component::External;
my $cfg = new Config::Simple('/scripts/master_config/config.ini');
my $db_host = $cfg->param('db_host');
my $db_user = $cfg->param('db_user');
my $db_pass = $cfg->param('db_pass');
my $dsn = 'dbi:mysql:dbname=Email_New;auto_reconnect=1;host=' . $db_host;
my $schema = Cantella::Jabber::Schema->connection
($dsn, $db_user, $db_pass, { quote_char => '`', name_sep => '.' } );
#$schema->storage->debug(1);
my $daemonize;
Getopt::Long::GetOptions('d|daemon' => \$daemonize );
my $delivery = DJabberd::Delivery::Local->new;
my $rs = Cantella::Jabber::RosterStorage->new(schema => $schema);
$rs->finalize;
#this plugin handles message logging
#in the future I'd like this to be a subclass of LocalDelivery
#with the ability to support multiple backends, but until then, egh
#it really is hacky, but whatever, you know?
my $log = Cantella::Jabber::Delivery->new(schema => $schema);
$log->finalize;
my $auth = Cantella::Jabber::Authentication->new(schema => $schema);
$auth->finalize;
#get all the domains we are handling email for and set up
# djabberd vhosts for them
my @domains = map{ $_->domain } $schema->resultset('User')
->search(undef, {select => ['domain'], distinct => 1})->all;
my %vhost_args = (
require_ssl => 0,
s2s => 0,
plugins => [$auth, $rs, $log, $delivery,],
);
my $server = DJabberd->new(daemonize => $daemonize);
my @vhosts;
for( @domains ){
my $aim = DJabberd::Component::External->new(
listenport => 5270,
secret => 'some_secret',
);
$aim->finalize;
my $vhost = DJabberd::VHost->new( %vhost_args, server_name => $_,);
$vhost->register_subdomain("aim", $aim);
$server->add_vhost($vhost);
}
$server->run;
More information about the Djabberd
mailing list