nx-real-ip 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +27 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/nx-real-ip.rb +2 -0
- data/lib/nx/real-ip.rb +16 -0
- data/lib/nx/version.rb +5 -0
- data/nx-real-ip-0.1.0.gem +0 -0
- data/nx-real-ip.gemspec +35 -0
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a4069d478640f692d2e765b3bf4324f301270f298afc794108f2e770d8c4785
|
4
|
+
data.tar.gz: 1603262ef3ae9f106dbc73e8fad8636675091748a554ca2d590bd69c46648880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d59a2cc02c75cfaa7d75e0fa6e601dbc709b6eb5677e76503420389d4377cb79a1bc654a2ed70e799de4ee1b743b515bd95db64292d4aebca893edb32279bb52
|
7
|
+
data.tar.gz: 7b8d74ec99ef944b89daf1a26bba142728929b490315f370c1f8fb5861ac6ee56a67e6b677d52a8011ac834361c62349b6595747f37db771d4091100cc8cc734
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# nx-real-ip
|
2
|
+
> Get real ip address.
|
3
|
+
|
4
|
+
## installation
|
5
|
+
```rb
|
6
|
+
# from gem
|
7
|
+
gem 'nx-real-ip'
|
8
|
+
# from git
|
9
|
+
gem 'nx-real-ip', git: 'git@github.com:afeiship/nx-real-ip.git'
|
10
|
+
```
|
11
|
+
|
12
|
+
## usage
|
13
|
+
```rb
|
14
|
+
Nx::RealIp::get
|
15
|
+
Nx::RealIp::get(proxy:'http://120.234.63.196:3128')
|
16
|
+
|
17
|
+
# 220.11.10.123
|
18
|
+
```
|
19
|
+
|
20
|
+
## build/publish
|
21
|
+
```shell
|
22
|
+
# build
|
23
|
+
gem build nx-real-ip.gemspec
|
24
|
+
|
25
|
+
# publish
|
26
|
+
gem push nx-real-ip-0.1.0.gem
|
27
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "nx-real-ip"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/nx-real-ip.rb
ADDED
data/lib/nx/real-ip.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
|
3
|
+
module Nx
|
4
|
+
class RealIp
|
5
|
+
def get(args = { timeout: 5, proxy: nil })
|
6
|
+
real_ip = open(
|
7
|
+
"http://icanhazip.com/",
|
8
|
+
read_timeout: args[:timeout],
|
9
|
+
open_timeout: args[:timeout],
|
10
|
+
proxy: args[:proxy],
|
11
|
+
).read
|
12
|
+
|
13
|
+
real_ip.strip
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/nx/version.rb
ADDED
Binary file
|
data/nx-real-ip.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "nx/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nx-real-ip"
|
8
|
+
spec.version = Nx::RealIp::VERSION
|
9
|
+
spec.licenses = ["MIT"]
|
10
|
+
spec.authors = ["afeiship"]
|
11
|
+
spec.email = ["1290657123@qq.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{Get real ip.}
|
14
|
+
spec.description = %q{Get real ip address.}
|
15
|
+
spec.homepage = "https://github.com/afeiship/nx-real-ip"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
34
|
+
spec.add_development_dependency "rake", "~> 12.3", ">= 12.3.3"
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nx-real-ip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- afeiship
|
@@ -50,7 +50,18 @@ email:
|
|
50
50
|
executables: []
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|
53
|
-
files:
|
53
|
+
files:
|
54
|
+
- ".gitignore"
|
55
|
+
- Gemfile
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- bin/console
|
59
|
+
- bin/setup
|
60
|
+
- lib/nx-real-ip.rb
|
61
|
+
- lib/nx/real-ip.rb
|
62
|
+
- lib/nx/version.rb
|
63
|
+
- nx-real-ip-0.1.0.gem
|
64
|
+
- nx-real-ip.gemspec
|
54
65
|
homepage: https://github.com/afeiship/nx-real-ip
|
55
66
|
licenses:
|
56
67
|
- MIT
|