line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Suffit::Const; |
2
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
3
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=encoding utf8 |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
WWW::Suffit::Const - The Suffit constants |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 1.00 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use WWW::Suffit::Const; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This module contains constants definitions |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 TAGS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 8 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item B<:GENERAL> |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Exports common constants |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item B<:SESSION> |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Exports session and token constants |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item B<:SECURITY> |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Exports security and cryptography constants |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item B<:MIME> |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Exports MIME constants |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item B<:MISC> |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Exports miscellaneous constants |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item B<:DICTS> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Exports dictionaries |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item B<:SERVER> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Exports server constants |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=back |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 HISTORY |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
See C file |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 TO DO |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
See C file |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SEE ALSO |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
L |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Serż Minus (Sergey Lepenkov) L Eabalama@cpan.orgE |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 COPYRIGHT |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Copyright (C) 1998-2023 D&D Corporation. All Rights Reserved |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
80
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
See C file and L |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
1
|
|
51
|
use vars qw/$VERSION @EXPORT @EXPORT_OK %EXPORT_TAGS/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
87
|
|
|
|
|
|
|
$VERSION = '1.00'; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
1
|
|
6
|
use base qw/Exporter/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
310
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use constant { |
92
|
1
|
50
|
|
|
|
574
|
PROJECTNAME => 'Suffit', |
|
|
50
|
|
|
|
|
|
93
|
|
|
|
|
|
|
PROJECTNAMEL => 'suffit', |
94
|
|
|
|
|
|
|
PROJECT_ABSTRACT => 'The Suffit core library', |
95
|
|
|
|
|
|
|
DEFAULT_URL => 'http://localhost', |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# System constants |
98
|
|
|
|
|
|
|
IS_TTY => (-t STDOUT) ? 1 : 0, |
99
|
|
|
|
|
|
|
IS_ROOT => ($> == 0) ? 1 : 0, |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# UID/GID for daemons |
102
|
|
|
|
|
|
|
USERNAME => 'suffit', |
103
|
|
|
|
|
|
|
GROUPNAME => 'suffit', |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Directories |
106
|
|
|
|
|
|
|
DATADIR => 'suffit', |
107
|
|
|
|
|
|
|
HTMLDIR => 'suffit', |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Date and time formats |
110
|
|
|
|
|
|
|
DATE_FORMAT => '%Y-%m-%d', # See strftime(3) |
111
|
|
|
|
|
|
|
DATETIME_FORMAT => '%Y-%m-%dT%H:%M:%SZ', # See strftime(3) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Session |
114
|
|
|
|
|
|
|
SESSION_EXPIRATION => 3600, # 1 hour |
115
|
|
|
|
|
|
|
SESSION_EXPIRE_MAX => 86400 * 30, # 30 days |
116
|
|
|
|
|
|
|
TOKEN_HEADER_NAME => 'X-Token', |
117
|
|
|
|
|
|
|
TOKEN_EXPIRATION => 86400, # 1 day (for session and access tokens only) |
118
|
|
|
|
|
|
|
TOKEN_EXPIRE_MAX => 86400 * 30, # 30 days (for session and access tokens only) |
119
|
|
|
|
|
|
|
TOKEN_FILE_FORMAT => 'token-%s.tkn', |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# Security and Cryptography |
122
|
|
|
|
|
|
|
DEFAULT_SECRET => 'The_Suffit_API_secret_string_673', # 32 chars |
123
|
|
|
|
|
|
|
PRIVATEKEYFILE => 'rsa-private.key', |
124
|
|
|
|
|
|
|
PUBLICKEYFILE => 'rsa-public.key', |
125
|
|
|
|
|
|
|
DIGEST_ALGORITHMS => [qw/MD5 SHA1 SHA224 SHA256 SHA384 SHA512/], |
126
|
|
|
|
|
|
|
DEFAULT_ALGORITHM => 'SHA256', |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Misc |
129
|
|
|
|
|
|
|
USERNAME_REGEXP => qr/(?![_.\-])(?!.*[_.\-]{2,})[a-zA-Z0-9_.\-]+(?
|
130
|
|
|
|
|
|
|
EMAIL_REGEXP => qr/^[a-zA-Z0-9.!#$%&'*+\/\=?^_`{|}~\-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/, |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# MIME Content Types |
133
|
|
|
|
|
|
|
CONTENT_TYPE_TXT => "text/plain; charset=utf-8", |
134
|
|
|
|
|
|
|
CONTENT_TYPE_JSON => "application/json", |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# Server |
137
|
|
|
|
|
|
|
SERVER_UPGRADE_TIMEOUT => 30, |
138
|
|
|
|
|
|
|
SERVER_TIMEOUT => 60, |
139
|
|
|
|
|
|
|
SERVER_MAX_CLIENTS => 1000, # See Mojo::Server::Prefork |
140
|
|
|
|
|
|
|
SERVER_MAX_REQUESTS => 100, # See Mojo::Server::Prefork |
141
|
|
|
|
|
|
|
SERVER_ACCEPTS => 0, # See Mojo::Server::Prefork |
142
|
|
|
|
|
|
|
SERVER_SPARE => 2, # See Mojo::Server::Prefork |
143
|
|
|
|
|
|
|
SERVER_WORKERS => 4, # See Mojo::Server::Prefork |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Dictionaries |
146
|
|
|
|
|
|
|
HTTP_METHODS => [qw/ |
147
|
|
|
|
|
|
|
CONNECT OPTIONS HEAD GET |
148
|
|
|
|
|
|
|
POST PUT PATCH DELETE |
149
|
|
|
|
|
|
|
TRACE |
150
|
|
|
|
|
|
|
ANY MULTI |
151
|
|
|
|
|
|
|
/], |
152
|
1
|
|
|
1
|
|
8
|
}; |
|
1
|
|
|
|
|
5
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# Named groups of exports |
155
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
156
|
|
|
|
|
|
|
'GENERAL' => [qw/ |
157
|
|
|
|
|
|
|
IS_TTY IS_ROOT |
158
|
|
|
|
|
|
|
PROJECTNAME PROJECTNAMEL PROJECT_ABSTRACT |
159
|
|
|
|
|
|
|
DEFAULT_URL |
160
|
|
|
|
|
|
|
DATADIR HTMLDIR |
161
|
|
|
|
|
|
|
DATE_FORMAT DATETIME_FORMAT |
162
|
|
|
|
|
|
|
/], |
163
|
|
|
|
|
|
|
'SESSION' => [qw/ |
164
|
|
|
|
|
|
|
SESSION_EXPIRATION SESSION_EXPIRE_MAX |
165
|
|
|
|
|
|
|
TOKEN_HEADER_NAME TOKEN_EXPIRATION TOKEN_EXPIRE_MAX TOKEN_FILE_FORMAT |
166
|
|
|
|
|
|
|
/], |
167
|
|
|
|
|
|
|
'SECURITY' => [qw/ |
168
|
|
|
|
|
|
|
DEFAULT_SECRET |
169
|
|
|
|
|
|
|
PRIVATEKEYFILE PUBLICKEYFILE DIGEST_ALGORITHMS DEFAULT_ALGORITHM |
170
|
|
|
|
|
|
|
/], |
171
|
|
|
|
|
|
|
'MIME' => [qw/ |
172
|
|
|
|
|
|
|
CONTENT_TYPE_TXT CONTENT_TYPE_JSON |
173
|
|
|
|
|
|
|
/], |
174
|
|
|
|
|
|
|
'MISC' => [qw/ |
175
|
|
|
|
|
|
|
USERNAME_REGEXP EMAIL_REGEXP |
176
|
|
|
|
|
|
|
/], |
177
|
|
|
|
|
|
|
'DICTS' => [qw/ |
178
|
|
|
|
|
|
|
HTTP_METHODS |
179
|
|
|
|
|
|
|
/], |
180
|
|
|
|
|
|
|
'SERVER' => [qw/ |
181
|
|
|
|
|
|
|
SERVER_TIMEOUT SERVER_UPGRADE_TIMEOUT |
182
|
|
|
|
|
|
|
SERVER_MAX_CLIENTS SERVER_MAX_REQUESTS |
183
|
|
|
|
|
|
|
SERVER_ACCEPTS SERVER_SPARE SERVER_WORKERS |
184
|
|
|
|
|
|
|
/], |
185
|
|
|
|
|
|
|
); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# Items to export into callers namespace by default |
188
|
|
|
|
|
|
|
# (move infrequently used names to @EXPORT_OK below) |
189
|
|
|
|
|
|
|
@EXPORT = ( |
190
|
|
|
|
|
|
|
@{$EXPORT_TAGS{GENERAL}}, |
191
|
|
|
|
|
|
|
); |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# Other items we are prepared to export if requested |
194
|
|
|
|
|
|
|
@EXPORT_OK = ( |
195
|
|
|
|
|
|
|
map {@{$_}} values %EXPORT_TAGS |
196
|
|
|
|
|
|
|
); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
1; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
__END__ |