Code

Allow hostnames as source - just rewrite them to their resolved ip_address
authorjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 2 Oct 2008 15:41:50 +0000 (15:41 +0000)
committerjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 2 Oct 2008 15:41:50 +0000 (15:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12594 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server

index 2c4770cbc660b47ccc943b87ebe77c327ba41f8d..4f15e34c8f83f3771b5d43726ee2a55f7900d290 100755 (executable)
@@ -601,8 +601,18 @@ sub check_outgoing_xml_validity {
         if( 0 == length $source) {
             die 'source has length 0';
         }
+
+                               # Check if source contains hostname instead of ip address
+                               if($source !=~ /^[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";
+                                               }
+                               }
         unless( $source =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$/ ||
-                $source =~ /^GOSA$/i ) {
+                $source =~ /^GOSA$/i) {
             die "source '$source' is neither a complete ip-address with port nor 'GOSA'";
         }