line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::ProxyHunter::Model::Schema::mysql; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2012
|
use Mo; |
|
1
|
|
|
|
|
673
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
1243
|
use Teng::Schema::Declare; |
|
1
|
|
|
|
|
70990
|
|
|
1
|
|
|
|
|
112
|
|
5
|
1
|
|
|
1
|
|
1315
|
use DateTime::Format::MySQL; |
|
1
|
|
|
|
|
262389
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
512
|
use App::ProxyHunter::Constants; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use App::ProxyHunter::Model::SchemaUtils qw'proxy_name_to_type proxy_type_to_name'; |
8
|
|
|
|
|
|
|
extends 'App::ProxyHunter::Model::Schema'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub perl_datetime_to_sql { |
13
|
|
|
|
|
|
|
return unless defined $_[0]; |
14
|
|
|
|
|
|
|
DateTime::Format::MySQL->format_datetime($_[0]); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub sql_datetime_to_perl { |
18
|
|
|
|
|
|
|
return unless defined $_[0] && $_[0] ne '0000-00-00 00:00:00'; |
19
|
|
|
|
|
|
|
DateTime::Format::MySQL->parse_datetime($_[0])->set_time_zone(TZ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
table { |
23
|
|
|
|
|
|
|
name 'proxy'; |
24
|
|
|
|
|
|
|
pk 'id'; |
25
|
|
|
|
|
|
|
columns qw( |
26
|
|
|
|
|
|
|
id |
27
|
|
|
|
|
|
|
host |
28
|
|
|
|
|
|
|
port |
29
|
|
|
|
|
|
|
checked |
30
|
|
|
|
|
|
|
success_total |
31
|
|
|
|
|
|
|
fails_total |
32
|
|
|
|
|
|
|
insertdate |
33
|
|
|
|
|
|
|
checkdate |
34
|
|
|
|
|
|
|
speed_checkdate |
35
|
|
|
|
|
|
|
fails |
36
|
|
|
|
|
|
|
type |
37
|
|
|
|
|
|
|
in_progress |
38
|
|
|
|
|
|
|
conn_time |
39
|
|
|
|
|
|
|
speed |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
inflate type => \&proxy_name_to_type; |
43
|
|
|
|
|
|
|
deflate type => \&proxy_type_to_name; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
for (qw/insertdate checkdate speed_checkdate/) { |
46
|
|
|
|
|
|
|
inflate $_ => \&sql_datetime_to_perl; |
47
|
|
|
|
|
|
|
deflate $_ => \&perl_datetime_to_sql; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
App::ProxyHunter::Model::Schema::mysql - MySQL schema for App::ProxyHunter |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# just edit proxyhunter's config |
62
|
|
|
|
|
|
|
db = { |
63
|
|
|
|
|
|
|
driver: "mysql" |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
You need to create database yourself, then use C<proxyhunter --create-schema> to create tables structure |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SEE ALSO |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L<App::ProxyHunter> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Oleg G, E<lt>oleg@cpan.orgE<gt> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
81
|
|
|
|
|
|
|
it under the same terms as Perl itself |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__DATA__ |
86
|
|
|
|
|
|
|
CREATE TABLE `proxy` ( |
87
|
|
|
|
|
|
|
`id` int(11) NOT NULL AUTO_INCREMENT, |
88
|
|
|
|
|
|
|
`host` varchar(15) NOT NULL, |
89
|
|
|
|
|
|
|
`port` smallint(5) unsigned NOT NULL, |
90
|
|
|
|
|
|
|
`checked` tinyint(1) NOT NULL DEFAULT '0', |
91
|
|
|
|
|
|
|
`success_total` int(11) NOT NULL DEFAULT '0', |
92
|
|
|
|
|
|
|
`fails_total` int(11) NOT NULL DEFAULT '0', |
93
|
|
|
|
|
|
|
`insertdate` datetime NOT NULL, |
94
|
|
|
|
|
|
|
`checkdate` datetime NOT NULL DEFAULT '1980-01-01 00:00:00', |
95
|
|
|
|
|
|
|
`speed_checkdate` datetime NOT NULL DEFAULT '1980-01-01 00:00:00', |
96
|
|
|
|
|
|
|
`fails` tinyint(1) NOT NULL DEFAULT '0', |
97
|
|
|
|
|
|
|
`type` enum('HTTPS_PROXY','HTTP_PROXY','CONNECT_PROXY','SOCKS4_PROXY','SOCKS5_PROXY','DEAD_PROXY') NOT NULL DEFAULT 'DEAD_PROXY', |
98
|
|
|
|
|
|
|
`in_progress` tinyint(1) NOT NULL DEFAULT '0', |
99
|
|
|
|
|
|
|
`conn_time` smallint(5) unsigned DEFAULT NULL, |
100
|
|
|
|
|
|
|
`speed` int(10) unsigned NOT NULL DEFAULT '0', |
101
|
|
|
|
|
|
|
PRIMARY KEY (`id`), |
102
|
|
|
|
|
|
|
UNIQUE KEY `proxy` (`host`,`port`), |
103
|
|
|
|
|
|
|
KEY `sort` (`checked`,`checkdate`), |
104
|
|
|
|
|
|
|
KEY `type` (`type`) |
105
|
|
|
|
|
|
|
); |