em-simple_telnet 0.0.15 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/em-simple_telnet.rb +13 -14
- 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: a3a87aad1b79cbd0d9d345286f057f9645b762ed
|
4
|
+
data.tar.gz: 1afc5e5953809b6ba526672a07ad778b600419dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f09ceba50d39a511a8a800b9a143bc16b42b504a4f327ad4a5aa744e5d91587df422dad994f579f60111be7db8ba7d4146f99affe6f25d1f95be5d28556e1a
|
7
|
+
data.tar.gz: 45480727c86fc53583f24f96112b6f7d3cf02c79552ba5abdf9f8528c317d29c7f59a150dc287db4925d8d85e5b83a2d93efdfa68b73cc45724c5046bcc21dd9
|
data/lib/em-simple_telnet.rb
CHANGED
@@ -521,7 +521,7 @@ class Protocols::SimpleTelnet < Connection
|
|
521
521
|
# #log_output. Then calls #process_payload.
|
522
522
|
#
|
523
523
|
def receive_data data
|
524
|
-
@recently_received_data << data if
|
524
|
+
@recently_received_data << data if log_recently_received_data?
|
525
525
|
if @telnet_options[:telnet_mode]
|
526
526
|
c = @input_rest + data
|
527
527
|
se_pos = c.rindex(/#{IAC}#{SE}/no) || 0
|
@@ -673,7 +673,8 @@ class Protocols::SimpleTelnet < Connection
|
|
673
673
|
#
|
674
674
|
def waitfor prompt=nil, opts={}
|
675
675
|
if closed?
|
676
|
-
|
676
|
+
raise Errno::ENOTCONN,
|
677
|
+
"Can't wait for anything when connection is already closed!"
|
677
678
|
end
|
678
679
|
options_were = @telnet_options
|
679
680
|
timeout_was = self.timeout if opts.key?(:timeout)
|
@@ -756,9 +757,8 @@ class Protocols::SimpleTelnet < Connection
|
|
756
757
|
raise Errno::ENOTCONN,
|
757
758
|
"Can't send data: Connection is already closed." if closed?
|
758
759
|
@last_sent_data = Time.now
|
759
|
-
log_recently_received_data
|
760
|
+
log_recently_received_data
|
760
761
|
logger.debug "#{node}: Sending #{s.inspect}"
|
761
|
-
log_output(s)
|
762
762
|
super
|
763
763
|
end
|
764
764
|
|
@@ -933,7 +933,7 @@ class Protocols::SimpleTelnet < Connection
|
|
933
933
|
def unbind(reason)
|
934
934
|
prev_conn_state = @connection_state
|
935
935
|
self.connection_state = :closed
|
936
|
-
logger.debug "#{node}:
|
936
|
+
logger.debug "#{node}: Unbind reason: " + reason.inspect
|
937
937
|
@@_telnet_connection_count -= 1
|
938
938
|
close_logs
|
939
939
|
|
@@ -999,23 +999,22 @@ class Protocols::SimpleTelnet < Connection
|
|
999
999
|
|
1000
1000
|
private
|
1001
1001
|
|
1002
|
-
# Prints recently received data (@
|
1003
|
-
#
|
1002
|
+
# Prints recently received data (@recently_received_data) if
|
1003
|
+
# {#log_recently_received_data?} says so and there is recently received data
|
1004
|
+
# in the buffer. Clears the buffer afterwards.
|
1004
1005
|
#
|
1005
1006
|
# The goal is to log data in a more readable way, by periodically log what
|
1006
1007
|
# has recently been received, as opposed to each single character in case of
|
1007
1008
|
# a slowly answering telnet server.
|
1008
1009
|
def log_recently_received_data
|
1009
|
-
return if @recently_received_data.empty?
|
1010
|
+
return if @recently_received_data.empty? || !log_recently_received_data?
|
1010
1011
|
logger.debug "#{node}: Received: #{@recently_received_data.inspect}"
|
1011
|
-
@recently_received_data
|
1012
|
+
@recently_received_data.clear
|
1012
1013
|
end
|
1013
1014
|
|
1014
|
-
#
|
1015
|
-
|
1016
|
-
|
1017
|
-
def should_log_recently_received_data?
|
1018
|
-
true & logger.debug?
|
1015
|
+
# @return [Boolean] if recently received data should be logged or not
|
1016
|
+
def log_recently_received_data?
|
1017
|
+
logger.debug?
|
1019
1018
|
end
|
1020
1019
|
|
1021
1020
|
# Sets the @connection_state to _new_state_. Raises if current (old) state is
|