Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Remove sensitive information shown in console.
Browse files Browse the repository at this point in the history
  • Loading branch information
christiankakesa committed May 1, 2016
1 parent 0a2b9b0 commit 1c90e7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 10 additions & 4 deletions bin/netsoul-ruby
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,28 @@ end
retry_count = 10
retry_wait_time = 1.0
RETRY_WAIT_FACTOR = 2.0 # Each time retry is called in Exception block, current 'retry_wait_time' is increased with this factor

include Netsoul::Logging
begin
c = Netsoul::Client.new options[:user_opts]
c.connect
if c.started
log :info, '[connection:ok] successfully connected to the Netsoul server'
trap_interrupt c
retry_count = 10
retry_wait_time = 1.0
loop do
res = c.get
c.send res if res.to_s.match(/^ping.*/)
sleep 1
res != 'nothing'.freeze ? log(:info, "[get ] #{res}") : log(:warn, '[get ] (<was empty!!!>)'.freeze)
if res.to_s.match(/^ping.*/)
c.send res
log :info, "[send] #{res}"
end
end
end
rescue => e
puts "[ERROR]: #{e}"
puts "[RETRY_COUNT]: #{retry_count}"
log :error, "[EXCEPTION!!]: #{e}"
log :error, "[RETRY_COUNT]: #{retry_count}"
begin c.disconnect; end
if retry_count > 0
retry_count -= 1
Expand Down
4 changes: 0 additions & 4 deletions lib/netsoul/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

module Netsoul
class Client
include Logging
attr_reader :started
SOCKET_READ_TIMEOUT = 12 * 60
SOCKET_WRITE_TIMEOUT = 1 * 60
Expand Down Expand Up @@ -66,7 +65,6 @@ def send(str)
raise Netsoul::SocketError, 'Timeout or raise on write socket'.freeze unless s
s.puts str
s.flush
log :info, "[send] #{str}"
end

def get
Expand All @@ -75,10 +73,8 @@ def get
raise Netsoul::SocketError, 'Timeout or raise on read socket'.freeze unless s
res = s.gets.chomp
if !res.empty?
log :info, "[get ] #{res}"
res
else
log :warn, '[get ] (<was empty!!!>)'.freeze
'nothing'.freeze # Send some string and permit IO.select to thrown exception if something goes wrong.
end
end
Expand Down

0 comments on commit 1c90e7c

Please sign in to comment.