| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: /mirror/gungho/lib/Gungho/Engine.pm 31637 2007-12-01T14:04:35.046822Z lestrrat $ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp> |
|
4
|
|
|
|
|
|
|
# All rights reserved. |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Gungho::Engine; |
|
7
|
1
|
|
|
1
|
|
3456
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
21
|
|
|
9
|
1
|
|
|
1
|
|
2
|
use base qw(Gungho::Base); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_virtual_methods($_) for qw(run stop); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub finish_request |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
0
|
|
|
0
|
1
|
|
my ($self, $c, $request) = @_; |
|
16
|
0
|
0
|
|
|
|
|
if (my $host = $request->notes('original_host')) { |
|
17
|
|
|
|
|
|
|
# Put it back |
|
18
|
0
|
|
|
|
|
|
$request->uri->host($host); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub handle_response |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
0
|
|
|
0
|
1
|
|
my ($self, $c, $request, $response) = @_; |
|
25
|
0
|
|
|
|
|
|
$self->finish_request($c, $request); |
|
26
|
0
|
|
|
|
|
|
$c->handle_response($request, $response); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub handle_dns_response |
|
30
|
|
|
|
|
|
|
{ |
|
31
|
0
|
|
|
0
|
1
|
|
my ($self, $c, $request, $dns_response) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if (! $dns_response) { |
|
34
|
0
|
|
|
|
|
|
return; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
foreach my $answer ($dns_response->answer) { |
|
38
|
0
|
0
|
|
|
|
|
next unless $answer->type eq 'A'; |
|
39
|
0
|
0
|
|
|
|
|
return if $c->handle_dns_response($request, $answer, $dns_response); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$c->handle_response($request, $c->_http_error(500, "Failed to resolve host " . $request->uri->host, $request)), |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Gungho::Engine - Base Class For Gungho Engine |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
package Gungho::Engine::SomeEngine; |
|
56
|
|
|
|
|
|
|
use strict; |
|
57
|
|
|
|
|
|
|
use base qw(Gungho::Engine); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub run |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
|
|
|
|
|
|
.... |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 handle_dns_response() |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Handles the response from DNS lookups. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 handle_response |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Call finish_request() on the request, and delegates to Gungho's |
|
73
|
|
|
|
|
|
|
hnalde_response() |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 finish_request |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Perform whatever cleanup required on the request |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 run() |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Starts the engine. The exact behavior differs between each engines |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 stop() |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Stops the engine. The exact behavior differs between each engines |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |