netsoul 2.3.1 → 2.3.2

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: f511c891783d06060a8d654ebbdf37c041d620fd
4
- data.tar.gz: f63b6c750f8b96ec56fa4157cb26c8ba6fbfe8ad
3
+ metadata.gz: d9f097f6171effa2f3bd38fbecea89406384c946
4
+ data.tar.gz: 3864a93c873ac2a74e3fe944f50e2b95163a9888
5
5
  SHA512:
6
- metadata.gz: 84754812cf7271daf35e82578987f093d197e6d1a94763bb9681ecee6a29a5a230203ead449d6b7c722c118322e106376619d9bde31b8337df7df7604c2ae0ff
7
- data.tar.gz: 5132d4dd76c213ff170b4c1973a9dff1ab1eda35a5e08b43288d405226cff93baf02b4d64ae0c39bb97994d6b45c271df5c1fbcbf97a15803f3fa7046cc4094a
6
+ metadata.gz: 39920b1fe6209190bb9d2c0ac72bedbc1e567f25a1e37e9a0d05851add0ecfe3ceadb5253cf691daaa7552f4459d3b05a386ca0da6e3808e5692fc79128100d9
7
+ data.tar.gz: ee510ac2bec7789ab66b59b8352cdafd12ec7e00bb1a279d39bbcbd5d2121cf3bb7b3e8d02cfebe28e49bbaae3d1177fd67ba4f7516f199adcbd3d09832a27e7
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
 
3
3
  require_relative '../netsoul'
4
4
  require 'socket'
@@ -18,7 +18,7 @@ module Netsoul
18
18
 
19
19
  def auth_ag
20
20
  send(Message.auth_ag)
21
- fail Netsoul::IdentificationError, 'Identification failed.'.freeze unless get.split(' '.freeze)[1] == '002'.freeze
21
+ raise Netsoul::IdentificationError, 'Identification failed.'.freeze unless get.split(' '.freeze)[1] == '002'.freeze
22
22
  end
23
23
  private :auth_ag
24
24
 
@@ -28,7 +28,7 @@ module Netsoul
28
28
  else
29
29
  send(Message.standard_auth(@config))
30
30
  end
31
- fail Netsoul::AuthenticationError, 'Authentication failed. See your config file or environment variables'.freeze \
31
+ raise Netsoul::AuthenticationError, 'Authentication failed. See your config file or environment variables'.freeze \
32
32
  unless get.split(' '.freeze)[1] == '002'.freeze
33
33
  end
34
34
  private :auth_method
@@ -41,7 +41,7 @@ module Netsoul
41
41
 
42
42
  def connect
43
43
  @socket = TCPSocket.new(@config.server_host, @config.server_port)
44
- fail Netsoul::SocketError, 'Could not open a socket. Connection is unavailable.'.freeze unless @socket
44
+ raise Netsoul::SocketError, 'Could not open a socket. Connection is unavailable.'.freeze unless @socket
45
45
  _cmd, _socket_num, md5_hash, client_ip, client_port, _server_timestamp = get.split
46
46
 
47
47
  @config.build_user_connection_info md5_hash: md5_hash, client_ip: client_ip, client_port: client_port
@@ -61,18 +61,21 @@ module Netsoul
61
61
 
62
62
  def send(str)
63
63
  _, sock = IO.select(nil, [@socket], nil, SOCKET_WRITE_TIMEOUT)
64
- fail Netsoul::SocketError, 'Timeout or fail on write socket'.freeze if sock.nil? || sock.empty?
64
+ raise Netsoul::SocketError, 'Timeout or raise on write socket'.freeze if sock.nil? || sock.empty?
65
65
  s = sock.first
66
66
  if s
67
67
  s.puts str
68
68
  s.flush
69
69
  end
70
70
  log :info, "[send] #{str.chomp}"
71
+ rescue Errno::EPIPE
72
+ disconnect
73
+ connect
71
74
  end
72
75
 
73
76
  def get
74
77
  sock, = IO.select([@socket], nil, nil, SOCKET_READ_TIMEOUT)
75
- fail Netsoul::SocketError, 'Timeout or fail on read socket'.freeze if sock.nil? || sock.empty?
78
+ raise Netsoul::SocketError, 'Timeout or raise on read socket'.freeze if sock.nil? || sock.empty?
76
79
  res = sock.first.gets
77
80
  if res
78
81
  log :info, "[get ] #{res.chomp}"
@@ -80,6 +83,9 @@ module Netsoul
80
83
  else
81
84
  'nothing'.freeze # Send some string and permit IO.select to thrown exception if something goes wrong.
82
85
  end
86
+ rescue Errno::EPIPE
87
+ disconnect
88
+ connect
83
89
  end
84
90
 
85
91
  def close
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Netsoul
4
4
  class Config
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'logger'
4
4
 
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'base64'
4
4
  require 'digest/md5'
@@ -8,7 +8,7 @@ module Netsoul
8
8
  class Message
9
9
  class << self
10
10
  def _standard_auth_string(c)
11
- str = c.user_connection_info[:md5_hash]
11
+ str = c.user_connection_info[:md5_hash].dup
12
12
  str << "-#{c.user_connection_info[:client_ip]}"
13
13
  str << "/#{c.user_connection_info[:client_port]}#{c.socks_password}"
14
14
  Digest::MD5.hexdigest(str)
@@ -39,7 +39,7 @@ module Netsoul
39
39
 
40
40
  def kerberos_auth(config)
41
41
  unless _kerberos_get.build_token(config.login, config.unix_password)
42
- fail Netsoul::Error, 'Impossible to retrieve the kerberos token.'.freeze
42
+ raise Netsoul::Error, 'Impossible to retrieve the kerberos token.'.freeze
43
43
  end
44
44
  _kerberos_auth_klog(config)
45
45
  end
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Netsoul
4
- VERSION = '2.3.1'.freeze
4
+ VERSION = '2.3.2'.freeze
5
5
  end
data/netsoul.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
18
  # delete this section to allow pushing this gem to any host.
19
- fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
19
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
20
20
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
21
 
22
22
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsoul
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Kakesa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-10 00:00:00.000000000 Z
11
+ date: 2016-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler