From 8e1477e9ea1100cba32f4b93eed3990e529ebc14 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Wed, 20 May 2009 09:59:33 +0000 Subject: [PATCH] * switch order of memorizing own address and patching source tag * move one case of answer processing to a new place git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13653 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 49 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 684315b33..43ca76ccb 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -883,16 +883,15 @@ sub send_msg_to_target { $header = ""; } + # Memorize own source address + my $own_source_address = &get_local_ip_for_remote_ip(sprintf("%s", $address =~ /^([0-9\.]*?):.*$/)); + $own_source_address .= ":".$server_port; + # Patch the source ip if($msg =~ /0\.0\.0\.0:\d*?<\/source>/) { - my $remote_ip = &get_local_ip_for_remote_ip(sprintf("%s", $address =~ /^([0-9\.]*?):.*$/)); - $msg =~ s/(0\.0\.0\.0):(\d*?)<\/source>/$remote_ip:$2<\/source>/s; + $msg =~ s/(0\.0\.0\.0):(\d*?)<\/source>/$own_source_address<\/source>/s; } - # Memorize own source address - $msg =~ /(\S+)<\/source>/; - my $own_source_address = $1; - # encrypt xml msg my $crypted_msg = &encrypt_msg($msg, $encrypt_key); @@ -1174,25 +1173,6 @@ sub msg_to_decrypt { } } - # target is a client address in known_clients -> process here - if (not $done) { - $sql = "SELECT * FROM $known_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')"; - $res = $known_clients_db->select_dbentry($sql); - if (keys(%$res) > 0) { - $done = 1; - my $hostname = $res->{1}->{'hostname'}; - $msg =~ s/$target<\/target>/$hostname<\/target>/; - my $local_address = &get_local_ip_for_remote_ip($target_ip).":$server_port"; - if ($source eq "GOSA") { - $msg =~ s/<\/xml>/$local_address,$session_id<\/forward_to_gosa><\/xml>/; - } - &daemon_log("$session_id DEBUG: target is a client address in known_clients -> process here", 7); - - } else { - $not_found_in_known_clients_db = 1; - } - } - # target ist own address with forward_to_gosa-tag not pointing to myself -> process here if (not $done) { my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; @@ -1251,6 +1231,25 @@ sub msg_to_decrypt { } + # target is a client address in known_clients -> forward to client + if (not $done) { + $sql = "SELECT * FROM $known_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')"; + $res = $known_clients_db->select_dbentry($sql); + if (keys(%$res) > 0) { + $done = 1; + my $key = $res->{1}->{'hostkey'}; + my $error= &send_msg_to_target($msg, $target, $key, $header, $session_id); + if ($error) { + &daemon_log("$session_id ERROR: some problems (error=$error) occurred while trying to send msg to client: $msg", 1); + } + + &daemon_log("$session_id DEBUG: target is a client address in known_clients -> forward to client", 7); + + } else { + $not_found_in_known_clients_db = 1; + } + } + # target is a client address in foreign_clients -> forward to registration server if (not $done) { $sql = "SELECT * FROM $foreign_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')"; -- 2.30.2