Let’s Talk about Cloak: Its Application and Implementation

Cloak, when translated literally, refers to a cape or mantle, symbolizing something that covers. In the realm of advertising, it implies making a marketed product accessible to a specific subset of the audience.

The direct translation can be a bit cumbersome. Let’s commence with its practical application. For instance, when promoting a product on Facebook, even if the images and copy pass the review process, the promoted URL often gets flagged by Facebook’s review bots and is deemed to violate the rules. In such a situation, Cloak comes into play. It has the ability to distinguish between a real – person user and a bot, subsequently presenting the marketing page to real users and a compliant page to bots. This constitutes the fundamental application of Cloak. Evidently, Cloak’s utility extends beyond this single scenario; its diverse uses typically stem from specific requirements.

Some time back, I experimented with bulk – sending links via RCS. Initially, the results were promising, but over time, the effectiveness waned. Upon inspection, I discovered that even the domain name had been expunged by the registrar. This realization prompted me to implement Cloak for differentiating visiting users.

Step 1: Grab the IP in the Program

Here is how you can grab the IP in PHP. The following function attempts to get the real IP address of the client:

Step 2: Determine the Country and ISP of the IP

To determine the country and ISP, we can make use of an API. There are numerous IP – location services available on Google that offer APIs. You can select an appropriate package based on your user traffic volume. The API will return a plethora of values, but we only need to extract the relevant ones.

For my project, I’m specifically interested in country_code2 and isp. Here’s a sample of what the API response might look like in JSON format:

{
    "hostname": "dns.google",
    "continent_code": "NA",
    "continent_name": "North America",
    "country_code2": "US",
    "country_code3": "USA",
    "country_name": "United States",
    "country_capital": "Washington, D.C.",
    "state_prov": "California",
    "district": "Santa Clara",
    "city": "Mountain View",
    "zipcode": "94043 - 1351",
    "latitude": "37.42240",
    "longitude": "-122.08421",
    "is_eu": false,
    "calling_code": "+1",
    "country_tld": ".us",
    "languages": "en - US,es - US,haw,fr",
    "geoname_id": "6301403",
    "isp": "Google LLC",
    "connection_type": "",
    "organization": "Google LLC",
    "asn": "AS15169",
    "currency": {
        "code": "USD",
        "name": "US Dollar",
        "symbol": "$"
    },
    "time_zone": {
        "name": "America/Los_Angeles",
        "offset": -8,
        "current_time": "2020 - 12 - 17 07:49:45.872 - 0800",
        "current_time_unix": 1608220185.872,
        "is_dst": false,
        "dst_savings": 1
    }
}

Filtering by Country and Analyzing ISP

  • Country Filtering: Filtering by country is straightforward. As long as country_code2 = us, it meets our criteria.
  • ISP Analysis: Analyzing ISP is a bit more intricate. ISP stands for Internet Service Provider, which is a telecom operator offering Internet access, information services, and value – added services to a wide range of users. For example, if the ISP of an IP is Google LLC, and we wish to restrict its access, we redirect it to a compliant page. Another case is when the ISP is DigitalOcean (a company providing IDC services), indicating that the IP is likely a data center IP. If our intention is to display the page only to regular American users (who typically use residential IPs), we need to redirect such IPs.

To determine if an ISP corresponds to a residential IP, we can leverage data from the Federal Communications Commission in the US. Their official website hosts a national broadband map. Download the ISP data from there and import it into your database. By comparing the ISP obtained from the IP with the downloaded data, you can ascertain whether it’s a residential IP. This helps in differentiating between regular visitors and bots, enabling the redirection of users to different pages as required.

In conclusion, Cloak offers a wide array of functions that vary depending on specific needs and scenarios. You can enhance user – identification precision by incorporating User – Agent (UA) data or by extracting more values from the IP API. The key lies in its flexible application.

Share the Post:

Related Posts