[JDEV] juddi, a JUD component using Jabber::Connection
Thanks to DJ Adams, I have a component that can store (but not yet retrieve) JUD info from a MySQL database... I intend this to be a teaching example (for myself as well, since I'm learning), so I hope you enjoy! #!/usr/bin/perl # juddi.pl, a JUD component that uses Database Independent libraries # # # Migs Paraz <[EMAIL PROTECTED]> November 9, 2001 # Initial release - only "Register" works, written for MySQL # License: GNU GPL, as this is a teaching example. # # TODO: # Search function # External config file. XML? # Make it easy to change database backends. # How to implement searches that take long without blocking other clients? # # Current table: # create table juddi (jid varchar(32) not null primary key, # first varchar(32), last varchar(32), # nick varchar(32), email varchar(64)) # use Jabber::Connection; use Jabber::NodeFactory; use Jabber::NS qw(:all); use DBI; use DBD::mysql; use strict; Configuration section our $config_jabber_server = "localhost:1234"; our $config_jabber_password = "test"; our $config_localname = "jud.localhost"; our $config_log = 1; # Database our $config_db_database = "jabber"; our $config_db_username = "jabber"; our $config_db_password = "imjabber"; our $config_db_table= "juddi"; # Fields for display and for database. our %config_db_fields = ("first" => "first", "last" => "last", "nick" => "nick", "email" => "email"); # This is an ordered list since it will come out in the dialog box. our @config_jud_list = ("first", "last", "nick", "email"); # Text our $config_text_search = "juddi search"; our $config_text_register = "juddi register"; ### # Keep state in between connections our %state; our $c = new Jabber::Connection( ns => "jabber:component:accept", server => $config_jabber_server, localname => $config_localname, log=> $config_log, ); $c->connect or die "oops: ".$c->lastError; $c->register_handler('message', \&message); $c->register_handler('iq', \&iq); $c->auth($config_jabber_password); # Connect to the database. We will autocommit. # TODO allow change of db my $cn = "dbi:mysql:" . $config_db_database; our $dbh = DBI->connect($cn, $config_db_username, $config_db_password, { AutoCommit => 1 }); if (!defined ($dbh)) { # TODO: There should be a nicer reporting method. die ($dbh->errstr); } # We only have one constant select, which is for the register method. # This will come out like: # INSERT INTO juddi (jid, first, last, nick, email) VALUES (?, ?, ?, ?, ?) # jid will always be present. # This ugly loop, because Perl can't duplicate lists. my @q; for (my $i = 0; $i < $#config_jud_list + 2; $i++) { push (@q, "?"); } my $statement = "INSERT INTO " . $config_db_table . " (jid, " . join (",", map {$config_db_fields{$_}} @config_jud_list) . ") VALUES (" . join (",", @q) . ")"; our $sth_register = $dbh->prepare($statement); Main Loop $c->start(); # This never gets called since the entire loop is in the start() call. $c->disconnect(); sub message { my $node = shift; print "Message --> ", $node->toStr, "\n"; } sub iq { my $node = shift; # Different kinds of XML content # Get list for register or search. # Pretend we're not yet registered. # (Make a database for that!) if ($node->attr("type") eq IQ_GET) { my $id = $node->attr("id"); # Create a new node for the reply. my $nf = new Jabber::NodeFactory; my $tag = $nf->newNode("iq"); $tag->attr("type", IQ_RESULT); $tag->attr("from", "jud.localhost"); $tag->attr("id", $id); # Set "to" to original "from" $tag->attr("to", $node->attr("from")); my $tag2 = $tag->insertTag("query", NS_SEARCH); foreach my $k (@config_jud_list) { $tag2->insertTag($k); } # Key is needed to keep state between searches. my $key = time(); $tag2->insertTag("key")->data($key); # Store the from and id so we can reply later $state{"from"}{$key} = $node->attr("from"); my $data; if ($node->getTag("query", NS_SEARCH)) { $data = $config_text_search; } elsif ($node->getTag("query", NS_REGISTER)) { $data = $config_text_register; } $tag2->insertTag("instructions")->data($data); # Send back to client $c->send($tag); } elsif (($node->attr("type") eq IQ_SET) && (my $tag = $node->getTag("query", NS_SEARCH))) { my $id = $node->attr("id"); # Construct a bogus result. # Grab parameters and store in a hash. my %param; foreach my $k (@config_jud_list) { my $tag2 = $tag->getTag($k); if (defined ($tag2)) { $param{$k} = $tag2->data(); } } my $nf = new Jabber::NodeFactory; my $ta
Re: [JDEV] Foreign protocol transports using Jabber::Connection?
I do! Cheers. On Thu, Nov 08, 2001 at 06:42:51PM +0800, Migs Paraz wrote: > On Wed, Nov 07, 2001 at 05:28:08PM +, DJ Adams wrote: > > Well, considering that you can do pretty much what you want with > > Jabber XML using Jabber::NodeFactory (and the fact that the API > > sort of reflects the xmlnode library used in the jabber.org server > > anyway), I'd say yes. > > > > But then I'm biased, of course. Jabber::Connection is what I use, > > but it is still comparatively "young". > > > well I've proven it works with my "JUD" (to which I'll add DBI database > calls later)... now I'll try writing a test transport for foreign IM's. > > any other Jabber::Connection users out there? > ___ > jdev mailing list > [EMAIL PROTECTED] > http://mailman.jabber.org/listinfo/jdev ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
Re: [JDEV] Offline message quotas?
On Thu, Nov 08, 2001 at 06:38:42PM +0800, Migs Paraz wrote: > > > > Well, I'm wondering what will break first, disk space or the > > XML library functions ... > > Whichever case, it would be a denial of service for the server operator, so > we need to watch out for it before it happens? Well, perhaps. But don't forget the karma settings for the server which could be used to hinder such a DOS attack - unless the attacker was extremely patient or had nothing better to do than to write a script to trickle-feed messages ... dj ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
Re: [JDEV] Foreign protocol transports using Jabber::Connection?
On Thu, Nov 08, 2001 at 05:04:33PM -, Ben Schumacher wrote: > That being said, there is not reason you'd have to do threading for a > transport. You just need to be able to associate each ICQ connection with Agreed. No requirement to use threads. dj ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
Re: [JDEV] Foreign protocol transports using Jabber::Connection?
On Thu, Nov 08, 2001 at 06:42:51PM +0800, Migs Paraz wrote: > any other Jabber::Connection users out there? Me! Me! ;-) dj ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
Re: [JDEV] sub agents?
On Thu, Nov 08, 2001 at 11:18:08AM -0700, Brian Lalor wrote: > Can someone give me a quick overview of subagents? how do you set up the > jabber.xml (or do you?) to let it know that they exist, and how should the > master agent behave? Hi Brian by subagents, do you mean components that connect to a Jabber server? dj ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
[JDEV] trusted component documentation
Hi, Can anyone provide pointers to documentation/protocol spec on Jabber trusted components? I need to implement a service/app that will synchronize buddy list of an external system with Jabber roster. My limited understanding of Jabber is pointing me to the direction of using a trusted component to achieve this (forcing roster updates, i.e. no user approval process involved & intercept all roster requests so I can sync the other way, Jabber => external system). I need the protocol spec between trusted component & Jabber server and any config/setup spec any one can provide or points to. Thank you very much. - Lily Chang ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
Re: [JDEV] sub agents?
On Fri, 9 Nov 2001, DJ Adams wrote: > On Thu, Nov 08, 2001 at 11:18:08AM -0700, Brian Lalor wrote: > > Can someone give me a quick overview of subagents? how do you set up the > > jabber.xml (or do you?) to let it know that they exist, and how should the > > master agent behave? > > Hi Brian > > by subagents, do you mean components that connect to a Jabber server? Well, in my dictionary, an agent is a component that connects to the server, and then exposes other agents "below" itself in the tree. So: . jabber.org `-- agent1 |-- agent1-1 `-- agent1-2 agent1-1 and 1-2 are then sub-agents of agent1. In my pooled user idea I was talking about earlier in the week, there'd be a pool agent/component that exposes sub-agents that are the pooled aliases. For example: . jabber.org `-- PooledAliases |-- [EMAIL PROTECTED] `-- [EMAIL PROTECTED] I know I've seen something like multi-level agents on jabber.org before; maybe the irc component? It probably has something to do with jabber:iq:agents that gets answered by the component and not the server. _ B r i a n L a l o r [EMAIL PROTECTED] http://hcirisc.cs.binghamton.edu/~blalor Spam me not. To get my pgp key, put "get pgp key" in the subject of your message At Group L, Stoffel oversees six first-rate programmers, a managerial challenge roughly comparable to herding cats. -The Washington Post Magazine, June 9, 1985 ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
[JDEV] test
test ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
[JDEV] ICQ Transport problems, messages don't reach dest, etc...
Hi all, first at all, thanks for reading this mail. Second, I'm experiencing problems with ICQ from some time ago, I don't get any error, the problem is this: I open jabber, and I receive a lot of messages sent to me while I was offline, but after I close and open jabber again, I receive the messages again!! The other problem is even worse, I see when the people logs in and out, and I can send them a few messages, and later they don't receive my messages, I don't get any error, but the messages get lost in the cyberspace!!! This is worse, because the people thinks that I don't want to talk them!! hehe... I don't know if it's jabber particular problem, I think the people @ ICQ have changed something in the protocol, and the ICQ transport now is having these problems... If it's something like this, I can help fixing it (bah, I can try to help :) I'm in Linux, using gabber to connect, and MSN and Yahoo works very good... I'm using my own configured jabber server, maybe it's something in the configuration! Well, if you have any ideas, just let me know! Thanks a lot!! P.D. Sorry if my english is not very good, please tell if I've made some errors so I can improve my english! thanks! ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
[JDEV] IMAP Authentication module?
Has anyone built a Jabber module to authenticate against an IMAP server? Preferably, the xdb_file would still hold all other user information, with just the authentication being done against an IMAP (or POP) server. This would be very useful for any site (like ours) which has a large number of user already registered and do not want to have to have yet another authentication scheme for the Jabber service. Make password changing ands signups a whole lot easier to manage. Thanks in advance. -- -Barry Flanagan CTO, DigiServe Ltd. Dublin, Ireland ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
[JDEV] Jabber client for win32
Hi, I'm trying to implement a Jabber client for the WinCe environment running on a native hardware. I have successfully built the jabberooce library with the help of jaberooce library provided by movsoftware. Now can somebody please help me how I should go about building the client using the same library. If there is someone who can help me on the use of the jabberoo client library to build client on the win32 environment. Kamal
Re: [JDEV] Foreign protocol transports using Jabber::Connection?
That being said, there is not reason you'd have to do threading for a transport. You just need to be able to associate each ICQ connection with a Jabber connection. And you need to setup your software to be able to wait for input from either the ICQ connections or the Jabber server. Basically, threads are used to allow you to schedule events and such, but just because they aren't available doesn't mean that you won't be able to write a transport. That doesn't mean its not going to be hard, you'll probably just run into issues more important than whether you can do threading. Ben On Thu, 8 Nov 2001, Richard Dobson wrote: > I dont think you can do threading in Perl, not the last time I was > programming in it a year ago anyway. > > > On Thu, Nov 08, 2001 at 06:42:51PM +0800, I wrote: > > I find that the Jabber part is really easy! Just trial and error with > > gabber to see what is sent to the Perl client, then look it up in > > jabber-programmers.pdf. > > > > Now the hard part: > > I find that threads are used in the transport code (I looked at AIM and > ICQ) > > and I would assume that they are needed since a single transport pretends > > to be the IM user for each of the clients. > > > > Any suggestions on how to implement this in Perl? I have no experience > > in threads in any language... :( ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
[JDEV] broken tcp connections
Perhaps it's a known problem - today I wondered why one contact didn't go offline, while I knew that the computer the client ran on was disconnected from the network. tcpdump showed that jabberd tried to send packets to the clients, but got no reply. Probably due to the client's firewall setup, it didn't get a RST or port/host unreachable. So it took a fairly long time until the tcp connection timed out and the server noticed the client went offline. Even worse, messages sent to this contact during the time he was 'offline without notice' got lost. I assume the jabber server already pushed them to the tcp stream and assumed they got delivered. A first step towards a solution would be shortening the tcp timeout. I don't know much about tcp programming, but I think it's possible for an application to set the timeout? Jan ___ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
[JDEV] Jabber help required.
- Original Message - From: Parul Agarwal To: [EMAIL PROTECTED] Sent: Friday, November 09, 2001 12:15 PM Subject: Jabber help required. Hi there, I had recently installed jabber server - jabber-1.4.1 on my Linux machine. I have been using winjab and jabber cleints. Till sometime, I had been using this jabber on my LAN to chat with people who are connected on my LAN. I had a requirement to allow people from ouside of my LAN to allow access to my jabber server. My LAN is placed on a firewall. When I tried to creatye a user from outside of my LAN, i found that it was unable to create the user. When I ran jabber server in debug mode, it showed that a session was established for that user but soon the session got terminated. On my client, I got the following error message. The error message said that COMM ERROR: Couldnot establish Stream. Session closed (0) Can you pls help me out and let me know as to why is this error coming up?? Regards, Parul