netsoul 2.3.8 → 2.4.1
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 +10 -4
- data/lib/netsoul/client.rb +11 -14
- data/lib/netsoul/message.rb +4 -4
- data/lib/netsoul/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce61d62c759a9b3ac31c5d52983338bbd65b0af2
|
4
|
+
data.tar.gz: 2e1c9c803753c4f67b4e96275c9dc4b61d318e7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aca72b67b7f9ebecb39a4ab49eca5542609559b24e92afbbefa064b9cda12f6daa493f8f31cc308fe0d9716444fff267270dad1a154e32b36a2ce4ca93733193
|
7
|
+
data.tar.gz: 16e50ef0bd6948f831c5c5e0472dda9e11aeba8d9816d38d390bd536d275e3231f5518551a3a55bd58379301b92a8a33d5589289d67d0bd459ab85b8bae29c01
|
data/bin/netsoul-ruby
CHANGED
@@ -47,22 +47,28 @@ end
|
|
47
47
|
retry_count = 10
|
48
48
|
retry_wait_time = 1.0
|
49
49
|
RETRY_WAIT_FACTOR = 2.0 # Each time retry is called in Exception block, current 'retry_wait_time' is increased with this factor
|
50
|
+
|
51
|
+
include Netsoul::Logging
|
50
52
|
begin
|
51
53
|
c = Netsoul::Client.new options[:user_opts]
|
52
54
|
c.connect
|
53
55
|
if c.started
|
56
|
+
log :info, '[connection:ok] successfully connected to the Netsoul server'
|
54
57
|
trap_interrupt c
|
55
58
|
retry_count = 10
|
56
59
|
retry_wait_time = 1.0
|
57
60
|
loop do
|
58
61
|
res = c.get
|
59
|
-
|
60
|
-
|
62
|
+
res != 'nothing'.freeze ? log(:info, "[get ] #{res}") : log(:warn, '[get ] (<was empty!!!>)'.freeze)
|
63
|
+
if res.to_s.match(/^ping.*/)
|
64
|
+
c.send res
|
65
|
+
log :info, "[send] #{res}"
|
66
|
+
end
|
61
67
|
end
|
62
68
|
end
|
63
69
|
rescue => e
|
64
|
-
|
65
|
-
|
70
|
+
log :error, "[EXCEPTION!!]: #{e}"
|
71
|
+
log :error, "[RETRY_COUNT]: #{retry_count}"
|
66
72
|
begin c.disconnect; end
|
67
73
|
if retry_count > 0
|
68
74
|
retry_count -= 1
|
data/lib/netsoul/client.rb
CHANGED
@@ -5,7 +5,6 @@ require 'socket'
|
|
5
5
|
|
6
6
|
module Netsoul
|
7
7
|
class Client
|
8
|
-
include Logging
|
9
8
|
attr_reader :started
|
10
9
|
SOCKET_READ_TIMEOUT = 12 * 60
|
11
10
|
SOCKET_WRITE_TIMEOUT = 1 * 60
|
@@ -55,37 +54,35 @@ module Netsoul
|
|
55
54
|
|
56
55
|
def disconnect
|
57
56
|
send(Message.ns_exit)
|
58
|
-
ensure
|
59
57
|
close
|
58
|
+
ensure
|
59
|
+
@started = false
|
60
60
|
end
|
61
61
|
|
62
62
|
def send(str)
|
63
63
|
_, sock = IO.select(nil, [@socket], nil, SOCKET_WRITE_TIMEOUT)
|
64
|
-
raise Netsoul::SocketError, 'Timeout or raise on write socket'.freeze if sock.nil? || sock.empty?
|
65
64
|
s = sock.first
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
log :info, "[send] #{str.chomp}"
|
65
|
+
raise Netsoul::SocketError, 'Timeout or raise on write socket'.freeze unless s
|
66
|
+
s.puts str
|
67
|
+
s.flush
|
71
68
|
end
|
72
69
|
|
73
70
|
def get
|
74
71
|
sock, = IO.select([@socket], nil, nil, SOCKET_READ_TIMEOUT)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
s = sock.first
|
73
|
+
raise Netsoul::SocketError, 'Timeout or raise on read socket'.freeze unless s
|
74
|
+
res = s.gets.chomp
|
75
|
+
if !res.empty?
|
79
76
|
res
|
80
77
|
else
|
81
78
|
'nothing'.freeze # Send some string and permit IO.select to thrown exception if something goes wrong.
|
82
79
|
end
|
83
80
|
end
|
84
81
|
|
82
|
+
private
|
83
|
+
|
85
84
|
def close
|
86
85
|
@socket.close if @socket
|
87
|
-
ensure
|
88
|
-
@started = false
|
89
86
|
end
|
90
87
|
end
|
91
88
|
end
|
data/lib/netsoul/message.rb
CHANGED
@@ -7,10 +7,10 @@ require 'uri'
|
|
7
7
|
module Netsoul
|
8
8
|
class Message
|
9
9
|
class << self
|
10
|
-
def _standard_auth_string(
|
11
|
-
str =
|
12
|
-
str << "-#{
|
13
|
-
str << "/#{
|
10
|
+
def _standard_auth_string(config)
|
11
|
+
str = config.user_connection_info[:md5_hash].dup
|
12
|
+
str << "-#{config.user_connection_info[:client_ip]}"
|
13
|
+
str << "/#{config.user_connection_info[:client_port]}#{config.socks_password}"
|
14
14
|
Digest::MD5.hexdigest(str)
|
15
15
|
end
|
16
16
|
|
data/lib/netsoul/version.rb
CHANGED