ip_locator_cn 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +4 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +9 -1
- data/README.md +44 -5
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/ip_locator_cn.gemspec +19 -19
- data/lib/ip_locator_cn/qqwry/city_directly.rb +5 -5
- data/lib/ip_locator_cn/qqwry/isp.rb +7 -7
- data/lib/ip_locator_cn/qqwry/provinces.rb +35 -35
- data/lib/ip_locator_cn/qqwry.rb +39 -34
- data/lib/ip_locator_cn/version.rb +1 -1
- data/lib/ip_locator_cn.rb +4 -3
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7a329456174c6d309051f83b38dce8004116c4e86ef6c6c9c7e816cdee527cc
|
4
|
+
data.tar.gz: ab81c58038e50b9d85bc75853c5670bab3bcee8c537b4de5f692721bc310559b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c76128be6fe760277a4734def75823063827c775c172ecad3d7c484c3174a2ac8839baf31fb8a33d86780fcc33cec3556ade86b84f57e8a831d090843e43c3f
|
7
|
+
data.tar.gz: ee5994b55c2b0ddcab0a2dc509e241f797f05d239d2492fbbe79098f21e149df407e37cb80ae2e2e74ce0007ee1d7bf5c9856a9ed51df1d2fedfa3391b6f87df
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in ip_locator_cn.gemspec
|
6
6
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ip_locator_cn (0.1.
|
4
|
+
ip_locator_cn (0.1.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.3)
|
10
|
+
docile (1.3.1)
|
11
|
+
json (2.2.0)
|
10
12
|
rake (10.5.0)
|
11
13
|
rspec (3.8.0)
|
12
14
|
rspec-core (~> 3.8.0)
|
@@ -21,6 +23,11 @@ GEM
|
|
21
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
24
|
rspec-support (~> 3.8.0)
|
23
25
|
rspec-support (3.8.0)
|
26
|
+
simplecov (0.16.1)
|
27
|
+
docile (~> 1.1)
|
28
|
+
json (>= 1.8, < 3)
|
29
|
+
simplecov-html (~> 0.10.0)
|
30
|
+
simplecov-html (0.10.2)
|
24
31
|
|
25
32
|
PLATFORMS
|
26
33
|
ruby
|
@@ -30,6 +37,7 @@ DEPENDENCIES
|
|
30
37
|
ip_locator_cn!
|
31
38
|
rake (~> 10.0)
|
32
39
|
rspec (~> 3.0)
|
40
|
+
simplecov (~> 0.16.1)
|
33
41
|
|
34
42
|
BUNDLED WITH
|
35
43
|
1.16.6
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# IP Locator CN
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
基于纯真 IP 库解析中国的 IP,参考了“[纯真数据库自动更新原理](https://github.com/shuax/QQWryUpdate/blob/master/update.php)” 和 “[PHP 版本的 IP 搜索源码](https://github.com/itbdw/ip-database/blob/master/src/IpLocation.php)”
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,42 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
从 Gem 包集成的 qqwry.dat 数据库解析 IP:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
2.4.5 :001 > require 'ip_locator_cn'
|
27
|
+
=> true
|
28
|
+
2.4.5 :002 > IpLocatorCn.resolve('60.195.153.98')
|
29
|
+
=> {:province=>"北京", :city=>"顺义区", :country=>"中国", :ip=>"60.195.153.98", :county=>"", :isp=>"", :area=>"中国北京顺义区后沙峪金龙网吧", :origin_country=>"北京市顺义区", :origin_area=>"后沙峪金龙网吧"}
|
30
|
+
```
|
31
|
+
|
32
|
+
在线下载并解码 qqwry.dat ,然后解析 IP:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
2.4.5 :001 > require 'ip_locator_cn'
|
36
|
+
=> true
|
37
|
+
2.4.5 :002 > IpLocatorCn.resolve('60.195.153.98', live_dat: true)
|
38
|
+
=> {:province=>"北京", :city=>"顺义区", :country=>"中国", :ip=>"60.195.153.98", :county=>"", :isp=>"", :area=>"中国北京顺义区后沙峪金龙网吧", :origin_country=>"北京市顺义区", :origin_area=>"后沙峪金龙网吧"}
|
39
|
+
```
|
40
|
+
|
41
|
+
开启调试信息:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
2.4.5 :001 > require 'ip_locator_cn'
|
45
|
+
=> true
|
46
|
+
2.4.5 :002 > IpLocatorCn.resolve('60.195.153.98', live_dat: true, debug: true)
|
47
|
+
[2019-03-01 17:37:46 +0800] => downloading http://update.cz88.net/ip/copywrite.rar
|
48
|
+
[2019-03-01 17:37:46 +0800] => downloading http://update.cz88.net/ip/qqwry.rar
|
49
|
+
[2019-03-01 17:37:49 +0800] => qqwry decoding key is 225
|
50
|
+
[2019-03-01 17:37:49 +0800] => total ip ranges: 472217
|
51
|
+
[2019-03-01 17:37:53 +0800] => pos is 6658343
|
52
|
+
[2019-03-01 17:37:53 +0800] => begin_ip is 60.195.153.0
|
53
|
+
[2019-03-01 17:37:53 +0800] => endip is 60.195.153.255
|
54
|
+
[2019-03-01 17:37:53 +0800] => offset is 696416
|
55
|
+
[2019-03-01 17:37:53 +0800] => country is 北京市顺义区
|
56
|
+
[2019-03-01 17:37:53 +0800] => area is 后沙峪金龙网吧
|
57
|
+
=> {:province=>"北京", :city=>"顺义区", :country=>"中国", :ip=>"60.195.153.98", :county=>"", :isp=>"", :area=>"中国北京顺义区后沙峪金龙网吧", :origin_country=>"北京市顺义区", :origin_area=>"后沙峪金龙网吧"}
|
58
|
+
```
|
26
59
|
|
27
60
|
## Development
|
28
61
|
|
@@ -34,6 +67,12 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
34
67
|
|
35
68
|
Bug reports and pull requests are welcome on GitHub at https://github.com/xiaohui-zhangxh/ip_locator_cn.
|
36
69
|
|
70
|
+
### Test
|
71
|
+
|
72
|
+
```bash
|
73
|
+
bundle exec rspec
|
74
|
+
```
|
75
|
+
|
37
76
|
## License
|
38
77
|
|
39
78
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'ip_locator_cn'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "ip_locator_cn"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/ip_locator_cn.gemspec
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require 'ip_locator_cn/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'ip_locator_cn'
|
8
7
|
spec.version = IpLocatorCn::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['xiaohui']
|
9
|
+
spec.email = ['xiaohui@tanmer.com']
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
11
|
+
spec.summary = 'Resolve IP info in China'
|
12
|
+
spec.description = 'Resolve IP with qqwry.data, can download qqwry.data on the air.'
|
13
|
+
spec.homepage = 'https://github.com/xiaohui-zhangxh/'
|
14
|
+
spec.license = 'MIT'
|
16
15
|
|
17
16
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
17
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
18
|
if spec.respond_to?(:metadata)
|
20
19
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
20
|
|
22
|
-
spec.metadata[
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
23
22
|
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
24
23
|
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
25
24
|
else
|
26
|
-
raise
|
27
|
-
|
25
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
26
|
+
'public gem pushes.'
|
28
27
|
end
|
29
28
|
|
30
29
|
# Specify which files should be added to the gem when it is released.
|
31
30
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
-
spec.files
|
31
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
33
32
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
33
|
end
|
35
|
-
spec.bindir =
|
34
|
+
spec.bindir = 'exe'
|
36
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
-
spec.require_paths = [
|
36
|
+
spec.require_paths = ['lib']
|
38
37
|
|
39
|
-
spec.add_development_dependency
|
40
|
-
spec.add_development_dependency
|
41
|
-
spec.add_development_dependency
|
38
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
39
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
40
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
41
|
+
spec.add_development_dependency 'simplecov', '~> 0.16.1'
|
42
42
|
end
|
@@ -1,40 +1,40 @@
|
|
1
1
|
module IpLocatorCn
|
2
2
|
class QQWry
|
3
|
-
PROVINCES = [
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
3
|
+
PROVINCES = %w[
|
4
|
+
北京
|
5
|
+
天津
|
6
|
+
重庆
|
7
|
+
上海
|
8
|
+
河北
|
9
|
+
山西
|
10
|
+
辽宁
|
11
|
+
吉林
|
12
|
+
黑龙江
|
13
|
+
江苏
|
14
|
+
浙江
|
15
|
+
安徽
|
16
|
+
福建
|
17
|
+
江西
|
18
|
+
山东
|
19
|
+
河南
|
20
|
+
湖北
|
21
|
+
湖南
|
22
|
+
广东
|
23
|
+
海南
|
24
|
+
四川
|
25
|
+
贵州
|
26
|
+
云南
|
27
|
+
陕西
|
28
|
+
甘肃
|
29
|
+
青海
|
30
|
+
台湾
|
31
|
+
内蒙古
|
32
|
+
广西
|
33
|
+
宁夏
|
34
|
+
新疆
|
35
|
+
西藏
|
36
|
+
香港
|
37
|
+
澳门
|
38
38
|
].freeze
|
39
39
|
end
|
40
40
|
end
|
data/lib/ip_locator_cn/qqwry.rb
CHANGED
@@ -4,7 +4,7 @@ require 'ip_locator_cn/qqwry/isp'
|
|
4
4
|
|
5
5
|
module IpLocatorCn
|
6
6
|
class QQWry
|
7
|
-
IP_ENTRY_BYTES = 7
|
7
|
+
IP_ENTRY_BYTES = 7
|
8
8
|
|
9
9
|
attr_reader :first_ip_pos, :last_ip_pos, :total_ips, :debug
|
10
10
|
|
@@ -20,13 +20,15 @@ module IpLocatorCn
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# return: <Hash> result
|
23
|
-
# result['ip']
|
24
|
-
# result['country']
|
25
|
-
# result['province']
|
26
|
-
# result['city']
|
27
|
-
# result['county']
|
28
|
-
# result['isp']
|
29
|
-
# result['area']
|
23
|
+
# result['ip'] 输入的ip
|
24
|
+
# result['country'] 国家 如 中国
|
25
|
+
# result['province'] 省份信息 如 河北省
|
26
|
+
# result['city'] 市区 如 邢台市
|
27
|
+
# result['county'] 郡县 如 威县
|
28
|
+
# result['isp'] 运营商 如 联通
|
29
|
+
# result['area'] 最完整的信息 如 中国河北省邢台市威县新科网吧(北外街)
|
30
|
+
# result['origin_country'] 解析之前的原始信息
|
31
|
+
# result['origin_area'] 解析之前的原始信息
|
30
32
|
def resolve(ip)
|
31
33
|
location = location_from_ip(ip)
|
32
34
|
extract_location(location[:country]).tap do |result|
|
@@ -43,6 +45,8 @@ module IpLocatorCn
|
|
43
45
|
result[:county],
|
44
46
|
location[:area]
|
45
47
|
].join
|
48
|
+
result[:origin_country] = location[:country]
|
49
|
+
result[:origin_area] = location[:area]
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
@@ -52,40 +56,40 @@ module IpLocatorCn
|
|
52
56
|
log "pos is #{pos}"
|
53
57
|
# 用户IP所在范围的开始地址
|
54
58
|
seek(pos)
|
55
|
-
begin_ip = long2ip(read_ip
|
59
|
+
begin_ip = long2ip(read_ip)
|
56
60
|
log "begin_ip is #{begin_ip}"
|
57
61
|
# 用户IP所在范围的结束地址
|
58
|
-
offset = getlong3
|
62
|
+
offset = getlong3
|
59
63
|
seek(offset)
|
60
|
-
endip = long2ip(read_ip
|
64
|
+
endip = long2ip(read_ip)
|
61
65
|
log "endip is #{endip}"
|
62
66
|
log "offset is #{offset}"
|
63
67
|
byte = read(1) # 标志字节
|
64
68
|
case byte.ord
|
65
69
|
when 1
|
66
70
|
# 标志字节为1,表示国家和区域信息都被同时重定向
|
67
|
-
country_offset = getlong3
|
71
|
+
country_offset = getlong3 # 重定向地址
|
68
72
|
seek(country_offset)
|
69
73
|
byte = read(1) # 标志字节
|
70
74
|
case byte.ord
|
71
75
|
when 2
|
72
76
|
seek(getlong3)
|
73
|
-
info[:country] = getstring
|
77
|
+
info[:country] = getstring
|
74
78
|
seek(country_offset + 4)
|
75
|
-
info[:area] = getarea
|
79
|
+
info[:area] = getarea
|
76
80
|
else
|
77
81
|
info[:country] = getstring(byte)
|
78
|
-
info[:area] = getarea
|
82
|
+
info[:area] = getarea
|
79
83
|
end
|
80
84
|
when 2
|
81
85
|
# 标志字节为2,表示国家信息被重定向
|
82
86
|
seek(getlong3)
|
83
|
-
info[:country] = getstring
|
87
|
+
info[:country] = getstring
|
84
88
|
seek(offset + 8)
|
85
|
-
info[:area] = getarea
|
89
|
+
info[:area] = getarea
|
86
90
|
else
|
87
91
|
info[:country] = getstring(byte)
|
88
|
-
info[:area] = getarea
|
92
|
+
info[:area] = getarea
|
89
93
|
end
|
90
94
|
|
91
95
|
info[:country] = encoding_convert(info[:country])
|
@@ -116,8 +120,8 @@ module IpLocatorCn
|
|
116
120
|
if str.include?(seperator_sheng)
|
117
121
|
collection[:province], str = str.split(seperator_sheng, 2)
|
118
122
|
else
|
119
|
-
province = (PROVINCES + CITY_DIRECTLY).find{ |x| str.start_with?(x) }
|
120
|
-
if
|
123
|
+
province = (PROVINCES + CITY_DIRECTLY).find { |x| str.start_with?(x) }
|
124
|
+
if province
|
121
125
|
collection[:province] = province
|
122
126
|
is_city_directly = CITY_DIRECTLY.include?(province)
|
123
127
|
str = str[province.length..-1]
|
@@ -162,8 +166,8 @@ module IpLocatorCn
|
|
162
166
|
|
163
167
|
def live_load_dat
|
164
168
|
require 'open-uri'
|
165
|
-
copywrite = download(IpLocatorCn.copywrite_url).read
|
166
|
-
qqwry = download(IpLocatorCn.live_data_url).read.bytes
|
169
|
+
(copywrite = download(IpLocatorCn.copywrite_url).read) && nil
|
170
|
+
(qqwry = download(IpLocatorCn.live_data_url).read.bytes) && nil
|
167
171
|
key = copywrite.unpack('V6')[5]
|
168
172
|
log "qqwry decoding key is #{key}"
|
169
173
|
(0...0x200).each do |i|
|
@@ -172,25 +176,26 @@ module IpLocatorCn
|
|
172
176
|
key &= 0xFF
|
173
177
|
qqwry[i] ^= key
|
174
178
|
end
|
175
|
-
qqwry = Zlib::Inflate.inflate(qqwry.pack('C*'))
|
179
|
+
(qqwry = Zlib::Inflate.inflate(qqwry.pack('C*'))) && nil
|
176
180
|
@io = StringIO.new(qqwry)
|
177
181
|
end
|
178
182
|
|
179
183
|
def parse_dat_info
|
180
|
-
@first_ip_pos = getlong4
|
181
|
-
@last_ip_pos = getlong4
|
184
|
+
@first_ip_pos = getlong4
|
185
|
+
@last_ip_pos = getlong4
|
182
186
|
@total_ips = (last_ip_pos - first_ip_pos) / IP_ENTRY_BYTES
|
183
187
|
log "total ip ranges: #{total_ips}"
|
184
188
|
end
|
185
189
|
|
186
190
|
def get_isp(str)
|
187
|
-
ISP.find {|x| str.include?(x)}
|
191
|
+
ISP.find { |x| str.include?(x) }
|
188
192
|
end
|
189
193
|
|
190
194
|
# b-tree search ip from qqwry.dat
|
191
195
|
def locate_ip_pos(ip)
|
192
196
|
x = ip2long(ip)
|
193
|
-
min
|
197
|
+
min = 0
|
198
|
+
max = total_ips
|
194
199
|
|
195
200
|
while min <= max
|
196
201
|
# b-tree search
|
@@ -198,14 +203,14 @@ module IpLocatorCn
|
|
198
203
|
pos = first_ip_pos + i * IP_ENTRY_BYTES
|
199
204
|
seek(pos)
|
200
205
|
# get middle ip
|
201
|
-
y = read_ip
|
206
|
+
y = read_ip
|
202
207
|
if x < y
|
203
208
|
# user ip < middle ip
|
204
209
|
max = i - 1
|
205
210
|
else
|
206
211
|
# user ip > middle ip, read next ip entry
|
207
212
|
read(3)
|
208
|
-
y = read_ip
|
213
|
+
y = read_ip
|
209
214
|
if x > y
|
210
215
|
# user ip > next ip
|
211
216
|
min = i + 1
|
@@ -243,14 +248,14 @@ module IpLocatorCn
|
|
243
248
|
end
|
244
249
|
|
245
250
|
def ipparts2long(parts)
|
246
|
-
0.upto(3).map{|i| parts[i] << ((3 - i) * 8) }.sum
|
251
|
+
0.upto(3).map { |i| parts[i] << ((3 - i) * 8) }.sum
|
247
252
|
end
|
248
253
|
|
249
254
|
def long2ip(n)
|
250
|
-
0.upto(3).map{|i| (n >> ((3 - i) * 8)) & 0xFF }.join('.')
|
255
|
+
0.upto(3).map { |i| (n >> ((3 - i) * 8)) & 0xFF }.join('.')
|
251
256
|
end
|
252
257
|
|
253
|
-
def getstring(data='')
|
258
|
+
def getstring(data = '')
|
254
259
|
char = read(1)
|
255
260
|
while char.ord > 0
|
256
261
|
data += char
|
@@ -267,14 +272,14 @@ module IpLocatorCn
|
|
267
272
|
return ''
|
268
273
|
when 1, 2
|
269
274
|
seek(getlong3)
|
270
|
-
return getstring
|
275
|
+
return getstring
|
271
276
|
else
|
272
277
|
return getstring(char)
|
273
278
|
end
|
274
279
|
end
|
275
280
|
|
276
281
|
def encoding_convert(str)
|
277
|
-
ec = Encoding::Converter.new(
|
282
|
+
ec = Encoding::Converter.new('GBK', 'UTF-8')
|
278
283
|
result = ec.convert(str)
|
279
284
|
ec.finish
|
280
285
|
result
|
data/lib/ip_locator_cn.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'ip_locator_cn/version'
|
2
2
|
require 'ip_locator_cn/qqwry'
|
3
|
+
|
3
4
|
module IpLocatorCn
|
4
5
|
# embeded qqwry.dat
|
5
6
|
def self.data_path
|
@@ -15,7 +16,7 @@ module IpLocatorCn
|
|
15
16
|
'http://update.cz88.net/ip/copywrite.rar'
|
16
17
|
end
|
17
18
|
|
18
|
-
def self.resolve(ip)
|
19
|
-
QQWry.new(
|
19
|
+
def self.resolve(ip, options={ dat_path: data_path })
|
20
|
+
QQWry.new(options).resolve(ip)
|
20
21
|
end
|
21
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ip_locator_cn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xiaohui
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.16.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.16.1
|
55
69
|
description: Resolve IP with qqwry.data, can download qqwry.data on the air.
|
56
70
|
email:
|
57
71
|
- xiaohui@tanmer.com
|
@@ -61,6 +75,7 @@ extra_rdoc_files: []
|
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
63
77
|
- ".rspec"
|
78
|
+
- ".rubocop.yml"
|
64
79
|
- ".travis.yml"
|
65
80
|
- Gemfile
|
66
81
|
- Gemfile.lock
|