nx-real-ip 0.1.1 → 0.1.6

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: 4a4069d478640f692d2e765b3bf4324f301270f298afc794108f2e770d8c4785
4
- data.tar.gz: 1603262ef3ae9f106dbc73e8fad8636675091748a554ca2d590bd69c46648880
3
+ metadata.gz: feab46862cb76e215b2534a235e376e723f403f189d5af79db59e477f8080028
4
+ data.tar.gz: 8bf598306a884cb84ac4466e29489b3c22efde20979f4cf1782f20816daf8a37
5
5
  SHA512:
6
- metadata.gz: d59a2cc02c75cfaa7d75e0fa6e601dbc709b6eb5677e76503420389d4377cb79a1bc654a2ed70e799de4ee1b743b515bd95db64292d4aebca893edb32279bb52
7
- data.tar.gz: 7b8d74ec99ef944b89daf1a26bba142728929b490315f370c1f8fb5861ac6ee56a67e6b677d52a8011ac834361c62349b6595747f37db771d4091100cc8cc734
6
+ metadata.gz: a3c3e869b122a051480ca76f1f6ebdf7a6a7aa8fad5828752803682bd94c827791b71675aca4f4724ed4795d12a05460619009ca8faa929e9a71d9e0a145cd1b
7
+ data.tar.gz: eae98b2731f31139802fd2ea7a2bd850332610d22ff587776fe6802e8fbfeadf00beded84f32ae32bb432dfd3858c8034a642fc008e2ae0b2dfaa6478996534b
@@ -1,2 +1,2 @@
1
- require "nx/version"
2
- require "nx/real-ip"
1
+ require_relative "./nx/version"
2
+ require_relative "./nx/real-ip"
@@ -1,16 +1,26 @@
1
1
  require "open-uri"
2
2
 
3
+ RE_IP_ADDRESS = /\b\d+\.\d+\.\d+\.\d+\b/
4
+
3
5
  module Nx
4
6
  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
7
+ def self.get(args = { timeout: 5, proxy: nil })
8
+ begin
9
+ real_ip = open(
10
+ "http://icanhazip.com/",
11
+ read_timeout: args[:timeout],
12
+ open_timeout: args[:timeout],
13
+ proxy: args[:proxy],
14
+ ).read
12
15
 
13
- real_ip.strip
16
+ if RE_IP_ADDRESS.match? real_ip
17
+ return real_ip.strip
18
+ else
19
+ nil
20
+ end
21
+ rescue Exception => e
22
+ end
23
+ nil
14
24
  end
15
25
  end
16
26
  end
@@ -1,5 +1,5 @@
1
1
  module Nx
2
2
  class RealIp
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
Binary file
Binary file
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "nx-real-ip",
3
+ "version": "1.0.0",
4
+ "description": "> Get real ip address.",
5
+ "directories": {
6
+ "lib": "lib"
7
+ },
8
+ "scripts": {
9
+ "clean": "rm -rf *.gem",
10
+ "build": "gem build *.gemspec",
11
+ "pubpush": "gem push *.gem"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/afeiship/nx-real-ip.git"
16
+ },
17
+ "keywords": [],
18
+ "author": "",
19
+ "license": "ISC",
20
+ "bugs": {
21
+ "url": "https://github.com/afeiship/nx-real-ip/issues"
22
+ },
23
+ "homepage": "https://github.com/afeiship/nx-real-ip#readme"
24
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nx-real-ip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - afeiship
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-03 00:00:00.000000000 Z
11
+ date: 2020-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,8 +60,10 @@ files:
60
60
  - lib/nx-real-ip.rb
61
61
  - lib/nx/real-ip.rb
62
62
  - lib/nx/version.rb
63
- - nx-real-ip-0.1.0.gem
63
+ - nx-real-ip-0.1.4.gem
64
+ - nx-real-ip-0.1.5.gem
64
65
  - nx-real-ip.gemspec
66
+ - package.json
65
67
  homepage: https://github.com/afeiship/nx-real-ip
66
68
  licenses:
67
69
  - MIT
@@ -81,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
83
  - !ruby/object:Gem::Version
82
84
  version: '0'
83
85
  requirements: []
84
- rubygems_version: 3.1.2
86
+ rubygems_version: 3.0.3
85
87
  signing_key:
86
88
  specification_version: 4
87
89
  summary: Get real ip.
Binary file