sockit 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c121958f45f2d643ce189f5b7931eda37cea135
4
- data.tar.gz: 04bfee78cc8309658de13c3f6dd9f8b8a313e2bc
3
+ metadata.gz: d4cb03123797163d6a7b4a0277a607497eb0cd9c
4
+ data.tar.gz: 4af7863f1723de14a2d0acd54eea61bf1b5038bd
5
5
  SHA512:
6
- metadata.gz: b90163e36c436a4424aef2e6236e3d1f54628897931c79e69d3f67bf0905bdb7c452407c2deddcc0153e8c329c379b965551fa610faaa4c4d1ff51c3f1e83f68
7
- data.tar.gz: 9facd1457c32dcc3f7474f74e845a489b91d3822fe3db1bb4063b10c83760df351d0300e2f4a5bf580143bb712ca41e47b9aafb7167063cce8d8e05eb238b6fe
6
+ metadata.gz: 7e6d1428f0ac8cab895403bc04f93ee6ec4db8b4906eb146e44b943c55c01d558c041f9a634f000bc3bf13f3d044751a93e56c11461e81356ac3698ecc3e1a40
7
+ data.tar.gz: d380d476862b6fc0d1edf78af829a2785ee37f54e3e6c7112ad265b8c42b7dbab59063f27641e40e7146757eef2fdc427d1569d5721f5f3f9f875b999efb04be
@@ -2,9 +2,9 @@ module Sockit
2
2
  module Connection
3
3
 
4
4
  def direct_connect(socket, remote_host, remote_port, local_host=nil, local_port=nil)
5
- log(:yellow, "Directly connecting to #{remote_host}:#{remote_port}")
5
+ Sockit.enabled? and log(:yellow, "Directly connecting to #{remote_host}:#{remote_port}")
6
6
  socket.__send__(:initialize_tcp, remote_host, remote_port, local_host=nil, local_port=nil)
7
- log(:green, "Connected to #{remote_host}:#{remote_port}")
7
+ Sockit.enabled? and log(:green, "Connected to #{remote_host}:#{remote_port}")
8
8
  end
9
9
 
10
10
  def connect(socket, host, port)
@@ -18,7 +18,7 @@ module Sockit
18
18
  end
19
19
 
20
20
  def connect_via_socks?(host)
21
- (is_configured? && !config.ignore.flatten.include?(host))
21
+ (is_configured? && !config.ignore.flatten.any?{ |ignored_host| host =~ /#{ignored_host}/ }
22
22
  end
23
23
 
24
24
  def is_socks_v5?
@@ -21,7 +21,7 @@
21
21
  module Sockit
22
22
 
23
23
  unless const_defined?(:VERSION)
24
- VERSION = "1.1.1"
24
+ VERSION = "1.2.0"
25
25
  end
26
26
 
27
27
  end
data/lib/sockit.rb CHANGED
@@ -69,6 +69,18 @@ module Sockit
69
69
  end
70
70
  end
71
71
 
72
+ def enabled
73
+ @@enabled ||= false
74
+ end
75
+
76
+ def enable
77
+ @@enabled = true
78
+ end
79
+
80
+ def disable
81
+ @@enabled = false
82
+ end
83
+
72
84
  extend Sockit::V5::Authentication
73
85
  extend Sockit::V5::Connection
74
86
  extend Sockit::V5::Support
@@ -83,8 +95,9 @@ end
83
95
  class TCPSocket
84
96
 
85
97
  alias :initialize_tcp :initialize
98
+
86
99
  def initialize(remote_host, remote_port, local_host=nil, local_port=nil)
87
- if Sockit.connect_via_socks?(remote_host)
100
+ if Sockit.enabled? && Sockit.connect_via_socks?(remote_host)
88
101
  initialize_tcp(Sockit.config.host, Sockit.config.port)
89
102
  Sockit.perform_v5_authenticate(self) if Sockit.is_socks_v5?
90
103
  Sockit.connect(self, remote_host, remote_port)
@@ -92,4 +105,5 @@ class TCPSocket
92
105
  Sockit.direct_connect(self, remote_host, remote_port, local_host, local_port)
93
106
  end
94
107
  end
108
+
95
109
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sockit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Patten
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-08 00:00:00.000000000 Z
11
+ date: 2017-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter