The DeviceAtlas Carrier documentation
|
Public Member Functions | |
CarrierApi () | |
Construct a Carrier API object More... | |
CarrierApi (string path) | |
Construct a Carrier API object and Load the data file from the provided path. More... | |
string | GetDeviceAtlasApiVersion () |
Get CarrierApi version. More... | |
virtual void | DownloadAndLoadDataFile (DataFileConfig dataFileConfig) |
Downloads and loads the DeviceAtlas carrier detection data into the API. The data file is downloaded from the DeviceAtlas web-site. More... | |
virtual void | DownloadAndLoadDataFile (string dataFileDownloadUrl) |
Downloads and loads the DeviceAtlas carrier detection data into the API. The data file is downloaded from the DeviceAtlas web-site. More... | |
void | LoadDataFromFile (string path) |
Load the data file from the provided path. The data file is reloaded every time this method is called. More... | |
string | GetDataFileCopyright () |
Returns the data file copyright text. More... | |
string | GetDataFileCreationDate () |
Returns the data file creation date in ISO8601 format. More... | |
string | GetDataFileVersion () |
Returns the version of the data file. More... | |
Properties | GetProperties (string ipv4) |
Get the Carrier properties for a given IP address. More... | |
Properties | GetProperties (Dictionary< string, string > keyVals) |
Property | GetProperty (string ipv4, string propertyName) |
Property | GetProperty (Dictionary< string, string > keyVals, string propertyName) |
ReadOnlyCollection< PropertyName > | GetPropertyNames () |
A set of all the possible property names. The Set contains PropertyName objects that each have a string name and an associated data type. More... | |
string | GetIp (Dictionary< string, string > keyVals) |
Get the most suitable IP address from the given keyVals set of HTTP headers. This function checks the headers defined in HEADERS_TO_CHECK. More... | |
string | ExtractIp (string headerName, string headerValue) |
Static Public Member Functions | |
static string | GetApiVersion () |
Get CarrierApi version. More... | |
static bool | IsPublicIp (string ipStr) |
An IP address is considered public if it is not in any of the following ranges: More... | |
Static Public Attributes | |
static readonly string | API_VERSION = "1.3" |
static readonly string [] | HEADERS_TO_CHECK |
A list of HTTP headers to choose the original client IP address from. In addition to these the RemoteAddr (REMOTE_ADDR) is also used as a final fallback. More... | |
The main class for the Carrier Identification API. Used to load the data file and to perform lookups using IPv4 addresses. For usage in a Web Container it is recommended to also include the CarrierApiWeb jar file as this facilitates passing a HttpRequest object.
Please note that it is advisable to load only a single instance of this class to avoid multiple loadings of the data file. This can be done in a Web Container by storing a reference to it in the ServletContext.
Example usage:
Please see the code in the Examples directory for additional samples.
|
inline |
Construct a Carrier API object
|
inline |
Construct a Carrier API object and Load the data file from the provided path.
path | The path on disk to the data file. |
DataLoadingException | thrown when there is a problem with the data file. |
|
inlinevirtual |
Downloads and loads the DeviceAtlas carrier detection data into the API. The data file is downloaded from the DeviceAtlas web-site.
dataFileConfig | Data file download and load configuration |
DataLoadingException |
|
inlinevirtual |
Downloads and loads the DeviceAtlas carrier detection data into the API. The data file is downloaded from the DeviceAtlas web-site.
dataFileDownloadUrl | The URL to download the data file from. |
DataLoadingException |
|
inline |
Extracts and cleans an IP address from the headerValue. Some headers such as "X-Forwarded-For" can contain multiple IP addresses such as: clientIP, proxy1, proxy2...
This method splits up the headerValue and takes the most appropriate value as the IP.
headerName | The name of the HTTP Header |
headerValue | The value for the HTTP Header |
|
inlinestatic |
Get CarrierApi version.
|
inline |
Returns the data file copyright text.
|
inline |
Returns the data file creation date in ISO8601 format.
|
inline |
Returns the version of the data file.
|
inline |
Get CarrierApi version.
|
inline |
Get the most suitable IP address from the given keyVals set of HTTP headers. This function checks the headers defined in HEADERS_TO_CHECK.
keyVals | A hash of HTTP headers {header-name:value} |
|
inline |
Get the Carrier properties for a given IP address.
ipv4 | The IP address to find carrier properties for. |
|
inline |
Get the Carrier properties for a given Map of HTTP Headers. The API will choose the most appropriate IP to use.
The following headers are checked in order to find the most suitable IP address.
keyVals | A map of HTTP header name to HTTP header value. Both must be strings. |
|
inline |
Try and get a specific property for a given IP address.
Note: if multiple properties are needed for the same IP it is more efficient to call GetProperties() once than repeated calls to GetProperty().
ipv4 | The IP address to find carrier properties for. |
propertyName | The name of the property to return. |
InvalidPropertyNameException | Thrown if the property name does not exist. |
|
inline |
Try and get a specific property for a given Map of HTTP Headers. The API will choose the most appropriate IP to use.
Note: if multiple properties are needed for the same IP it is more efficient to call GetProperties() once than repeated calls to GetProperty().
keyVals | A map of HTTP header name to HTTP header value. Both must be strings. |
propertyName | The name of the property to return |
InvalidPropertyNameException | Thrown if the property name does not exist. |
|
inline |
A set of all the possible property names. The Set contains PropertyName objects that each have a string name and an associated data type.
|
inlinestatic |
An IP address is considered public if it is not in any of the following ranges:
1) any local address IP: 0
2) a local loopback address range: 127/8
3) a site local address i.e. IP is in any of the ranges: range: 10/8 range: 172.16/12 range: 192.168/16
4) a link local address range: 169.254/16
ip | The IP address to check |
|
inline |
Load the data file from the provided path. The data file is reloaded every time this method is called.
path | The path on disk to the data file. |
IOException | Thrown when there is a problem loading the file. |
DataLoadingException | thrown when there is a problem with the data file. |
|
static |
A list of HTTP headers to choose the original client IP address from. In addition to these the RemoteAddr (REMOTE_ADDR) is also used as a final fallback.