nicinfo 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/nicinfo +22 -0
- data/lib/autnum.rb +90 -0
- data/lib/bootstrap.rb +198 -0
- data/lib/bsfiles/asn.json +2326 -0
- data/lib/bsfiles/dns.json +25 -0
- data/lib/bsfiles/entity.json +52 -0
- data/lib/bsfiles/ipv4.json +244 -0
- data/lib/bsfiles/ipv6.json +97 -0
- data/lib/cache.rb +141 -0
- data/lib/common_json.rb +263 -0
- data/lib/common_names.rb +49 -0
- data/lib/config.rb +260 -0
- data/lib/constants.rb +113 -0
- data/lib/data_tree.rb +205 -0
- data/lib/demo/autnum.json +228 -0
- data/lib/demo/domain-dnr.json +695 -0
- data/lib/demo/domain-rir.json +569 -0
- data/lib/demo/domains.json +625 -0
- data/lib/demo/entities.json +545 -0
- data/lib/demo/entity-dnr.json +143 -0
- data/lib/demo/entity-rir.json +394 -0
- data/lib/demo/error-code.json +31 -0
- data/lib/demo/help.json +58 -0
- data/lib/demo/ip.json +306 -0
- data/lib/demo/nameservers.json +434 -0
- data/lib/demo/ns-simple.json +210 -0
- data/lib/demo/ns-very-simple.json +41 -0
- data/lib/demo/ns.json +63 -0
- data/lib/demo/simple-ip.json +41 -0
- data/lib/demo/simple.json +13 -0
- data/lib/domain.rb +203 -0
- data/lib/ds_data.rb +70 -0
- data/lib/entity.rb +372 -0
- data/lib/enum.rb +47 -0
- data/lib/error_code.rb +56 -0
- data/lib/female-first-names.txt +4275 -0
- data/lib/ip.rb +86 -0
- data/lib/key_data.rb +70 -0
- data/lib/last-names.txt +88799 -0
- data/lib/male-first-names.txt +1219 -0
- data/lib/nicinfo_logger.rb +370 -0
- data/lib/nicinfo_main.rb +1013 -0
- data/lib/notices.rb +110 -0
- data/lib/ns.rb +108 -0
- data/lib/utils.rb +189 -0
- metadata +90 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"rdap_bootstrap": {
|
3
|
+
"version": "1.0",
|
4
|
+
"publication": "2014-09-09T15:39:03-0400",
|
5
|
+
"services": [
|
6
|
+
[
|
7
|
+
[
|
8
|
+
"info"
|
9
|
+
],
|
10
|
+
[
|
11
|
+
"http://rdg.afilias.info/rdap"
|
12
|
+
]
|
13
|
+
],
|
14
|
+
[
|
15
|
+
[
|
16
|
+
"cn"
|
17
|
+
],
|
18
|
+
[
|
19
|
+
"https://rdap.restfulwhois.org",
|
20
|
+
"http://rdap.restfulwhois.org"
|
21
|
+
]
|
22
|
+
]
|
23
|
+
]
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
{
|
2
|
+
"rdap_bootstrap": {
|
3
|
+
"version": "1.0",
|
4
|
+
"publication": "2014-09-09T15:39:03-0400",
|
5
|
+
"services": [
|
6
|
+
[
|
7
|
+
[
|
8
|
+
"ARIN"
|
9
|
+
],
|
10
|
+
[
|
11
|
+
"http://rdappilot.arin.net/restfulwhois/rdap"
|
12
|
+
]
|
13
|
+
],
|
14
|
+
[
|
15
|
+
[
|
16
|
+
"AP"
|
17
|
+
],
|
18
|
+
[
|
19
|
+
"https://rdap.apnic.net",
|
20
|
+
"http://rdap.apnic.net"
|
21
|
+
]
|
22
|
+
],
|
23
|
+
[
|
24
|
+
[
|
25
|
+
"RIPE"
|
26
|
+
],
|
27
|
+
[
|
28
|
+
"https://rdap.db.ripe.net",
|
29
|
+
"http://rdap.db.ripe.net"
|
30
|
+
]
|
31
|
+
],
|
32
|
+
[
|
33
|
+
[
|
34
|
+
"AFRINIC"
|
35
|
+
],
|
36
|
+
[
|
37
|
+
"https://rdap.rd.me.afrinic.net/whois/AFRINIC",
|
38
|
+
"http://rdap.rd.me.afrinic.net/whois/AFRINIC"
|
39
|
+
]
|
40
|
+
],
|
41
|
+
[
|
42
|
+
[
|
43
|
+
"LACNIC"
|
44
|
+
],
|
45
|
+
[
|
46
|
+
"https://rdap.lacnic.net/rdap",
|
47
|
+
"http://rdap.lacnic.net/rdap"
|
48
|
+
]
|
49
|
+
]
|
50
|
+
]
|
51
|
+
}
|
52
|
+
}
|
@@ -0,0 +1,244 @@
|
|
1
|
+
{
|
2
|
+
"rdap_bootstrap": {
|
3
|
+
"version": "1.0",
|
4
|
+
"publication": "2014-09-09T15:38:41-0400",
|
5
|
+
"services": [
|
6
|
+
[
|
7
|
+
[
|
8
|
+
"000.000.000.000/8",
|
9
|
+
"010.000.000.000/8",
|
10
|
+
"127.000.000.000/8"
|
11
|
+
],
|
12
|
+
[
|
13
|
+
"https://rdap.iana.org",
|
14
|
+
"http://rdap.iana.org"
|
15
|
+
]
|
16
|
+
],
|
17
|
+
[
|
18
|
+
[
|
19
|
+
"001.000.000.000/8",
|
20
|
+
"014.000.000.000/8",
|
21
|
+
"027.000.000.000/8",
|
22
|
+
"036.000.000.000/8",
|
23
|
+
"039.000.000.000/8",
|
24
|
+
"042.000.000.000/8",
|
25
|
+
"043.000.000.000/8",
|
26
|
+
"049.000.000.000/8",
|
27
|
+
"058.000.000.000/8",
|
28
|
+
"059.000.000.000/8",
|
29
|
+
"060.000.000.000/8",
|
30
|
+
"061.000.000.000/8",
|
31
|
+
"101.000.000.000/8",
|
32
|
+
"103.000.000.000/8",
|
33
|
+
"106.000.000.000/8",
|
34
|
+
"110.000.000.000/8",
|
35
|
+
"111.000.000.000/8",
|
36
|
+
"112.000.000.000/8",
|
37
|
+
"113.000.000.000/8",
|
38
|
+
"114.000.000.000/8",
|
39
|
+
"115.000.000.000/8",
|
40
|
+
"116.000.000.000/8",
|
41
|
+
"117.000.000.000/8",
|
42
|
+
"118.000.000.000/8",
|
43
|
+
"119.000.000.000/8",
|
44
|
+
"120.000.000.000/8",
|
45
|
+
"121.000.000.000/8",
|
46
|
+
"122.000.000.000/8",
|
47
|
+
"123.000.000.000/8",
|
48
|
+
"124.000.000.000/8",
|
49
|
+
"125.000.000.000/8",
|
50
|
+
"126.000.000.000/8",
|
51
|
+
"133.000.000.000/8",
|
52
|
+
"150.000.000.000/8",
|
53
|
+
"153.000.000.000/8",
|
54
|
+
"163.000.000.000/8",
|
55
|
+
"171.000.000.000/8",
|
56
|
+
"175.000.000.000/8",
|
57
|
+
"180.000.000.000/8",
|
58
|
+
"182.000.000.000/8",
|
59
|
+
"183.000.000.000/8",
|
60
|
+
"202.000.000.000/8",
|
61
|
+
"203.000.000.000/8",
|
62
|
+
"210.000.000.000/8",
|
63
|
+
"211.000.000.000/8",
|
64
|
+
"218.000.000.000/8",
|
65
|
+
"219.000.000.000/8",
|
66
|
+
"220.000.000.000/8",
|
67
|
+
"221.000.000.000/8",
|
68
|
+
"222.000.000.000/8",
|
69
|
+
"223.000.000.000/8"
|
70
|
+
],
|
71
|
+
[
|
72
|
+
"https://rdap.apnic.net",
|
73
|
+
"http://rdap.apnic.net"
|
74
|
+
]
|
75
|
+
],
|
76
|
+
[
|
77
|
+
[
|
78
|
+
"002.000.000.000/8",
|
79
|
+
"005.000.000.000/8",
|
80
|
+
"031.000.000.000/8",
|
81
|
+
"037.000.000.000/8",
|
82
|
+
"046.000.000.000/8",
|
83
|
+
"062.000.000.000/8",
|
84
|
+
"077.000.000.000/8",
|
85
|
+
"078.000.000.000/8",
|
86
|
+
"079.000.000.000/8",
|
87
|
+
"080.000.000.000/8",
|
88
|
+
"081.000.000.000/8",
|
89
|
+
"082.000.000.000/8",
|
90
|
+
"083.000.000.000/8",
|
91
|
+
"084.000.000.000/8",
|
92
|
+
"085.000.000.000/8",
|
93
|
+
"086.000.000.000/8",
|
94
|
+
"087.000.000.000/8",
|
95
|
+
"088.000.000.000/8",
|
96
|
+
"089.000.000.000/8",
|
97
|
+
"090.000.000.000/8",
|
98
|
+
"091.000.000.000/8",
|
99
|
+
"092.000.000.000/8",
|
100
|
+
"093.000.000.000/8",
|
101
|
+
"094.000.000.000/8",
|
102
|
+
"095.000.000.000/8",
|
103
|
+
"109.000.000.000/8",
|
104
|
+
"141.000.000.000/8",
|
105
|
+
"145.000.000.000/8",
|
106
|
+
"151.000.000.000/8",
|
107
|
+
"176.000.000.000/8",
|
108
|
+
"178.000.000.000/8",
|
109
|
+
"185.000.000.000/8",
|
110
|
+
"188.000.000.000/8",
|
111
|
+
"193.000.000.000/8",
|
112
|
+
"194.000.000.000/8",
|
113
|
+
"195.000.000.000/8",
|
114
|
+
"212.000.000.000/8",
|
115
|
+
"213.000.000.000/8",
|
116
|
+
"217.000.000.000/8"
|
117
|
+
],
|
118
|
+
[
|
119
|
+
"https://rdap.db.ripe.net",
|
120
|
+
"http://rdap.db.ripe.net/"
|
121
|
+
]
|
122
|
+
],
|
123
|
+
[
|
124
|
+
[
|
125
|
+
"007.000.000.000/8",
|
126
|
+
"023.000.000.000/8",
|
127
|
+
"024.000.000.000/8",
|
128
|
+
"035.000.000.000/8",
|
129
|
+
"040.000.000.000/8",
|
130
|
+
"045.000.000.000/8",
|
131
|
+
"047.000.000.000/8",
|
132
|
+
"050.000.000.000/8",
|
133
|
+
"054.000.000.000/8",
|
134
|
+
"063.000.000.000/8",
|
135
|
+
"064.000.000.000/8",
|
136
|
+
"065.000.000.000/8",
|
137
|
+
"066.000.000.000/8",
|
138
|
+
"067.000.000.000/8",
|
139
|
+
"068.000.000.000/8",
|
140
|
+
"069.000.000.000/8",
|
141
|
+
"070.000.000.000/8",
|
142
|
+
"071.000.000.000/8",
|
143
|
+
"072.000.000.000/8",
|
144
|
+
"073.000.000.000/8",
|
145
|
+
"074.000.000.000/8",
|
146
|
+
"075.000.000.000/8",
|
147
|
+
"076.000.000.000/8",
|
148
|
+
"096.000.000.000/8",
|
149
|
+
"097.000.000.000/8",
|
150
|
+
"098.000.000.000/8",
|
151
|
+
"099.000.000.000/8",
|
152
|
+
"100.000.000.000/8",
|
153
|
+
"104.000.000.000/8",
|
154
|
+
"107.000.000.000/8",
|
155
|
+
"108.000.000.000/8",
|
156
|
+
"128.000.000.000/8",
|
157
|
+
"129.000.000.000/8",
|
158
|
+
"130.000.000.000/8",
|
159
|
+
"131.000.000.000/8",
|
160
|
+
"132.000.000.000/8",
|
161
|
+
"134.000.000.000/8",
|
162
|
+
"135.000.000.000/8",
|
163
|
+
"136.000.000.000/8",
|
164
|
+
"137.000.000.000/8",
|
165
|
+
"138.000.000.000/8",
|
166
|
+
"139.000.000.000/8",
|
167
|
+
"140.000.000.000/8",
|
168
|
+
"142.000.000.000/8",
|
169
|
+
"143.000.000.000/8",
|
170
|
+
"144.000.000.000/8",
|
171
|
+
"146.000.000.000/8",
|
172
|
+
"147.000.000.000/8",
|
173
|
+
"148.000.000.000/8",
|
174
|
+
"149.000.000.000/8",
|
175
|
+
"152.000.000.000/8",
|
176
|
+
"155.000.000.000/8",
|
177
|
+
"156.000.000.000/8",
|
178
|
+
"157.000.000.000/8",
|
179
|
+
"158.000.000.000/8",
|
180
|
+
"159.000.000.000/8",
|
181
|
+
"160.000.000.000/8",
|
182
|
+
"161.000.000.000/8",
|
183
|
+
"162.000.000.000/8",
|
184
|
+
"164.000.000.000/8",
|
185
|
+
"165.000.000.000/8",
|
186
|
+
"166.000.000.000/8",
|
187
|
+
"167.000.000.000/8",
|
188
|
+
"168.000.000.000/8",
|
189
|
+
"169.000.000.000/8",
|
190
|
+
"170.000.000.000/8",
|
191
|
+
"172.000.000.000/8",
|
192
|
+
"173.000.000.000/8",
|
193
|
+
"174.000.000.000/8",
|
194
|
+
"184.000.000.000/8",
|
195
|
+
"192.000.000.000/8",
|
196
|
+
"198.000.000.000/8",
|
197
|
+
"199.000.000.000/8",
|
198
|
+
"204.000.000.000/8",
|
199
|
+
"205.000.000.000/8",
|
200
|
+
"206.000.000.000/8",
|
201
|
+
"207.000.000.000/8",
|
202
|
+
"208.000.000.000/8",
|
203
|
+
"209.000.000.000/8",
|
204
|
+
"216.000.000.000/8"
|
205
|
+
],
|
206
|
+
[
|
207
|
+
"http://rdappilot.arin.net/restfulwhois/rdap"
|
208
|
+
]
|
209
|
+
],
|
210
|
+
[
|
211
|
+
[
|
212
|
+
"041.000.000.000/8",
|
213
|
+
"102.000.000.000/8",
|
214
|
+
"105.000.000.000/8",
|
215
|
+
"154.000.000.000/8",
|
216
|
+
"196.000.000.000/8",
|
217
|
+
"197.000.000.000/8"
|
218
|
+
],
|
219
|
+
[
|
220
|
+
"https://rdap.rd.me.afrinic.net/whois/AFRINIC",
|
221
|
+
"http://rdap.rd.me.afrinic.net/whois/AFRINIC"
|
222
|
+
]
|
223
|
+
],
|
224
|
+
[
|
225
|
+
[
|
226
|
+
"177.000.000.000/8",
|
227
|
+
"179.000.000.000/8",
|
228
|
+
"181.000.000.000/8",
|
229
|
+
"186.000.000.000/8",
|
230
|
+
"187.000.000.000/8",
|
231
|
+
"189.000.000.000/8",
|
232
|
+
"190.000.000.000/8",
|
233
|
+
"191.000.000.000/8",
|
234
|
+
"200.000.000.000/8",
|
235
|
+
"201.000.000.000/8"
|
236
|
+
],
|
237
|
+
[
|
238
|
+
"https://rdap.lacnic.net/rdap",
|
239
|
+
"http://rdap.lacnic.net/rdap"
|
240
|
+
]
|
241
|
+
]
|
242
|
+
]
|
243
|
+
}
|
244
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
{
|
2
|
+
"rdap_bootstrap": {
|
3
|
+
"version": "1.0",
|
4
|
+
"publication": "2014-09-09T15:39:03-0400",
|
5
|
+
"services": [
|
6
|
+
[
|
7
|
+
[
|
8
|
+
"2001:0000::/23",
|
9
|
+
"2001:3c00::/22",
|
10
|
+
"2d00:0000::/8",
|
11
|
+
"2e00:0000::/7",
|
12
|
+
"3000:0000::/4",
|
13
|
+
"3ffe::/16",
|
14
|
+
"5f00::/8"
|
15
|
+
],
|
16
|
+
[
|
17
|
+
"https://rdap.iana.org",
|
18
|
+
"http://rdap.iana.org"
|
19
|
+
]
|
20
|
+
],
|
21
|
+
[
|
22
|
+
[
|
23
|
+
"2001:0200::/23",
|
24
|
+
"2001:0c00::/23",
|
25
|
+
"2001:0e00::/23",
|
26
|
+
"2001:4400::/23",
|
27
|
+
"2001:8000::/19",
|
28
|
+
"2001:a000::/20",
|
29
|
+
"2001:b000::/20",
|
30
|
+
"2400:0000::/12"
|
31
|
+
],
|
32
|
+
[
|
33
|
+
"https://rdap.apnic.net",
|
34
|
+
"http://rdap.apnic.net"
|
35
|
+
]
|
36
|
+
],
|
37
|
+
[
|
38
|
+
[
|
39
|
+
"2001:0400::/23",
|
40
|
+
"2001:1800::/23",
|
41
|
+
"2001:4800::/23",
|
42
|
+
"2600:0000::/12",
|
43
|
+
"2610:0000::/23",
|
44
|
+
"2620:0000::/23"
|
45
|
+
],
|
46
|
+
[
|
47
|
+
"http://rdappilot.arin.net/restfulwhois/rdap"
|
48
|
+
]
|
49
|
+
],
|
50
|
+
[
|
51
|
+
[
|
52
|
+
"2001:0600::/23",
|
53
|
+
"2001:0800::/23",
|
54
|
+
"2001:0a00::/23",
|
55
|
+
"2001:1400::/23",
|
56
|
+
"2001:1600::/23",
|
57
|
+
"2001:1a00::/23",
|
58
|
+
"2001:1c00::/22",
|
59
|
+
"2001:2000::/20",
|
60
|
+
"2001:3000::/21",
|
61
|
+
"2001:3800::/22",
|
62
|
+
"2001:4000::/23",
|
63
|
+
"2001:4600::/23",
|
64
|
+
"2001:4a00::/23",
|
65
|
+
"2001:4c00::/23",
|
66
|
+
"2001:5000::/20",
|
67
|
+
"2003:0000::/18",
|
68
|
+
"2a00:0000::/12"
|
69
|
+
],
|
70
|
+
[
|
71
|
+
"https://rdap.db.ripe.net",
|
72
|
+
"http://rdap.db.ripe.net"
|
73
|
+
]
|
74
|
+
],
|
75
|
+
[
|
76
|
+
[
|
77
|
+
"2001:1200::/23",
|
78
|
+
"2800:0000::/12"
|
79
|
+
],
|
80
|
+
[
|
81
|
+
"https://rdap.lacnic.net/rdap",
|
82
|
+
"http://rdap.lacnic.net/rdap"
|
83
|
+
]
|
84
|
+
],
|
85
|
+
[
|
86
|
+
[
|
87
|
+
"2001:4200::/23",
|
88
|
+
"2c00:0000::/12"
|
89
|
+
],
|
90
|
+
[
|
91
|
+
"https://rdap.rd.me.afrinic.net/whois/AFRINIC",
|
92
|
+
"http://rdap.rd.me.afrinic.net/whois/AFRINIC"
|
93
|
+
]
|
94
|
+
]
|
95
|
+
]
|
96
|
+
}
|
97
|
+
}
|
data/lib/cache.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# Copyright (C) 2011,2012,2013,2014 American Registry for Internet Numbers
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
# purpose with or without fee is hereby granted, provided that the above
|
5
|
+
# copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
13
|
+
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
|
16
|
+
require 'time'
|
17
|
+
require 'uri'
|
18
|
+
require 'utils'
|
19
|
+
|
20
|
+
module NicInfo
|
21
|
+
|
22
|
+
class Cache
|
23
|
+
|
24
|
+
def initialize config
|
25
|
+
@config = config
|
26
|
+
end
|
27
|
+
|
28
|
+
# creates or updates an object in the cache
|
29
|
+
def create_or_update url, data
|
30
|
+
return nil if @config.config[ NicInfo::CACHE ][ NicInfo::USE_CACHE ] == false
|
31
|
+
safe = NicInfo::make_safe(url)
|
32
|
+
@config.logger.trace("Persisting " + url + " as " + safe)
|
33
|
+
f = File.open(File.join(@config.rdap_cache_dir, safe), "w")
|
34
|
+
f.puts data
|
35
|
+
f.close
|
36
|
+
end
|
37
|
+
|
38
|
+
# creates an object in the cache.
|
39
|
+
# if the object already exists in the cache, this does nothing.
|
40
|
+
def create url, data
|
41
|
+
safe = NicInfo::make_safe(url)
|
42
|
+
file_name = File.join(@config.rdap_cache_dir, safe)
|
43
|
+
expiry = Time.now - @config.config[ NicInfo::CACHE ][ NicInfo::CACHE_EXPIRY ]
|
44
|
+
return if (File.exist?(file_name) && File.mtime(file_name) > expiry)
|
45
|
+
create_or_update(url, data)
|
46
|
+
end
|
47
|
+
|
48
|
+
def get url
|
49
|
+
return nil if @config.config[ NicInfo::CACHE ][ NicInfo::USE_CACHE ] == false
|
50
|
+
safe = NicInfo::make_safe(url)
|
51
|
+
file_name = File.join(@config.rdap_cache_dir, safe)
|
52
|
+
expiry = Time.now - @config.config[ NicInfo::CACHE ][ NicInfo::CACHE_EXPIRY ]
|
53
|
+
if (File.exist?(file_name) && File.mtime(file_name) > expiry)
|
54
|
+
@config.logger.trace("Getting " + url + " from cache.")
|
55
|
+
f = File.open(file_name, "r")
|
56
|
+
data = ''
|
57
|
+
f.each_line do |line|
|
58
|
+
data += line
|
59
|
+
end
|
60
|
+
f.close
|
61
|
+
return data
|
62
|
+
end
|
63
|
+
#else
|
64
|
+
return nil
|
65
|
+
end
|
66
|
+
|
67
|
+
def clean
|
68
|
+
cache_files = Dir::entries(@config.rdap_cache_dir)
|
69
|
+
eviction = Time.now - @config.config[ NicInfo::CACHE ][ NicInfo::CACHE_EVICTION ]
|
70
|
+
eviction_count = 0
|
71
|
+
cache_files.each do |file|
|
72
|
+
full_file_name = File.join(@config.rdap_cache_dir, file)
|
73
|
+
if !file.start_with?(".") && (File.mtime(full_file_name) < eviction)
|
74
|
+
@config.logger.trace("Evicting " + full_file_name)
|
75
|
+
File::unlink(full_file_name)
|
76
|
+
eviction_count += 1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
@config.logger.trace("Evicted " + eviction_count.to_s + " files from the cache")
|
80
|
+
return eviction_count
|
81
|
+
end
|
82
|
+
|
83
|
+
def empty
|
84
|
+
cache_files = Dir::entries(@config.rdap_cache_dir)
|
85
|
+
eviction_count = 0
|
86
|
+
cache_files.each do |file|
|
87
|
+
full_file_name = File.join(@config.rdap_cache_dir, file)
|
88
|
+
if !file.start_with?(".")
|
89
|
+
@config.logger.trace("Evicting " + full_file_name)
|
90
|
+
File::unlink(full_file_name)
|
91
|
+
eviction_count += 1
|
92
|
+
end
|
93
|
+
end
|
94
|
+
@config.logger.trace("Evicted " + eviction_count.to_s + " files from the cache")
|
95
|
+
return eviction_count
|
96
|
+
end
|
97
|
+
|
98
|
+
def count
|
99
|
+
count = 0
|
100
|
+
cache_files = Dir::entries(@config.rdap_cache_dir)
|
101
|
+
cache_files.each do |file|
|
102
|
+
if !file.start_with?(".")
|
103
|
+
count += 1
|
104
|
+
end
|
105
|
+
end
|
106
|
+
return count
|
107
|
+
end
|
108
|
+
|
109
|
+
def get_last
|
110
|
+
cache_files = Dir::entries(@config.rdap_cache_dir)
|
111
|
+
last_file = nil
|
112
|
+
last_file_mtime = nil
|
113
|
+
cache_files.each do |file|
|
114
|
+
full_file_name = File.join(@config.rdap_cache_dir, file)
|
115
|
+
if !file.start_with?(".")
|
116
|
+
mtime = File.mtime(full_file_name)
|
117
|
+
if last_file == nil
|
118
|
+
last_file = full_file_name
|
119
|
+
last_file_mtime = mtime
|
120
|
+
elsif mtime > last_file_mtime
|
121
|
+
last_file = full_file_name
|
122
|
+
last_file_mtime = mtime
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
if last_file
|
127
|
+
f = File.open(last_file, "r")
|
128
|
+
data = ''
|
129
|
+
f.each_line do |line|
|
130
|
+
data += line
|
131
|
+
end
|
132
|
+
f.close
|
133
|
+
return [last_file, last_file_mtime, data]
|
134
|
+
end
|
135
|
+
#else
|
136
|
+
return nil
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|