/
AnonymousIP.ts
63 lines (61 loc) · 2.07 KB
/
AnonymousIP.ts
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
import mmdb = require('maxmind');
/** Class representing the model of an "AnonymousIP" response **/
export default class AnonymousIP {
/**
* 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.
*/
public ipAddress?: string;
/**
* `true if the IP address belongs to any sort of anonymous network.
*/
public readonly isAnonymous: boolean;
/**
* `true` if the IP address is registered to an anonymous VPN provider.
*/
public readonly isAnonymousVpn: boolean;
/**
* `true` if the IP address belongs to a hosting or VPN provider (see
* description of `isAnonymousVpn` property).
*/
public readonly isHostingProvider: boolean;
/**
* `true` if the IP address belongs to a public proxy.
*/
public readonly isPublicProxy: boolean;
/**
* `true` if the IP address is on a suspected anonymizing network and belongs
* to a residential ISP.
*/
public readonly isResidentialProxy: boolean;
/**
* `true` if IP is a Tor exit node.
*/
public readonly isTorExitNode: boolean;
/**
* The network associated with the record. In particular, this is the largest
* network where all of the fields besides `ipAddress` have the same value.
*/
public network?: string;
/**
* Instantiates an "AnonymousIP" using fields from the response
*
* @param response The GeoIP2 response
*/
public constructor(
response: mmdb.AnonymousIPResponse,
ipAddress?: string,
network?: string
) {
this.ipAddress = ipAddress;
this.isAnonymous = !!response.is_anonymous;
this.isAnonymousVpn = !!response.is_anonymous_vpn;
this.isHostingProvider = !!response.is_hosting_provider;
this.isPublicProxy = !!response.is_public_proxy;
this.isResidentialProxy = !!response.is_residential_proxy;
this.isTorExitNode = !!response.is_tor_exit_node;
this.network = network;
}
}