From 29f7b1b0944f4d1e8ed5a57c8ff3e54b6239e3c9 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Thu, 7 May 2009 15:17:13 +0000 Subject: [PATCH] * server adding their ip:port at the end of their msg too, as clients already do * set daemon_log lines in the correct order git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13634 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-client | 6 ++++-- gosa-si/gosa-si-server | 14 +++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index d2084e2ab..ee8be12b0 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -1005,11 +1005,13 @@ sub server_input { my $error = 0; my $answer; - daemon_log("INFO: Incoming msg from '$remote_ip'", 5); daemon_log("DEBUG: Incoming msg:\n$input\n", 9); - my ($msg, $msg_hash) = &check_key_and_xml_validity($input, $server_key); + # Cut of ip and port from msgs tail + my ($encrypted_msg, $msg_source) = split(/;/, $input); + + my ($msg, $msg_hash) = &check_key_and_xml_validity($encrypted_msg, $server_key); if( (!$msg) || (!$msg_hash) ) { daemon_log("WARNING: Deciphering of incoming msg failed", 3); if($server_address =~ /$remote_ip/) { diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index e652480a3..079e86761 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -889,19 +889,23 @@ sub send_msg_to_target { $msg =~ s/(0\.0\.0\.0):(\d*?)<\/source>/$remote_ip:$2<\/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); # opensocket my $socket = &open_socket($address); if( !$socket ) { - daemon_log("$session_id WARNING: cannot send ".$header."msg to '$address' , host not reachable", 3); + daemon_log("$session_id WARNING: cannot send ".$header."msg to '$address' , host not reachable! Message: '$msg'", 3); $error++; } if( $error == 0 ) { # send xml msg - print $socket $crypted_msg."\n"; + print $socket $crypted_msg.";$own_source_address\n"; daemon_log("$session_id INFO: send ".$header."msg to $address", 5); daemon_log("$session_id DEBUG: message:\n$msg", 9); @@ -1078,13 +1082,13 @@ sub msg_to_decrypt { if(( !$msg ) || ( !$msg_hash ) || ( !$module )){ # if an incoming msg could not be decrypted (maybe a wrong key), send client a ping. If the client # could not understand a msg from its server the client cause a re-registering process - my $remote_ip = $heap->{'remote_ip'}; + daemon_log("$session_id WARNING cannot understand incoming msg, send 'ping'-msg to all host with ip '".$heap->{remote_ip}. + "' to cause a re-registering of the client if necessary", 3); + my $remote_ip = $heap->{'remote_ip'}; my $remote_port = $heap->{'remote_port'}; my $ping_msg = "
gosa_ping
$server_address$msg_source
"; my ($test_error, $test_error_string) = &send_msg_to_target($ping_msg, "$msg_source", "dummy-key", "gosa_ping", $session_id); - daemon_log("$session_id WARNING cannot understand incoming msg, send 'ping'-msg to all host with ip '".$heap->{remote_ip}. - "' to cause a re-registering of the client if necessary", 3); $error++; } -- 2.30.2