Code

* change regex for outgoing messages, now '-' is allowed
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 5 Jun 2009 08:53:24 +0000 (08:53 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 5 Jun 2009 08:53:24 +0000 (08:53 +0000)
* hostnames as source in outgoing messages are substituted with ip:port

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13695 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/tests/client.php

index 3bce9a9b76daa4511f3a4e271d9653bed94dc5ee..e8dbfae9fd7d6d11c8fe316d60122ca2670c3f42 100755 (executable)
@@ -655,15 +655,17 @@ sub check_outgoing_xml_validity {
             die 'source has length 0';
         }
 
-                               # Check if source contains hostname instead of ip address
-                               if($source =~ /^[a-z][a-z0-9\.]+:\d+$/i) {
-                                               my ($hostname,$port) = split(/:/, $source);
-                                               my $ip_address = inet_ntoa(scalar gethostbyname($hostname));
-                                               if(defined($ip_address) && $ip_address =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ && $port =~ /^\d+$/) {
-                                                       # Write ip address to $source variable
-                                                       $source = "$ip_address:$port";
-                                               }
-                               }
+               # Check if source contains hostname instead of ip address
+               if($source =~ /^[a-z][\w-\.]+:\d+$/i) {
+                       my ($hostname,$port) = split(/:/, $source);
+                       my $ip_address = inet_ntoa(scalar gethostbyname($hostname));
+                       if(defined($ip_address) && $ip_address =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ && $port =~ /^\d+$/) {
+                               # Write ip address to $source variable
+                               $source = "$ip_address:$port";
+                               $msg_hash->{source}[0] = $source ;
+                               $msg =~ s/<source>.*<\/source>/<source>$source<\/source>/; 
+                       }
+               }
         unless( $source =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$/ ||
                 $source =~ /^GOSA$/i) {
             die "source '$source' is neither a complete ip-address with port nor 'GOSA'";
@@ -695,7 +697,7 @@ sub check_outgoing_xml_validity {
         $msg_hash = undef;
     }
 
-    return ($msg_hash);
+    return ($msg, $msg_hash);
 }
 
 
@@ -1527,7 +1529,7 @@ sub process_task {
 
         foreach my $answer ( @{$answer_l} ) {
             # check outgoing msg to xml validity
-            my $answer_hash = &check_outgoing_xml_validity($answer, $session_id);
+            my ($answer, $answer_hash) = &check_outgoing_xml_validity($answer, $session_id);
             if( not defined $answer_hash ) { next; }
             
             $answer_header = @{$answer_hash->{'header'}}[0];
index bcf3f3010212a62ae8c3eb3c2f03bcffad6f5f50..a6e88f97a32955d5a97faf9f64a3fe3777d3d99b 100755 (executable)
@@ -77,7 +77,7 @@ for($count = 1; $count <= $zahl; $count++)
     #$data = "<xml> <header>gosa_get_client_for_login_usr</header> <target>GOSA</target> <source>GOSA</source> <usr>rettenbe</usr></xml>";
 
     # List all si-server providing opsi
-    $data = "<xml> <header>gosa_get_hosts_with_module</header> <source>GOSA</source> <target>00:0C:29:4C:4B:0C</target> <module_name>mailqueue_com</module_name> </xml>";
+    $data = "<xml> <header>gosa_get_hosts_with_module</header> <source>GOSA</source> <target>linux-cl-7:20081</target> <module_name>opsi</module_name> </xml>";
 
     # Send messages to a user and displayed message via konch
     #$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <subject>".base64_encode("eine wichtige nachricht")."</subject> <from>admin</from>  <user>polle</user> <user>harald</user> <delivery_time>20130101235959</delivery_time> <message>".base64_encode("kaffeepause")."</message> </xml>";