trustip/trustip

A Laravel package from Trustip.io for VPN and Proxy detection, it allows you to check if an IP address is a Proxy, VPN, TOR, Hosting, Bad search engine robots or not.
2,638 1
Install
composer require trustip/trustip
Latest Version:v1.1
PHP:>=7.3
License:MIT
Last Updated:Sep 23, 2024
Links: GitHub  ·  Packagist
Maintainer: trustip

Trustip - VPN & Proxy Detection

A Laravel package for VPN & Proxy Detection by Trustip.io

Trustip

Installation

You can install the package via composer:

composer require trustip/trustip

You need to set TRUSTIP_API_KEY in your .env file before using the package. You can get the API key from Trustip.io

TRUSTIP_API_KEY=your_api_key

You can publish the config file with:

php artisan vendor:publish --provider="Trustip\Trustip\Providers\TrustipServiceProvider" 

Or create the config file config/trustip.php and add this code:

<?php

return [
    /*
     * The API key used to authenticate with the trustip API.
     *
     * You can get your API key from https://trustip.io
     */
    'api_key' => env('TRUSTIP_API_KEY'),
];

Usage

You can start using Trustip facade :

use Trustip;

$result = Trustip::check('8.8.8.8');

After that, you should get an output similar to this:

{
    "status":"success",
    "data": {
        "ip":"8.8.8.8",
        "is_proxy":true,
    }
}

If the IP is proxy the is_proxy will be true if not it will be false you can read more at https://docs.trustip.io

If there's an error, the output will be similar to this:

{
    "status":"error",
    "message":"Invalid IP address"
}

Check all errors on https://docs.trustip.io.

You can also use the isIpProxy helper function in your controllers or other classes:

The isIpProxy will return false if the check method throws an exception or returns an error

if (isIpProxy('8.8.8.8')) {
    // IP is a proxy
} else {
    // IP is not a proxy
}

Exceptions

  • Trustip\Trustip\Exceptions\MissingApiKeyException is thrown if the api key is not found in the env file.
  • Trustip\Trustip\Exceptions\InvalidIpAddressException is thrown if the ip address passed to the check method is invalid

Security

If you discover any security related issues, please email support@trustip.io instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

634,760,849 9,707
laravel/framework

The Laravel Framework.

584,532,650 34,931
laravel/tinker

Powerful REPL for the Laravel framework.

493,838,477 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

408,553,772 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

391,429,217 4,660