private_address_check 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of private_address_check might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69dffe5d95058be5d6d131dd7e27843b02e736ac
4
- data.tar.gz: 12043ad0e982f7bfc4e95050151b69a8fb3575f9
3
+ metadata.gz: a083cb52ac474ff6cf8ce66319809d17fa577fa3
4
+ data.tar.gz: 48f618961a48b3af93a1c1985b50538bcc1edaff
5
5
  SHA512:
6
- metadata.gz: 230e58a7c57213f83ee7975b05329aaa17b0a5c2f99d55325ff50fc1b9d76faeb616e4ce4ce24aa4b722bf819743e2ec75b36d2c113a91e1d89a929d63d58192
7
- data.tar.gz: f93358263bdd8fd37a62495a33402dc149a51d67c0a00928f54f1aaf0073e748654a36ba37f8b3b5f49ba1c04ee5bf7b233a35e633ff37a1bde9e834040e1935
6
+ metadata.gz: 66da1452e9f52d5ae201a8717d13142589f5df45562815755a169fcacd028be29f18e6ecedd66530ef8139852331d3f4ca8645b90d338cca0d91b3078ec8bb60
7
+ data.tar.gz: 36c62e3ab8a039711793fa6bd1ea655942d4dec9a03bb863c21f561ebb1fe00d1e73402e69d8bf58ecebabc753f701add6201fdc8f8145e35460ce0ea96a37e3
data/README.md CHANGED
@@ -41,7 +41,7 @@ PrivateAddressCheck.resolves_to_private_address?("localhost") # => true
41
41
 
42
42
  require "private_address_check/tcpsocket_ext"
43
43
  require "net/http"
44
- require "require "uri""
44
+ require "uri"
45
45
 
46
46
  Net::HTTP.get_response(URI.parse("http://192.168.1.1")) # => attempts connection like normal
47
47
 
@@ -13,12 +13,11 @@ module PrivateAddressCheck
13
13
  module TCPSocketExt
14
14
  def initialize(remote_host, remote_port, local_host = nil, local_port = nil)
15
15
  if Thread.current[:private_address_check]
16
- ip = Resolv.getaddress(remote_host)
17
- if PrivateAddressCheck.private_address?(ip)
16
+ if PrivateAddressCheck.resolves_to_private_address?(remote_host)
18
17
  raise PrivateAddressCheck::PrivateConnectionAttemptedError
19
18
  end
20
19
 
21
- super(ip, remote_port, local_host, local_port)
20
+ super(remote_host, remote_port, local_host, local_port)
22
21
  else
23
22
  super
24
23
  end
@@ -1,3 +1,3 @@
1
1
  module PrivateAddressCheck
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -19,4 +19,12 @@ class TCPSocketExtTest < Minitest::Test
19
19
 
20
20
  assert connected
21
21
  end
22
+
23
+ def test_invalid_domain
24
+ assert_raises SocketError do
25
+ PrivateAddressCheck.only_public_connections do
26
+ TCPSocket.new("not_a_domain", 80)
27
+ end
28
+ end
29
+ end
22
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: private_address_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Downey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-21 00:00:00.000000000 Z
11
+ date: 2016-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,8 +68,8 @@ files:
68
68
  - lib/private_address_check.rb
69
69
  - lib/private_address_check/tcpsocket_ext.rb
70
70
  - lib/private_address_check/version.rb
71
+ - test/private_address_check/tcpsocket_ext_test.rb
71
72
  - test/private_address_check_test.rb
72
- - test/tcpsocket_ext_test.rb
73
73
  - test/test_helper.rb
74
74
  homepage: https://github.com/jtdowney/private_address_check
75
75
  licenses: