18 |
use fields qw(socket target); |
use fields qw(socket target); |
19 |
use YAML qw/LoadFile/; |
use YAML qw/LoadFile/; |
20 |
|
|
21 |
|
my $config = { |
22 |
|
yaml_dir => './yaml/', |
23 |
|
listen => 'localhost:1389', |
24 |
|
upstream_ldap => 'ldap.ffzg.hr', |
25 |
|
upstream_ssl => 1, |
26 |
|
overlay_prefix => 'ffzg-', |
27 |
|
|
28 |
|
}; |
29 |
|
|
30 |
|
if ( ! -d $config->{yaml_dir} ) { |
31 |
|
warn "DISABLE ", $config->{yaml_dir}," data overlay"; |
32 |
|
} |
33 |
|
|
34 |
|
warn "# config = ",dump( $config ); |
35 |
|
|
36 |
sub handle { |
sub handle { |
37 |
my $clientsocket=shift; |
my $clientsocket=shift; |
38 |
my $serversocket=shift; |
my $serversocket=shift; |
92 |
} @{ $response->{protocolOp}->{searchResEntry}->{attributes} }; |
} @{ $response->{protocolOp}->{searchResEntry}->{attributes} }; |
93 |
} |
} |
94 |
|
|
95 |
my $path = "yaml/$uid.yaml"; |
my $path = $config->{yaml_dir} . "$uid.yaml"; |
96 |
if ( -e $path ) { |
if ( -e $path ) { |
97 |
my $data = LoadFile($path); |
my $data = LoadFile($path); |
98 |
warn "# yaml = ",dump($data); |
warn "# yaml = ",dump($data); |
105 |
my @vals = split(/\s*#\s*/, $vals); |
my @vals = split(/\s*#\s*/, $vals); |
106 |
|
|
107 |
push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, |
push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, |
108 |
{ type => "ffzg-$type", vals => [ @vals ] }; |
{ type => $config->{overlay_prefix} . $type, vals => [ @vals ] }; |
109 |
} |
} |
110 |
} |
} |
111 |
|
|
150 |
Listen => 5, |
Listen => 5, |
151 |
Proto => 'tcp', |
Proto => 'tcp', |
152 |
Reuse => 1, |
Reuse => 1, |
153 |
LocalPort => 1389 |
LocalAddr => $config->{listen}, |
154 |
); |
); |
155 |
|
|
156 |
|
|
157 |
my $targetsock = new IO::Socket::INET ( |
my $targetsock = $config->{upstream_ssl} |
158 |
Proto => 'tcp', |
? IO::Socket::INET->new( |
159 |
PeerAddr => 'ldap.ffzg.hr', |
Proto => 'tcp', |
160 |
PeerPort => 389, |
PeerAddr => $config->{upstream_ldap}, |
161 |
); |
PeerPort => 389, |
162 |
|
) |
163 |
$targetsock = IO::Socket::SSL->new("ldap.ffzg.hr:ldaps"); |
: IO::Socket::SSL->new( $config->{upstream_ldap} . ':ldaps') |
164 |
|
; |
165 |
|
|
166 |
run_proxy($listenersock,$targetsock); |
run_proxy($listenersock,$targetsock); |
167 |
|
|