line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
#=============================================================================== |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# FILE: DirectI.pm |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# DESCRIPTION: POE::Component::Client::Whois::Smart::DirectI; |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# FILES: --- |
9
|
|
|
|
|
|
|
# BUGS: --- |
10
|
|
|
|
|
|
|
# NOTES: --- |
11
|
|
|
|
|
|
|
# AUTHOR: Pavel Boldin (), |
12
|
|
|
|
|
|
|
# COMPANY: |
13
|
|
|
|
|
|
|
# VERSION: 1.0 |
14
|
|
|
|
|
|
|
# CREATED: 24.05.2009 19:09:08 MSD |
15
|
|
|
|
|
|
|
# REVISION: --- |
16
|
|
|
|
|
|
|
#=============================================================================== |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package POE::Component::Client::Whois::Smart::DirectI; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
1019
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
21
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
979
|
use Time::HiRes qw( time ); |
|
1
|
|
|
|
|
2037
|
|
|
1
|
|
|
|
|
7
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
1461
|
use Net::Whois::Raw::Common; |
|
1
|
|
|
|
|
95585
|
|
|
1
|
|
|
|
|
49
|
|
26
|
1
|
|
|
1
|
|
425
|
use SOAP::DirectI::Serialize; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use SOAP::DirectI::Parse; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Data::Dumper; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Tie::Cache::LRU; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
tie my %directi_cache, 'Tie::Cache::LRU', 200; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use POE qw/Component::Client::HTTP/; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub DEBUG { 1 } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub initialize { |
40
|
|
|
|
|
|
|
POE::Component::Client::HTTP->spawn( |
41
|
|
|
|
|
|
|
Alias => 'ua_directi', |
42
|
|
|
|
|
|
|
Timeout => 10, #$self->{request}->{timeout}, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return 1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub query_order { |
49
|
|
|
|
|
|
|
10; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub query { |
53
|
|
|
|
|
|
|
my $class = shift; |
54
|
|
|
|
|
|
|
my $query_list = shift; |
55
|
|
|
|
|
|
|
my $heap = shift; |
56
|
|
|
|
|
|
|
my $args_ref = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my @my_queries; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
@$query_list = grep { |
61
|
|
|
|
|
|
|
if ( s/^directi:// ) { |
62
|
|
|
|
|
|
|
push @my_queries, $_; |
63
|
|
|
|
|
|
|
(); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
else { |
66
|
|
|
|
|
|
|
$_ |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} @$query_list; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#warn Dumper $args_ref; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
if ( @my_queries ) { |
73
|
|
|
|
|
|
|
++$heap->{tasks}; |
74
|
|
|
|
|
|
|
$class->get_whois_directi( |
75
|
|
|
|
|
|
|
\@my_queries, $heap, $args_ref, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub get_whois_directi { |
81
|
|
|
|
|
|
|
my ($package, $domains, $heap, $args_ref) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my @request_domains = grep { not exists $directi_cache{ $_ } } @$domains; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# warn Dumper $args_ref; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $self = bless { |
88
|
|
|
|
|
|
|
domains => $domains, |
89
|
|
|
|
|
|
|
request_domains => \@request_domains, |
90
|
|
|
|
|
|
|
request => $args_ref, |
91
|
|
|
|
|
|
|
result => $heap->{result}, |
92
|
|
|
|
|
|
|
}, $package; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$self->{session_id} = POE::Session->create( |
95
|
|
|
|
|
|
|
object_states => [ |
96
|
|
|
|
|
|
|
$self => [ |
97
|
|
|
|
|
|
|
qw( _start _done ) |
98
|
|
|
|
|
|
|
], |
99
|
|
|
|
|
|
|
], |
100
|
|
|
|
|
|
|
options => { trace => 0 }, |
101
|
|
|
|
|
|
|
)->ID(); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
if ( DEBUG ) { |
104
|
|
|
|
|
|
|
print time, " $self->{session_id}: Query ", |
105
|
|
|
|
|
|
|
join(', ', @$domains), " from DirectI\n" |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
return $self; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $_directi_signature = { |
113
|
|
|
|
|
|
|
'namespace' => 'com.logicboxes.foundation.sfnb.order.DomOrder', |
114
|
|
|
|
|
|
|
'args' => [ |
115
|
|
|
|
|
|
|
{ |
116
|
|
|
|
|
|
|
'type' => 'string', |
117
|
|
|
|
|
|
|
'key' => 'SERVICE_USERNAME', |
118
|
|
|
|
|
|
|
'hash_key' => 'service_username', |
119
|
|
|
|
|
|
|
}, |
120
|
|
|
|
|
|
|
{ |
121
|
|
|
|
|
|
|
'type' => 'string', |
122
|
|
|
|
|
|
|
'key' => 'SERVICE_PASSWORD', |
123
|
|
|
|
|
|
|
'hash_key' => 'service_password', |
124
|
|
|
|
|
|
|
}, |
125
|
|
|
|
|
|
|
{ |
126
|
|
|
|
|
|
|
'type' => 'string', |
127
|
|
|
|
|
|
|
'key' => 'SERVICE_ROLE', |
128
|
|
|
|
|
|
|
'hash_key' => 'service_role', |
129
|
|
|
|
|
|
|
}, |
130
|
|
|
|
|
|
|
{ |
131
|
|
|
|
|
|
|
'type' => 'string', |
132
|
|
|
|
|
|
|
'key' => 'SERVICE_LANGPREF', |
133
|
|
|
|
|
|
|
'hash_key' => 'service_langpref', |
134
|
|
|
|
|
|
|
}, |
135
|
|
|
|
|
|
|
{ |
136
|
|
|
|
|
|
|
'type' => 'int', |
137
|
|
|
|
|
|
|
'key' => 'SERVICE_PARENTID', |
138
|
|
|
|
|
|
|
'hash_key' => 'service_parentid', |
139
|
|
|
|
|
|
|
}, |
140
|
|
|
|
|
|
|
{ |
141
|
|
|
|
|
|
|
'elem_sig' => { |
142
|
|
|
|
|
|
|
'type' => 'string', |
143
|
|
|
|
|
|
|
'key' => 'item' |
144
|
|
|
|
|
|
|
}, |
145
|
|
|
|
|
|
|
'type' => 'array', |
146
|
|
|
|
|
|
|
'key' => 'domainNames' |
147
|
|
|
|
|
|
|
}, |
148
|
|
|
|
|
|
|
{ |
149
|
|
|
|
|
|
|
'elem_sig' => { |
150
|
|
|
|
|
|
|
'type' => 'string', |
151
|
|
|
|
|
|
|
'key' => 'item' |
152
|
|
|
|
|
|
|
}, |
153
|
|
|
|
|
|
|
'type' => 'array', |
154
|
|
|
|
|
|
|
'key' => 'tlds' |
155
|
|
|
|
|
|
|
}, |
156
|
|
|
|
|
|
|
{ |
157
|
|
|
|
|
|
|
'type' => 'boolean', |
158
|
|
|
|
|
|
|
'key' => 'suggestAlternative' |
159
|
|
|
|
|
|
|
}, |
160
|
|
|
|
|
|
|
], |
161
|
|
|
|
|
|
|
'name' => 'checkAvailabilityMultiple' |
162
|
|
|
|
|
|
|
}; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub _get_directi_request_body { |
165
|
|
|
|
|
|
|
my ($self, $names, $tlds) = @_; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
my $serializer = 'SOAP::DirectI::Serialize'; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
#warn Dumper $self->{request}{directi_params}; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my %directi_data = ( |
172
|
|
|
|
|
|
|
%{ $self->{request}{directi_params} }, |
173
|
|
|
|
|
|
|
domain_names => $names , |
174
|
|
|
|
|
|
|
tlds => $tlds , |
175
|
|
|
|
|
|
|
suggest_alternative => 0, |
176
|
|
|
|
|
|
|
); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
return $serializer->hash_to_soap( \%directi_data, $_directi_signature ); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub _start { |
182
|
|
|
|
|
|
|
my ($kernel, $self) = @_[KERNEL, OBJECT]; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
#warn @_[KERNEL, OBJECT]; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
my $url = $self->{request}{directi_params}{url}; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my (%names, %tlds); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
foreach my $query ( @{ $self->{request_domains} } ) { |
191
|
|
|
|
|
|
|
my ($name, $tld) = ($query =~ m/^([^\.]*)\.(.*)$/g); |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
$names{$name} = 1; |
194
|
|
|
|
|
|
|
$tlds{$tld} = 1; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
my @names = keys %names; |
198
|
|
|
|
|
|
|
my @tlds = keys %tlds; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
if ( ! @names ) { |
201
|
|
|
|
|
|
|
my $request = delete $self->{request}; |
202
|
|
|
|
|
|
|
my $session = $request->{manager_id}; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
my $response = { |
205
|
|
|
|
|
|
|
host => 'soap_directi', |
206
|
|
|
|
|
|
|
domains => $self->{domains}, |
207
|
|
|
|
|
|
|
}; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
$response->{data} = \%directi_cache; |
210
|
|
|
|
|
|
|
$self->_response( $response ); |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
#warn Dumper $response, \%directi_cache; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
$kernel->post( $session => $request->{event} => $response ); |
215
|
|
|
|
|
|
|
return; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
my $request = eval { _get_directi_request_body( $self, \@names, \@tlds ) }; |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
if ( ! $request && $@ ) { |
221
|
|
|
|
|
|
|
my $request = delete $self->{request}; |
222
|
|
|
|
|
|
|
my $session = $request->{manager_id }; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
$self->_response( { domains => $self->{domains}, error => $@ }); |
226
|
|
|
|
|
|
|
$kernel->post( $session => $request->{event} ); |
227
|
|
|
|
|
|
|
return; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
#warn $request; |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
my $header = HTTP::Headers->new; |
233
|
|
|
|
|
|
|
$header->header('SOAPAction' => ''); # set |
234
|
|
|
|
|
|
|
my $req = new HTTP::Request 'POST', $url, $header; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
$req->content_type('text/xml'); |
237
|
|
|
|
|
|
|
$req->content($request); |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
#warn $request; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
#warn Dumper $self->{request}; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
$kernel->alias_resolve('ua_directi')->[OBJECT]{factory}->timeout( |
244
|
|
|
|
|
|
|
$self->{request}->{timeout}, |
245
|
|
|
|
|
|
|
); |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
$kernel->post("ua_directi", "request", "_done", $req); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub _done { |
251
|
|
|
|
|
|
|
my ($kernel, $heap, $self, $request_packet, $response_packet) |
252
|
|
|
|
|
|
|
= @_[KERNEL, HEAP, OBJECT, ARG0, ARG1]; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# response obj |
256
|
|
|
|
|
|
|
my $http_response = $response_packet->[0]; |
257
|
|
|
|
|
|
|
# response content |
258
|
|
|
|
|
|
|
my $content = $http_response->content(); |
259
|
|
|
|
|
|
|
#warn "" . $content; |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
my $parser = SOAP::DirectI::Parse->new; |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
my $data; |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
#warn $content; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
eval { |
268
|
|
|
|
|
|
|
$parser->parse_xml_string( $content ); |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
($data) = $parser->fetch_data_and_signature; |
271
|
|
|
|
|
|
|
}; |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
#warn $content, $@; |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
my $response; |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
if ( $@ ) { |
278
|
|
|
|
|
|
|
$response->{error} = $content =~ /Timeout/i ? 'Timeout' : $@; |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
elsif ( exists $data->{faultstring} ) { |
281
|
|
|
|
|
|
|
$response->{error} = $data->{faultstring}; |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
else { |
284
|
|
|
|
|
|
|
$response->{data} = $data; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
my $request = delete $self ->{request}; |
289
|
|
|
|
|
|
|
my $session = delete $request->{manager_id}; |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
$response->{host} = 'soap_directi'; |
292
|
|
|
|
|
|
|
$response->{domains} = $self->{domains}; |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
#warn Dumper $content, $self->{response}, $data; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
$self->_response( $response ); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
$kernel->post( $session => $request->{event} => $response ); |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
undef; |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
sub _response { |
304
|
|
|
|
|
|
|
my $self = shift; |
305
|
|
|
|
|
|
|
my $response = shift; |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
my $data = $response->{data}; |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
foreach my $domain (keys %$data) { |
310
|
|
|
|
|
|
|
$directi_cache{$domain} = $data->{$domain}; |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
foreach my $domain (@{ $response->{domains} }) { |
314
|
|
|
|
|
|
|
my $status = $data->{ $domain }; |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
# warn $domain, Dumper $data, $response; |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
$status ||= { error => $response->{error} }; |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
push @{ $self->{result}{ 'directi:'.$domain } }, { |
321
|
|
|
|
|
|
|
query => $domain, |
322
|
|
|
|
|
|
|
whois => $status->{status}, |
323
|
|
|
|
|
|
|
server => 'directi', |
324
|
|
|
|
|
|
|
error => $status->{error}, |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
if ( DEBUG ) { |
329
|
|
|
|
|
|
|
# awainting 5.10 with //= |
330
|
|
|
|
|
|
|
$self->{session_id} = defined $self->{session_id} |
331
|
|
|
|
|
|
|
? $self->{session_id} : 'cached'; |
332
|
|
|
|
|
|
|
print time, |
333
|
|
|
|
|
|
|
" $self->{session_id}: DONE: Query ", |
334
|
|
|
|
|
|
|
join(', ',@{ $response->{domains} } ), " from DirectI\n" |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
#warn Dumper \%directi_cache; |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
#$heap->{tasks}--; |
341
|
|
|
|
|
|
|
# check_if_done( $kernel, $heap ); |
342
|
|
|
|
|
|
|
# return; |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
1; |