summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: aafab82)
raw | patch | inline | side by side (parent: aafab82)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 5 Feb 2008 09:41:18 +0000 (09:41 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 5 Feb 2008 09:41:18 +0000 (09:41 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8744 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-client | patch | blob | history |
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index 1f0ae9b9ba4115943da54a9f2c4dc06a8e45f668..e483eb326bc36371e9718bc7bd5123de81dbd37e 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
use Digest::MD5 qw(md5_hex md5 md5_base64);
use MIME::Base64;
use XML::Simple;
-
-
-#use Fcntl;
-#use Sys::Syslog qw( :DEFAULT setlogsock);
-#use File::Spec;
-#use Cwd;
-
-
+use Net::DNS;
my $event_dir = "/usr/lib/gosa-si/client/events";
use lib "/usr/lib/gosa-si/client/events";
sub get_server_addresses {
my $domain= shift;
my @result;
- my $dig_cmd= 'dig +nocomments srv _gosad._tcp.'.$domain;
-
- my $output= `$dig_cmd 2>&1`;
- open (PIPE, "$dig_cmd 2>&1 |");
- while(<PIPE>) {
- chomp $_;
- # If it's not a comment
- if($_ =~ m/^[^;]/) {
- my @matches= split /\s+/;
-
- # Push hostname with port
- if($matches[3] eq 'SRV') {
- push @result, $matches[7].':'.$matches[6];
- } elsif ($matches[3] eq 'A') {
- my $i=0;
-
- # Substitute the hostname with the ip address of the matching A record
- foreach my $host (@result) {
- if ((split /\:/, $host)[0] eq $matches[0]) {
- $result[$i]= $matches[4].':'.(split /\:/, $host)[1];
- }
- $i++;
+
+ my $error = 0;
+ my $res = Net::DNS::Resolver->new;
+ my $query = $res->send("_gosad._tcp.".$domain, "SRV");
+ my @hits;
+
+ if ($query) {
+ foreach my $rr ($query->answer) {
+ push(@hits, $rr->target.":".$rr->port);
+ }
+ }
+ else {
+ #warn "query failed: ", $res->errorstring, "\n";
+ $error++;
+ }
+
+ if( $error == 0 ) {
+ foreach my $hit (@hits) {
+ my ($hit_name, $hit_port) = split(/:/, $hit);
+
+ my $address_query = $res->send($hit_name);
+ if( 1 == length($address_query->answer) ) {
+ foreach my $rr ($address_query->answer) {
+ push(@result, $rr->address.":".$hit_port);
}
}
}
}
- close(PIPE);
+
+# my $dig_cmd= 'dig +nocomments srv _gosad._tcp.'.$domain;
+#
+# my $output= `$dig_cmd 2>&1`;
+# open (PIPE, "$dig_cmd 2>&1 |");
+# while(<PIPE>) {
+# chomp $_;
+# # If it's not a comment
+# if($_ =~ m/^[^;]/) {
+# my @matches= split /\s+/;
+#
+# # Push hostname with port
+# if($matches[3] eq 'SRV') {
+# push @result, $matches[7].':'.$matches[6];
+# } elsif ($matches[3] eq 'A') {
+# my $i=0;
+#
+# # Substitute the hostname with the ip address of the matching A record
+# foreach my $host (@result) {
+# if ((split /\:/, $host)[0] eq $matches[0]) {
+# $result[$i]= $matches[4].':'.(split /\:/, $host)[1];
+# }
+# $i++;
+# }
+# }
+# }
+# }
+# close(PIPE);
return @result;
}