-
Notifications
You must be signed in to change notification settings - Fork 286
Expand file tree
/
Copy pathTraits.php
More file actions
338 lines (309 loc) · 13.6 KB
/
Copy pathTraits.php
File metadata and controls
338 lines (309 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<?php
declare(strict_types=1);
namespace GeoIp2\Record;
use GeoIp2\Util;
/**
* Contains data for the traits record associated with an IP address.
*
* This record is returned by all location services and databases.
*/
class Traits implements \JsonSerializable
{
/**
* @var int|null The autonomous system number
* associated with the IP address. See
* https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This attribute
* is only available from the City Plus and Insights web services and the
* GeoIP2 Enterprise database.
*/
public readonly ?int $autonomousSystemNumber;
/**
* @var string|null The organization
* associated with the registered autonomous system number for the IP address.
* See https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This
* attribute is only available from the City Plus and Insights web services and
* the GeoIP2 Enterprise database.
*/
public readonly ?string $autonomousSystemOrganization;
/**
* @var string|null The connection type may take the
* following values: "Dialup", "Cable/DSL", "Corporate", "Cellular", and
* "Satellite". Additional values may be added in the future. This attribute is
* only available from the City Plus and Insights web services and the GeoIP2
* Enterprise database.
*/
public readonly ?string $connectionType;
/**
* @var string|null The second level domain associated with the
* IP address. This will be something like "example.com" or "example.co.uk",
* not "foo.example.com". This attribute is only available from the
* City Plus and Insights web services and the GeoIP2 Enterprise
* database.
*/
public readonly ?string $domain;
/**
* @var string|null The IP address that the data in the model
* is for. If you performed a "me" lookup against the web service, this
* will be the externally routable IP address for the system the code is
* running on. If the system is behind a NAT, this may differ from the IP
* address locally assigned to it. This attribute is returned by all end
* points.
*/
public readonly ?string $ipAddress;
/**
* @var bool This is true if the IP address belongs to
* any sort of anonymous network. This property is only available from GeoIP2
* Insights.
*
* @deprecated use $anonymizer->isAnonymous in the Insights response instead
*/
public readonly bool $isAnonymous;
/**
* @var bool This is true if the IP address is
* registered to an anonymous VPN provider. If a VPN provider does not register
* subnets under names associated with them, we will likely only flag their IP
* ranges using the isHostingProvider property. This property is only available
* from GeoIP2 Insights.
*
* @deprecated use $anonymizer->isAnonymousVpn in the Insights response instead
*/
public readonly bool $isAnonymousVpn;
/**
* @var bool This is true if the IP address belongs to an [anycast
* network](https://en.wikipedia.org/wiki/Anycast). This property is not
* available from GeoLite databases or web services.
*/
public readonly bool $isAnycast;
/**
* @var bool This is true if the IP address belongs
* to a hosting or VPN provider (see description of isAnonymousVpn property).
* This property is only available from GeoIP2 Insights.
*
* @deprecated use $anonymizer->isHostingProvider in the Insights response instead
*/
public readonly bool $isHostingProvider;
/**
* @var bool This attribute is true if MaxMind
* believes this IP address to be a legitimate proxy, such as an internal
* VPN used by a corporation. This attribute is only available in the GeoIP2
* Enterprise database.
*/
public readonly bool $isLegitimateProxy;
/**
* @var bool This is true if the IP address belongs to
* a public proxy. This property is only available from GeoIP2 Insights.
*
* @deprecated use $anonymizer->isPublicProxy in the Insights response instead
*/
public readonly bool $isPublicProxy;
/**
* @var bool This is true if the IP address is
* on a suspected anonymizing network and belongs to a residential ISP. This
* property is only available from GeoIP2 Insights.
*
* @deprecated use $anonymizer->isResidentialProxy in the Insights response instead
*/
public readonly bool $isResidentialProxy;
/**
* @var bool This is true if the IP address is a Tor
* exit node. This property is only available from GeoIP2 Insights.
*
* @deprecated use $anonymizer->isTorExitNode in the Insights response instead
*/
public readonly bool $isTorExitNode;
/**
* @var string|null The name of the ISP associated with the IP
* address. This attribute is only available from the City Plus and Insights
* web services and the GeoIP2 Enterprise database.
*/
public readonly ?string $isp;
/**
* @var string|null The [mobile country code
* (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
* the IP address and ISP. This property is available from the City Plus and
* Insights web services and the GeoIP2 Enterprise database.
*/
public readonly ?string $mobileCountryCode;
/**
* @var string|null The [mobile network code
* (MNC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
* the IP address and ISP. This property is available from the City Plus and
* Insights web services and the GeoIP2 Enterprise database.
*/
public readonly ?string $mobileNetworkCode;
/**
* @var string|null The network in CIDR notation associated with
* the record. In particular, this is the largest network where all of the
* fields besides $ipAddress have the same value.
*/
public readonly ?string $network;
/**
* @var string|null The name of the organization
* associated with the IP address. This attribute is only available from the
* City Plus and Insights web services and the GeoIP2 Enterprise database.
*/
public readonly ?string $organization;
/**
* @var float|null A risk score from 0.01 to 99 indicating the risk associated with the
* IP address. A higher score indicates a higher risk. Please note that the IP
* risk score provided in GeoIP products and services is more static than the
* IP risk score provided in minFraud and is not responsive to traffic on your
* network. If you need realtime IP risk scoring based on behavioral signals on
* your own network, please use minFraud. This attribute is only available from
* the GeoIP2 Insights web service.
*
* We do not provide an IP risk snapshot for low-risk networks. If this field
* is not populated, we either do not have signals for the network or the
* signals we have show that the network is low-risk. If you would like to get
* signals for low-risk networks, please use the minFraud web services.
*/
public readonly ?float $ipRiskSnapshot;
/**
* @var float|null An indicator of how static or
* dynamic an IP address is. This property is only available from GeoIP2
* Insights.
*/
public readonly ?float $staticIpScore;
/**
* @var int|null The estimated number of users sharing
* the IP/network during the past 24 hours. For IPv4, the count is for the
* individual IP. For IPv6, the count is for the /64 network. This property is
* only available from GeoIP2 Insights.
*/
public readonly ?int $userCount;
/**
* @var string|null <p>The user type associated with the IP
* address. This can be one of the following values:</p>
* <ul>
* <li>business
* <li>cafe
* <li>cellular
* <li>college
* <li>consumer_privacy_network
* <li>content_delivery_network
* <li>dialup
* <li>government
* <li>hosting
* <li>library
* <li>military
* <li>residential
* <li>router
* <li>school
* <li>search_engine_spider
* <li>traveler
* </ul>
* <p>
* This attribute is only available from the Insights web service and the
* GeoIP2 Enterprise database.
* </p>
*/
public readonly ?string $userType;
/**
* @ignore
*
* @param array<string, mixed> $record
*/
public function __construct(array $record)
{
$this->autonomousSystemNumber = $record['autonomous_system_number'] ?? null;
$this->autonomousSystemOrganization = $record['autonomous_system_organization'] ?? null;
$this->connectionType = $record['connection_type'] ?? null;
$this->domain = $record['domain'] ?? null;
$this->ipAddress = $record['ip_address'] ?? null;
$this->isAnonymous = $record['is_anonymous'] ?? false;
$this->isAnonymousVpn = $record['is_anonymous_vpn'] ?? false;
$this->isAnycast = $record['is_anycast'] ?? false;
$this->isHostingProvider = $record['is_hosting_provider'] ?? false;
$this->isLegitimateProxy = $record['is_legitimate_proxy'] ?? false;
$this->isp = $record['isp'] ?? null;
$this->isPublicProxy = $record['is_public_proxy'] ?? false;
$this->isResidentialProxy = $record['is_residential_proxy'] ?? false;
$this->isTorExitNode = $record['is_tor_exit_node'] ?? false;
$this->mobileCountryCode = $record['mobile_country_code'] ?? null;
$this->mobileNetworkCode = $record['mobile_network_code'] ?? null;
$this->organization = $record['organization'] ?? null;
$this->ipRiskSnapshot = $record['ip_risk_snapshot'] ?? null;
$this->staticIpScore = $record['static_ip_score'] ?? null;
$this->userCount = $record['user_count'] ?? null;
$this->userType = $record['user_type'] ?? null;
if (isset($record['network'])) {
$this->network = $record['network'];
} else {
$this->network = isset($record['prefix_len']) ? Util::cidr($this->ipAddress, $record['prefix_len']) : null;
}
}
/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
$js = [];
if ($this->autonomousSystemNumber !== null) {
$js['autonomous_system_number'] = $this->autonomousSystemNumber;
}
if ($this->autonomousSystemOrganization !== null) {
$js['autonomous_system_organization'] = $this->autonomousSystemOrganization;
}
if ($this->connectionType !== null) {
$js['connection_type'] = $this->connectionType;
}
if ($this->domain !== null) {
$js['domain'] = $this->domain;
}
if ($this->ipAddress !== null) {
$js['ip_address'] = $this->ipAddress;
}
if ($this->isAnonymous !== false) {
$js['is_anonymous'] = $this->isAnonymous;
}
if ($this->isAnonymousVpn !== false) {
$js['is_anonymous_vpn'] = $this->isAnonymousVpn;
}
if ($this->isAnycast !== false) {
$js['is_anycast'] = $this->isAnycast;
}
if ($this->isHostingProvider !== false) {
$js['is_hosting_provider'] = $this->isHostingProvider;
}
if ($this->isLegitimateProxy !== false) {
$js['is_legitimate_proxy'] = $this->isLegitimateProxy;
}
if ($this->isPublicProxy !== false) {
$js['is_public_proxy'] = $this->isPublicProxy;
}
if ($this->isResidentialProxy !== false) {
$js['is_residential_proxy'] = $this->isResidentialProxy;
}
if ($this->isTorExitNode !== false) {
$js['is_tor_exit_node'] = $this->isTorExitNode;
}
if ($this->isp !== null) {
$js['isp'] = $this->isp;
}
if ($this->mobileCountryCode !== null) {
$js['mobile_country_code'] = $this->mobileCountryCode;
}
if ($this->mobileNetworkCode !== null) {
$js['mobile_network_code'] = $this->mobileNetworkCode;
}
if ($this->network !== null) {
$js['network'] = $this->network;
}
if ($this->organization !== null) {
$js['organization'] = $this->organization;
}
if ($this->ipRiskSnapshot !== null) {
$js['ip_risk_snapshot'] = $this->ipRiskSnapshot;
}
if ($this->staticIpScore !== null) {
$js['static_ip_score'] = $this->staticIpScore;
}
if ($this->userCount !== null) {
$js['user_count'] = $this->userCount;
}
if ($this->userType !== null) {
$js['user_type'] = $this->userType;
}
return $js;
}
}