maxmind_proxy_detection 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/lib/maxmind_proxy_detection.rb +46 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzdkOTNlZjc1NjIwNzc5NzRkMGQ0MjU4MDE2ZmNhYzgyY2I2MDM3NQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDgxMTU3NTg4NmQ1OWVmMzk5NWQ1YjYzMTc5YWMyMzA3ZjE4NTc1ZA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDQxMDVkYTgxNzM2ZjdhZTE2NTM4NDU1YzI5YWYyOWFiYmJiODYwZmE5N2Vm
|
10
|
+
NzQ5ZTg1MWRkOTdmMWRlYjRkNGM3NjY1MTkzMWMxMzY1ZWM1YmNjOWNmNzcy
|
11
|
+
N2E1MGY0ZjRmMTkzY2Q3YjYyYmY2MThhNDE0MmVhNGQwMTIwMjY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YmRiN2YwYzA0ZWVhMzZjZGNhOTE1YmY1Y2YwNWI3Y2QyNGE0YmY3OGMyODEx
|
14
|
+
OGZmYjc2YzY4YTBkMjRhNjI2OTBhODcxNTBhZDg4YzI5MDhjODAyOTQ3Yjcy
|
15
|
+
OGFlODdjNTg4ZjE5ZDBkYjEzYjRlNDg5Y2QyNmRjMGVjZGE0OTg=
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'excon'
|
2
|
+
|
3
|
+
module MaxmindProxyDetection
|
4
|
+
URL = 'https://minfraud.maxmind.com/app/ipauth_http'
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_writer :license_key
|
8
|
+
|
9
|
+
def available?
|
10
|
+
return true if @license_key && !@license_key.empty?
|
11
|
+
return false
|
12
|
+
end
|
13
|
+
|
14
|
+
# Query Maxmind Proxy Detection service with given ip and set license_key.
|
15
|
+
# @return [Float, nil] Proxy score from 0.0 to 4.0. Nil if IP is invalid.
|
16
|
+
def score(ip)
|
17
|
+
response = request(ip)
|
18
|
+
|
19
|
+
raise 'Request to Maxmind Proxy Detection service failed' unless response.status == 200
|
20
|
+
|
21
|
+
# Parse response
|
22
|
+
key, value = response.body.split('=')
|
23
|
+
|
24
|
+
# Process response
|
25
|
+
case key
|
26
|
+
when 'err'
|
27
|
+
raise 'Error returned by Maxmind Proxy Detection service'
|
28
|
+
when 'proxyScore'
|
29
|
+
return value.to_f if value
|
30
|
+
return nil # According to documentation, response does not contain value if IP is invalid
|
31
|
+
else
|
32
|
+
raise 'Unknown response from Maxmind Proxy Detection service'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def request(ip)
|
38
|
+
# Maxmind Proxy Detection service accepts query strings (GET) and for posts (POST). We use form post with
|
39
|
+
# parameters in body to minimize the chance that license_key is stored in clear by a proxy or a logger.
|
40
|
+
return Excon.post(URL,
|
41
|
+
body: URI.encode_www_form(i: ip, l: @license_key),
|
42
|
+
headers: {'Content-Type' => 'application/x-www-form-urlencoded'}
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maxmind_proxy_detection
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: excon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest-reporters
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - <
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - <
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
description: A wrapper for MaxMind's Proxy Detection service.
|
42
|
+
email: eric.github@smartlove.fr
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/maxmind_proxy_detection.rb
|
48
|
+
homepage: https://github.com/eric-smartlove/maxmind_proxy_detection
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements:
|
67
|
+
- A MaxMind account with a subscription for Proxy Detection service
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 2.1.11
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: Wrapper for MaxMind's Proxy Detection service
|
73
|
+
test_files: []
|