IP2Proxy Ruby on Rails Library
This IP2Proxy Ruby on Rails library allows user to reverse search of IP address to detect VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots, data center ranges, residential proxies, consumer privacy networks, and enterprise private networks using IP2Proxy BIN database. Other information available includes proxy type, country, state, city, ISP, domain name, usage type, AS number, AS name, threats, last seen date and provider names. It lookup the proxy IP address from IP2Proxy BIN Data file.
INSTALLATION
- Add this lines to your application's Gemfile:
ruby gem 'ip2proxy_ruby' gem 'ip2proxy_rails'
- Then execute it
bash $ bundle install
- Open the preferred file in the
config/environments
directory. Add the following code to the chosen configuration file after theRails.application.configure do
line.ruby config.ip2proxy_db_path = Rails.root.join('lib', 'assets', 'ip2proxy_rails', 'IP2PROXY.BIN').to_s
USAGE
- Download IP2Proxy BIN database
- IP2Proxy LITE database at https://lite.ip2location.com
- IP2Proxy Commercial database at https://www.ip2location.com/proxy-database
- Create a folder named as
ip2proxy_rails
in thelib/assets
directory. - Unzip and copy the BIN file into
lib/assets/ip2proxy_rails
folder. - Rename the BIN file to IP2PROXY.BIN.
- Create a TestController using the below command line
bash bin/rails generate controller Test index --skip-routes
- Open the app/controllers/test_controller.rb in any text editor.
- Add the below lines into the controller file. ```ruby require 'ip2proxy_rails'
class TestController < ApplicationController def index proxy_service = Ip2proxyRails.new('1.2.3.4') @is_proxy = proxy_service.is_proxy @proxy_type = proxy_service.proxy_type @country_code = proxy_service.country_code @country_name = proxy_service.country_name @region = proxy_service.region @city = proxy_service.city @isp = proxy_service.isp @domain = proxy_service.domain @usage_type = proxy_service.usagetype @asn = proxy_service.asn @as = proxy_service.as @last_seen = proxy_service.last_seen @threat = proxy_service.threat @provider = proxy_service.provider @fraud_score = proxy_service.fraud_score end end
8. Open the *app/views/test/index.html.erb* in any text editor and add the below lines into it.
is Proxy: <%= @is_proxy %>
Proxy Type: <%= @proxy_type %>
Country Code: <%= @country_code %>
Country Name: <%= @country_name %>
Region Name: <%= @region %>
City Name: <%= @city %>
ISP Name: <%= @isp %>
Domain Name: <%= @domain %>
Usage Type: <%= @usage_type %>
ASN: <%= @asn %>
AS: <%= @as %>
Last Seen: <%= @last_seen %>
Threat: <%= @threat %>
Provider: <%= @provider %>
Fraud Score: <%= @fraud_score %>
9. Add the following line into the *config/routes.rb* file after the `Rails.application.routes.draw do` line.
```ruby
get "/test", to: "test#index"
- Restart your development server.
bash $ bin/rails server
- Enter the URL
/test and run. You should see the proxy information of 1.2.3.4 IP address.
Dependencies
This library requires IP2Proxy BIN data file to function. You may download the BIN data file at
- IP2Proxy LITE BIN Data (Free): https://lite.ip2location.com
- IP2Proxy Commercial BIN Data (Comprehensive): https://www.ip2location.com/proxy-database
Support
Email: support@ip2location.com URL: https://www.ip2location.com