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 +4 -4
- data/lib/netsoul/client.rb +12 -6
- data/lib/netsoul/config.rb +1 -1
- data/lib/netsoul/logging.rb +1 -1
- data/lib/netsoul/message.rb +3 -3
- data/lib/netsoul/version.rb +2 -2
- data/netsoul.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9f097f6171effa2f3bd38fbecea89406384c946
|
4
|
+
data.tar.gz: 3864a93c873ac2a74e3fe944f50e2b95163a9888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39920b1fe6209190bb9d2c0ac72bedbc1e567f25a1e37e9a0d05851add0ecfe3ceadb5253cf691daaa7552f4459d3b05a386ca0da6e3808e5692fc79128100d9
|
7
|
+
data.tar.gz: ee510ac2bec7789ab66b59b8352cdafd12ec7e00bb1a279d39bbcbd5d2121cf3bb7b3e8d02cfebe28e49bbaae3d1177fd67ba4f7516f199adcbd3d09832a27e7
|
data/lib/netsoul/client.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/netsoul/config.rb
CHANGED
data/lib/netsoul/logging.rb
CHANGED
data/lib/netsoul/message.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
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
|
-
|
42
|
+
raise Netsoul::Error, 'Impossible to retrieve the kerberos token.'.freeze
|
43
43
|
end
|
44
44
|
_kerberos_auth_klog(config)
|
45
45
|
end
|
data/lib/netsoul/version.rb
CHANGED
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
|
-
|
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.
|
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-
|
11
|
+
date: 2016-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|