nx-real-ip 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed31b4f5fcfaaa8c5bf5f726dc1db224f21390b1418ed9a2bd849c0e029afb09
4
- data.tar.gz: 2be6bed18f26208c111cd3d5c6c22639d5677d0d3b89f3c57635ae8641224f02
3
+ metadata.gz: 4a4069d478640f692d2e765b3bf4324f301270f298afc794108f2e770d8c4785
4
+ data.tar.gz: 1603262ef3ae9f106dbc73e8fad8636675091748a554ca2d590bd69c46648880
5
5
  SHA512:
6
- metadata.gz: 7f0b2a4f3d3b4bd89d8a5c9f4bc634a77b239380c10a5cd2061fbba9563936884c5f65c4a595077f585eda2b76c016e1f999edf1c932bf158bfb6a8689d6de22
7
- data.tar.gz: 934191db3d6395e8c022b3360c9a26dbade6820d64571db015c942e99cdb5a0c058990d981bba3c2d725b566cfb70aed54151d25950ebe9e34758b4b666b8c93
6
+ metadata.gz: d59a2cc02c75cfaa7d75e0fa6e601dbc709b6eb5677e76503420389d4377cb79a1bc654a2ed70e799de4ee1b743b515bd95db64292d4aebca893edb32279bb52
7
+ data.tar.gz: 7b8d74ec99ef944b89daf1a26bba142728929b490315f370c1f8fb5861ac6ee56a67e6b677d52a8011ac834361c62349b6595747f37db771d4091100cc8cc734
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in templates.gemspec
4
+ gemspec
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
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/nx-real-ip.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "nx/version"
2
+ require "nx/real-ip"
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
@@ -0,0 +1,5 @@
1
+ module Nx
2
+ class RealIp
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
Binary file
@@ -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.0
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