Import Upstream version 0.0.8 upstream/0.0.8
authorThadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Fri, 11 Aug 2017 22:35:25 +0000 (19:35 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Fri, 11 Aug 2017 22:35:25 +0000 (19:35 -0300)
Changes
META.yml
sendxmpp

diff --git a/Changes b/Changes
index 45b5477..bfae7c4 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,15 @@
+2005-05-07: version 0.0.8 released.
+       - add options to specify non-default ports
+       - updated documentation
+
+2005-05-02: version 0.0.7 released / version 0.0.7.1.
+       - add --interactive mode to send from stdin line-by-line
+       - fix for typo ==> 0.0.7.1
+       - documentation updates
+
+2004-12-07: version 0.0.6 released.
+       - fix for installation paths 
+
 2004-12-01: version 0.0.5 released.
        - don't be too picky about passwords
        - verbose output
index 3e2695b..becf49d 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         sendxmpp
-version:      0.0.7.1
+version:      0.0.8
 version_from: sendxmpp
 installdirs:  site
 requires:
index 0c9452e..fd6523e 100755 (executable)
--- a/sendxmpp
+++ b/sendxmpp
@@ -1,6 +1,9 @@
 #!/usr/bin/perl -w
+
+eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
+    if 0; # not running under some shell
 #-*-mode:perl-*-
-#Time-stamp: <2005-05-02 01:00:02 (djcb)>
+#Time-stamp: <2005-05-07 19:24:09 (djcb)>
 
 # script to send message using xmpp (aka jabber), 
 #   somewhat resembling mail(1)
@@ -15,7 +18,7 @@ use Getopt::Long;
 use strict;
 
 # subroutines decls
-sub xmpp_login($$$$$$);
+sub xmpp_login($$$$$$$);
 sub xmpp_send ($$$);
 sub xmpp_send_message($$$$);
 sub xmpp_send_chatroom_message($$$$$);
@@ -30,7 +33,7 @@ sub terminate();
 sub main();
 
 my # MakeMaker
-$VERSION     = '0.0.7.1';
+$VERSION     = '0.0.8';
 my $RESOURCE = 'sendxmpp';
 my $VERBOSE  = 0;
 my $DEBUG    = 0;
@@ -55,6 +58,7 @@ sub main () {
     
     # login to xmpp
     my $cnx =  xmpp_login ($$cmdline{'jserver'}  || $$config{'jserver'},
+                          $$cmdline{'port'}     || $$config{'port'},
                           $$cmdline{'username'} || $$config{'username'},
                           $$cmdline{'password'} || $$config{'password'},
                           $$cmdline{'resource'},
@@ -132,10 +136,16 @@ sub read_config_file ($) {
        
        s/\#.*$//; # ignore comments in lines
        
-       if (/([-\.\w]+)@([-\.\w]+)\s+(\S+)\s*$/) {
+       if (/([-\.\w]+)@([-\.\w:]+)\s+(\S+)\s*$/) {
            %config = ('username' => $1,
                       'jserver'  => $2, 
+                      'port'     => 0,
                       'password' => $3);
+
+           if ($config{'jserver'} =~ /(.*):(\d+)/) {
+               $config{'jserver'} = $1;
+               $config{'port'}    = $2;
+           }
        } else {
            close CFG;
            error_exit ("syntax error in line $line of $cfg_file");
@@ -166,7 +176,7 @@ sub parse_cmdline () {
     
     usage() unless (scalar(@ARGV));
     
-    my ($subject,$file,$resource,$jserver,$username,$password,
+    my ($subject,$file,$resource,$jserver,$port,$username,$password,
        $message,$chatroom,$debug,$tls,$interactive,$help,$verbose);
     my $res = GetOptions ('subject|s=s'    => \$subject,
                          'file|f=s'       => \$file,
@@ -187,13 +197,19 @@ sub parse_cmdline () {
     my $rcpt = $ARGV[0]
       or error_exit "no recipient specified";
  
-   if ($message && $interactive) {
-       error_exit "cannot have both -m (--message) and -i (--interactive)\n";
-   } 
+    if ($message && $interactive) {
+       error_exit "cannot have both -m (--message) and -i (--interactive)\n";
+    } 
+    
+    if ($jserver && $jserver =~ /(.*):(\d+)/) {
+       $jserver = $1;
+       $port    = $2;
+    }
        
     my %dict = ('subject'     => ($subject  or ''),
                'resource'    => ($resource or $RESOURCE),
                'jserver'     => ($jserver or ''),
+               'port'        => ($port or 0),
                'username'    => ($username or ''),
                'password'    => ($password or ''),
                'chatroom'    => ($chatroom or 0),
@@ -216,20 +232,25 @@ sub parse_cmdline () {
 
 #
 # xmpp_login: login to the xmpp (jabber) server
-# input: hostname,username,password,resource,tls,debug
+# input: hostname,port,username,password,resource,tls,debug
 # output: an XMPP connection object
 #
-sub xmpp_login ($$$$$$) {
+sub xmpp_login ($$$$$$$) {
 
-    my ($host,$user,$pw,$res,$tls,$debug) = @_;
+    my ($host,$port,$user,$pw,$res,$tls,$debug) = @_;
     my $cnx = new Net::XMPP::Client(debuglevel=>($debug?2:0));
     error_exit "could not create XMPP client object: $!"
        unless ($cnx);    
 
-    my @res = $cnx->Connect(hostname=>$host,tls=>$tls);
+    my @res;
+    if (!$port) {
+       @res = $cnx->Connect(hostname=>$host,tls=>$tls);
+    } else {
+       @res = $cnx->Connect(hostname=>$host,port=>$port,tls=>$tls);
+    }
+
     xmpp_check_result("Connect",\@res,$cnx);
 
-    
     @res = $cnx->AuthSend('hostname' => $host,
                          'username' => $user,
                          'password' => $pw,
@@ -338,8 +359,8 @@ sub xmpp_check_result {
     my ($txt,$res,$cnx)=@_;
     
     error_exit ("Error '$txt': result undefined")
-       unless (defined $res);  
-
+       unless (defined $res);
+  
     # res may be 0
     if ($res == 0) {
        debug_print "$txt";
@@ -433,7 +454,7 @@ B<-p>,B<--password> <password>
 use <password> instead of the one in the configuration file
 
 B<-j>,B<--jserver> <server>
-use jabber server <server> instead of the one in the configuration file
+use jabber server <server> instead of the one in the configuration file. Note that you can add :<port> to use a non-default port, ie. B<-j myjabber.org:1234>
 
 B<-r>,B<--resource> <res>
 use resource <res> for the sender [default: 'sendxmpp']; when sending to a chatroom, this determines the 'alias'
@@ -475,7 +496,11 @@ e.g.:
     # my account
     alice@jabber.org  secret
 
-('#' and newlines are allowed like in shellscripts)
+('#' and newlines are allowed like in shellscripts). You can add :<port> to
+the <host> if you need an alternative port, ie.
+
+    # account with weird port number
+    alice@myjabberhost.com:1234 secret
     
 B<NOTE>: for your security, sendxmpp demands that the configuration
 file is owned by you and has file permissions 600.
@@ -488,6 +513,12 @@ file is owned by you and has file permissions 600.
 
    $ echo "Dinner Time" | sendxmpp -r TheCook --chatroom test2@conference.jabber.org    
 
+     or to send your system logs somewhere, as new lines appear:
+   
+   $ tail -f /var/log/syslog | sendxmpp -i sysadmin@myjabberserver.com
+     
+     NOTE: be careful not the overload public jabber services
+     
 =head1 SEE ALSO
 
 Documentation for the L<Net::XMPP> module