netsoul 1.9.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/netsoul-ruby +7 -6
- data/lib/netsoul/client.rb +18 -18
- data/lib/netsoul/config.rb +1 -1
- data/lib/netsoul/message.rb +50 -2
- data/lib/netsoul/version.rb +1 -1
- data/lib/netsoul.rb +0 -1
- metadata +1 -2
- data/lib/netsoul/location.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3867b9a41505375037c2a9dab38d767b1ff3fec
|
4
|
+
data.tar.gz: accfa0351a8f3702a6b528d09c5871ea5cd3e8bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9d49424ebfdb9417801d8307190b02f9c433d789863f9c5106471ee36df2d17a5c769a3ffe78d52de7d7f98a8eab390d875d446573a4540f4d36d133f5fad6c
|
7
|
+
data.tar.gz: f0f98ab4eede97c75ea6b44c95369a998b98397c90ed8b2c4cb2765a41e48168a189e4217e4b337ce39e7afb7eea36cca9fa0f09057774ee1bf35fa931359bb6
|
data/bin/netsoul-ruby
CHANGED
@@ -22,7 +22,7 @@ OptionParser.new do |opts|
|
|
22
22
|
options[:user_opts] = YAML.load_file(file) if File.file?(file)
|
23
23
|
end
|
24
24
|
|
25
|
-
opts.on('-h', '--help', 'Display this screen') do
|
25
|
+
opts.on('-h'.freeze, '--help', 'Display this screen'.freeze) do
|
26
26
|
puts opts
|
27
27
|
exit 42
|
28
28
|
end
|
@@ -30,7 +30,7 @@ end.parse!
|
|
30
30
|
|
31
31
|
if options.empty? || options[:user_opts].size == 0
|
32
32
|
unless ENV.to_a.count { |k, _v| %w(NETSOUL_LOGIN NETSOUL_SOCKS_PASSWORD NETSOUL_LOGIN NETSOUL_UNIX_PASSWORD NETSOUL_AUTH_METHOD).include?(k) } >= 2
|
33
|
-
puts '[ERROR] You have to specify a configuration file or environment variables'
|
33
|
+
puts '[ERROR] You have to specify a configuration file or environment variables'.freeze
|
34
34
|
exit 42
|
35
35
|
end
|
36
36
|
end
|
@@ -45,14 +45,14 @@ begin
|
|
45
45
|
retry_count = 10
|
46
46
|
retry_wait_time = 1.0
|
47
47
|
loop do
|
48
|
-
res = c.
|
49
|
-
c.
|
48
|
+
res = c.get
|
49
|
+
c.send res if res.to_s.match(/^ping.*/)
|
50
50
|
sleep 1
|
51
51
|
end
|
52
52
|
end
|
53
53
|
rescue Interrupt
|
54
54
|
begin c.disconnect; end
|
55
|
-
puts '!!! [SIGINT] !!!'
|
55
|
+
puts '!!! [SIGINT] !!!'.freeze
|
56
56
|
exit 42
|
57
57
|
rescue => e
|
58
58
|
puts "[ERROR]: #{e}"
|
@@ -61,7 +61,8 @@ rescue => e
|
|
61
61
|
if retry_count > 0
|
62
62
|
retry_count -= 1
|
63
63
|
retry_wait_time *= RETRY_WAIT_FACTOR
|
64
|
-
sleep(retry_wait_time)
|
64
|
+
sleep(retry_wait_time)
|
65
|
+
retry
|
65
66
|
end
|
66
67
|
exit 42
|
67
68
|
end
|
data/lib/netsoul/client.rb
CHANGED
@@ -15,31 +15,31 @@ module Netsoul
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def auth_ag
|
18
|
-
|
19
|
-
fail Netsoul::IdentificationError, 'Identification failed.'.freeze unless
|
18
|
+
send(Message.auth_ag)
|
19
|
+
fail Netsoul::IdentificationError, 'Identification failed.'.freeze unless get.split(' ')[1] == '002'.freeze
|
20
20
|
end
|
21
21
|
private :auth_ag
|
22
22
|
|
23
23
|
def auth_method
|
24
24
|
if @config.auth_method == :krb5
|
25
|
-
|
25
|
+
send(Message.kerberos_auth(@config))
|
26
26
|
else
|
27
|
-
|
27
|
+
send(Message.standard_auth(@config))
|
28
28
|
end
|
29
|
-
fail Netsoul::AuthenticationError, 'Authentication failed. See your config file or environment variables'.freeze unless
|
29
|
+
fail Netsoul::AuthenticationError, 'Authentication failed. See your config file or environment variables'.freeze unless get.split(' ')[1] == '002'
|
30
30
|
end
|
31
31
|
private :auth_method
|
32
32
|
|
33
33
|
def auth_status
|
34
|
-
|
35
|
-
|
34
|
+
send(Message.attach)
|
35
|
+
send(Message.user_state(@config.state, Time.now.to_i))
|
36
36
|
end
|
37
37
|
private :auth_status
|
38
38
|
|
39
39
|
def connect
|
40
|
-
@
|
41
|
-
fail Netsoul::SocketError, 'Could not open a socket. Connection is unavailable.'.freeze unless @
|
42
|
-
_cmd, _socket_num, md5_hash, client_ip, client_port, _server_timestamp =
|
40
|
+
@socket = TCPSocket.new(@config.server_host, @config.server_port)
|
41
|
+
fail Netsoul::SocketError, 'Could not open a socket. Connection is unavailable.'.freeze unless @socket
|
42
|
+
_cmd, _socket_num, md5_hash, client_ip, client_port, _server_timestamp = get.split
|
43
43
|
|
44
44
|
@config.build_user_connection_info md5_hash: md5_hash, client_ip: client_ip, client_port: client_port
|
45
45
|
|
@@ -51,29 +51,29 @@ module Netsoul
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def disconnect
|
54
|
-
|
54
|
+
send(Message.ns_exit)
|
55
55
|
ensure
|
56
|
-
|
56
|
+
close
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
60
|
-
_, sock = IO.select(nil, [@
|
59
|
+
def send(str)
|
60
|
+
_, sock = IO.select(nil, [@socket], nil, SOCKET_WRITE_TIMEOUT)
|
61
61
|
fail Netsoul::SocketError, 'Timeout or fail on write socket' if sock.nil? || sock.empty?
|
62
62
|
sock.first.puts str
|
63
63
|
log :info, "[send] #{str.chomp}"
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
67
|
-
sock, = IO.select([@
|
66
|
+
def get
|
67
|
+
sock, = IO.select([@socket], nil, nil, SOCKET_READ_TIMEOUT)
|
68
68
|
fail Netsoul::SocketError, 'Timeout or fail on read socket' if sock.nil? || sock.empty?
|
69
69
|
res = sock.first.gets
|
70
70
|
log :info, "[get ] #{res.chomp}" if res
|
71
71
|
res || ''
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
74
|
+
def close
|
75
75
|
@started = false
|
76
|
-
@
|
76
|
+
@socket.close
|
77
77
|
rescue
|
78
78
|
nil
|
79
79
|
end
|
data/lib/netsoul/config.rb
CHANGED
@@ -43,7 +43,7 @@ module Netsoul
|
|
43
43
|
@user_group = ENV['NETSOUL_USER_GROUP'] || opts.fetch(:user_group, 'ETNA_2008'.freeze)
|
44
44
|
@user_connection_info = {}
|
45
45
|
|
46
|
-
@client_name = ENV['NETSOUL_CLIENT_NAME'] || opts.fetch(:client_name,
|
46
|
+
@client_name = ENV['NETSOUL_CLIENT_NAME'] || opts.fetch(:client_name, "(Netsoul-Ruby v#{Netsoul::VERSION}) -> { Christian Kakesa, since 2009}".freeze)
|
47
47
|
end
|
48
48
|
|
49
49
|
def build_user_connection_info(opts = {})
|
data/lib/netsoul/message.rb
CHANGED
@@ -2,8 +2,6 @@ require 'base64'
|
|
2
2
|
require 'digest/md5'
|
3
3
|
require 'uri'
|
4
4
|
|
5
|
-
require_relative 'location'
|
6
|
-
|
7
5
|
module Netsoul
|
8
6
|
class Message
|
9
7
|
class << self
|
@@ -119,4 +117,54 @@ module Netsoul
|
|
119
117
|
end
|
120
118
|
end
|
121
119
|
end
|
120
|
+
|
121
|
+
class Location
|
122
|
+
class << self
|
123
|
+
def get(ip)
|
124
|
+
locations.each do |key, val|
|
125
|
+
return "#{key}".freeze if ip.match(/^#{val}/)
|
126
|
+
end
|
127
|
+
'ext'.freeze
|
128
|
+
end
|
129
|
+
|
130
|
+
# rubocop:disable all
|
131
|
+
def locations
|
132
|
+
@locations ||= {
|
133
|
+
:'lab-cisco-mid-sr' => '10.251.'.freeze,
|
134
|
+
etna: '10.245.'.freeze,
|
135
|
+
lse: '10.227.42.'.freeze,
|
136
|
+
:'sda-1' => '10.227.4.'.freeze,
|
137
|
+
lab: '10.227.'.freeze,
|
138
|
+
:'lab-tcom' => '10.226.7.'.freeze,
|
139
|
+
:'lab-acu' => '10.226.6.'.freeze,
|
140
|
+
:'lab-console' => '10.226.5.'.freeze,
|
141
|
+
:'lab-mspe' => '10.226.'.freeze,
|
142
|
+
epitanim: '10.225.19.'.freeze,
|
143
|
+
epidemic: '10.225.18.'.freeze,
|
144
|
+
:'sda-2' => '10.225.10.'.freeze,
|
145
|
+
cycom: '10.225.8.'.freeze,
|
146
|
+
epx: '10.225.7.'.freeze,
|
147
|
+
prologin: '10.225.6.'.freeze,
|
148
|
+
nomad: '10.225.2.'.freeze,
|
149
|
+
assos: '10.225.'.freeze,
|
150
|
+
sda: '10.224.14.'.freeze,
|
151
|
+
www: '10.223.106.'.freeze,
|
152
|
+
episport: '10.223.104.'.freeze,
|
153
|
+
epicom: '10.223.103.'.freeze,
|
154
|
+
:'bde-epita' => '10.223.100.'.freeze,
|
155
|
+
omatis: '10.223.42.'.freeze,
|
156
|
+
ipsa: '10.223.15.'.freeze,
|
157
|
+
lrde: '10.223.13.'.freeze,
|
158
|
+
cvi: '10.223.7.'.freeze,
|
159
|
+
epi: '10.223.1.'.freeze,
|
160
|
+
pasteur: '10.223.'.freeze,
|
161
|
+
bocal: '10.42.42.'.freeze,
|
162
|
+
sm: '10.42.'.freeze,
|
163
|
+
vpn: '10.10.'.freeze,
|
164
|
+
adm: '10.1.'.freeze,
|
165
|
+
epita: '10.'.freeze
|
166
|
+
}
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
122
170
|
end
|
data/lib/netsoul/version.rb
CHANGED
data/lib/netsoul.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netsoul
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Kakesa
|
@@ -156,7 +156,6 @@ files:
|
|
156
156
|
- lib/netsoul/client.rb
|
157
157
|
- lib/netsoul/config.rb
|
158
158
|
- lib/netsoul/errors.rb
|
159
|
-
- lib/netsoul/location.rb
|
160
159
|
- lib/netsoul/logging.rb
|
161
160
|
- lib/netsoul/message.rb
|
162
161
|
- lib/netsoul/version.rb
|
data/lib/netsoul/location.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
module Netsoul
|
2
|
-
class Location
|
3
|
-
class << self
|
4
|
-
def get(ip)
|
5
|
-
locations.each do |key, val|
|
6
|
-
return "#{key}".freeze if ip.match(/^#{val}/)
|
7
|
-
end
|
8
|
-
'ext'.freeze
|
9
|
-
end
|
10
|
-
|
11
|
-
# rubocop:disable all
|
12
|
-
def locations
|
13
|
-
{
|
14
|
-
:'lab-cisco-mid-sr' => '10.251.'.freeze,
|
15
|
-
etna: '10.245.'.freeze,
|
16
|
-
lse: '10.227.42.'.freeze,
|
17
|
-
:'sda-1' => '10.227.4.'.freeze,
|
18
|
-
lab: '10.227.'.freeze,
|
19
|
-
:'lab-tcom' => '10.226.7.'.freeze,
|
20
|
-
:'lab-acu' => '10.226.6.'.freeze,
|
21
|
-
:'lab-console' => '10.226.5.'.freeze,
|
22
|
-
:'lab-mspe' => '10.226.'.freeze,
|
23
|
-
epitanim: '10.225.19.'.freeze,
|
24
|
-
epidemic: '10.225.18.'.freeze,
|
25
|
-
:'sda-2' => '10.225.10.'.freeze,
|
26
|
-
cycom: '10.225.8.'.freeze,
|
27
|
-
epx: '10.225.7.'.freeze,
|
28
|
-
prologin: '10.225.6.'.freeze,
|
29
|
-
nomad: '10.225.2.'.freeze,
|
30
|
-
assos: '10.225.'.freeze,
|
31
|
-
sda: '10.224.14.'.freeze,
|
32
|
-
www: '10.223.106.'.freeze,
|
33
|
-
episport: '10.223.104.'.freeze,
|
34
|
-
epicom: '10.223.103.'.freeze,
|
35
|
-
:'bde-epita' => '10.223.100.'.freeze,
|
36
|
-
omatis: '10.223.42.'.freeze,
|
37
|
-
ipsa: '10.223.15.'.freeze,
|
38
|
-
lrde: '10.223.13.'.freeze,
|
39
|
-
cvi: '10.223.7.'.freeze,
|
40
|
-
epi: '10.223.1.'.freeze,
|
41
|
-
pasteur: '10.223.'.freeze,
|
42
|
-
bocal: '10.42.42.'.freeze,
|
43
|
-
sm: '10.42.'.freeze,
|
44
|
-
vpn: '10.10.'.freeze,
|
45
|
-
adm: '10.1.'.freeze,
|
46
|
-
epita: '10.'.freeze
|
47
|
-
}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|