/[virtual-ldap]/bin/ldap-rewrite.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/ldap-rewrite.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 27 by dpavlin, Mon Mar 16 18:11:12 2009 UTC revision 29 by dpavlin, Tue Mar 17 09:39:05 2009 UTC
# Line 31  my $config = { Line 31  my $config = {
31  my $log_fh;  my $log_fh;
32    
33  sub log {  sub log {
34          open($log_fh, '>', $config->{log_file}) || die "can't open ", $config->{log_file},": $!";          if ( ! $log_fh ) {
35                    open($log_fh, '>>', $config->{log_file}) || die "can't open ", $config->{log_file},": $!";
36                    print $log_fh "# " . time;
37            }
38          $log_fh->autoflush(1);          $log_fh->autoflush(1);
39          print $log_fh join("\n", @_),"\n";          print $log_fh join("\n", @_),"\n";
40  }  }
# Line 77  sub handle { Line 80  sub handle {
80  sub log_request {  sub log_request {
81          my $pdu=shift;          my $pdu=shift;
82    
83          print '-' x 80,"\n";  #       print '-' x 80,"\n";
84          print "Request ASN 1:\n";  #       print "Request ASN 1:\n";
85          Convert::ASN1::asn_hexdump(\*STDOUT,$pdu);  #       Convert::ASN1::asn_hexdump(\*STDOUT,$pdu);
86          print "Request Perl:\n";  #       print "Request Perl:\n";
87          my $request = $LDAPRequest->decode($pdu);          my $request = $LDAPRequest->decode($pdu);
88          print dump($request);          warn "## request = ",dump($request);
89  }  }
90    
91  sub log_response {  sub log_response {
92          my $pdu=shift;          my $pdu=shift;
93    
94          print '-' x 80,"\n";  #       print '-' x 80,"\n";
95          print "Response ASN 1:\n";  #       print "Response ASN 1:\n";
96          Convert::ASN1::asn_hexdump(\*STDOUT,$pdu);  #       Convert::ASN1::asn_hexdump(\*STDOUT,$pdu);
97          print "Response Perl:\n";  #       print "Response Perl:\n";
98          my $response = $LDAPResponse->decode($pdu);          my $response = $LDAPResponse->decode($pdu);
99    
100          if ( defined $response->{protocolOp}->{searchResEntry} ) {          if ( defined $response->{protocolOp}->{searchResEntry} ) {
# Line 133  sub log_response { Line 136  sub log_response {
136                  $pdu = $LDAPResponse->encode($response);                  $pdu = $LDAPResponse->encode($response);
137          }          }
138    
139          print dump($response);          warn "## response = ", dump($response);
140    
141          return $pdu;          return $pdu;
142  }  }
# Line 174  my $listenersock = IO::Socket::INET->new Line 177  my $listenersock = IO::Socket::INET->new
177          Proto => 'tcp',          Proto => 'tcp',
178          Reuse => 1,          Reuse => 1,
179          LocalAddr => $config->{listen},          LocalAddr => $config->{listen},
180  );  ) || die "can't open listen socket: $!";
181    
182    
183  my $targetsock = $config->{upstream_ssl}  my $targetsock = $config->{upstream_ssl}
# Line 184  my $targetsock = $config->{upstream_ssl} Line 187  my $targetsock = $config->{upstream_ssl}
187                  PeerPort => 389,                  PeerPort => 389,
188          )          )
189          : IO::Socket::SSL->new( $config->{upstream_ldap} . ':ldaps')          : IO::Socket::SSL->new( $config->{upstream_ldap} . ':ldaps')
190          ;          || die "can't open upstream socket: $!";
191    
192    binmode( $listenersock );
193    binmode( $targetsock );
194    
195  run_proxy($listenersock,$targetsock);  run_proxy($listenersock,$targetsock);
196    

Legend:
Removed from v.27  
changed lines
  Added in v.29

  ViewVC Help
Powered by ViewVC 1.1.26