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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4da6956f4acf8e95a6182d863b70b77303a34336
4
- data.tar.gz: b9ddab1e1a4671f079b900d37ad569eee619cc23
3
+ metadata.gz: ce61d62c759a9b3ac31c5d52983338bbd65b0af2
4
+ data.tar.gz: 2e1c9c803753c4f67b4e96275c9dc4b61d318e7f
5
5
  SHA512:
6
- metadata.gz: 20de678da3bae0ea2c8d25ab331d92196d5be88051d0c3a22873e323c02ad9dfc7014dbbffbf63fd482cbe3fa77ccba6b9791ff939fe682f124b236b6ff0e531
7
- data.tar.gz: d20a995bc0be5a1e3fa3f7c432328949acd806ae584bffe91e7d5895175e8a07f51db4d4b51749882dba71121a7e06be93b6d37c55a653a71723e5988a131211
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
- c.send res if res.to_s.match(/^ping.*/)
60
- sleep 1
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
- puts "[ERROR]: #{e}"
65
- puts "[RETRY_COUNT]: #{retry_count}"
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
@@ -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
- if s
67
- s.puts str
68
- s.flush
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
- raise Netsoul::SocketError, 'Timeout or raise on read socket'.freeze if sock.nil? || sock.empty?
76
- res = sock.first.gets
77
- if res
78
- log :info, "[get ] #{res.chomp}"
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
@@ -7,10 +7,10 @@ require 'uri'
7
7
  module Netsoul
8
8
  class Message
9
9
  class << self
10
- def _standard_auth_string(c)
11
- str = c.user_connection_info[:md5_hash].dup
12
- str << "-#{c.user_connection_info[:client_ip]}"
13
- str << "/#{c.user_connection_info[:client_port]}#{c.socks_password}"
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Netsoul
4
- VERSION = '2.3.8'.freeze
4
+ VERSION = '2.4.1'.freeze
5
5
  end
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: 2.3.8
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Kakesa