hrr_rb_ssh 0.4.0.pre1 → 0.4.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -8
  3. data/demo/client.rb +1 -3
  4. data/demo/echo_server.rb +1 -3
  5. data/demo/more_flexible_auth.rb +1 -3
  6. data/demo/multi_step_auth.rb +1 -3
  7. data/demo/server.rb +1 -3
  8. data/demo/subsystem_echo_server.rb +1 -3
  9. data/hrr_rb_ssh.gemspec +1 -1
  10. data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2.rb +12 -9
  11. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss.rb +10 -7
  12. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa.rb +9 -6
  13. data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/context.rb +9 -8
  14. data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb +6 -5
  15. data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_response.rb +5 -2
  16. data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb +12 -10
  17. data/lib/hrr_rb_ssh/authentication/method/none/context.rb +7 -6
  18. data/lib/hrr_rb_ssh/authentication/method/none.rb +10 -8
  19. data/lib/hrr_rb_ssh/authentication/method/password/context.rb +7 -6
  20. data/lib/hrr_rb_ssh/authentication/method/password.rb +10 -8
  21. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb +13 -11
  22. data/lib/hrr_rb_ssh/authentication/method/publickey/context.rb +5 -2
  23. data/lib/hrr_rb_ssh/authentication/method/publickey.rb +16 -14
  24. data/lib/hrr_rb_ssh/authentication.rb +28 -27
  25. data/lib/hrr_rb_ssh/client.rb +58 -56
  26. data/lib/hrr_rb_ssh/codable.rb +20 -10
  27. data/lib/hrr_rb_ssh/connection/channel/channel_type/direct_tcpip.rb +20 -18
  28. data/lib/hrr_rb_ssh/connection/channel/channel_type/forwarded_tcpip.rb +20 -18
  29. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/proc_chain/chain_context.rb +0 -3
  30. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/proc_chain.rb +0 -2
  31. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env/context.rb +5 -4
  32. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env.rb +2 -5
  33. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec/context.rb +5 -4
  34. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec.rb +2 -5
  35. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req/context.rb +5 -4
  36. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req.rb +2 -5
  37. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell/context.rb +5 -4
  38. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell.rb +2 -5
  39. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem/context.rb +5 -4
  40. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem.rb +2 -5
  41. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change/context.rb +5 -4
  42. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change.rb +2 -5
  43. data/lib/hrr_rb_ssh/connection/channel/channel_type/session.rb +14 -12
  44. data/lib/hrr_rb_ssh/connection/channel.rb +73 -71
  45. data/lib/hrr_rb_ssh/connection/global_request_handler.rb +14 -12
  46. data/lib/hrr_rb_ssh/connection/request_handler/reference_env_request_handler.rb +0 -2
  47. data/lib/hrr_rb_ssh/connection/request_handler/reference_exec_request_handler.rb +4 -6
  48. data/lib/hrr_rb_ssh/connection/request_handler/reference_pty_req_request_handler.rb +10 -12
  49. data/lib/hrr_rb_ssh/connection/request_handler/reference_shell_request_handler.rb +4 -6
  50. data/lib/hrr_rb_ssh/connection/request_handler/reference_window_change_request_handler.rb +0 -2
  51. data/lib/hrr_rb_ssh/connection/request_handler.rb +1 -3
  52. data/lib/hrr_rb_ssh/connection.rb +53 -53
  53. data/lib/hrr_rb_ssh/loggable.rb +42 -0
  54. data/lib/hrr_rb_ssh/server.rb +11 -9
  55. data/lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb +5 -3
  56. data/lib/hrr_rb_ssh/transport/compression_algorithm/unfunctionable.rb +5 -3
  57. data/lib/hrr_rb_ssh/transport/encryption_algorithm/functionable.rb +5 -3
  58. data/lib/hrr_rb_ssh/transport/encryption_algorithm/unfunctionable.rb +5 -3
  59. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +9 -8
  60. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange.rb +13 -12
  61. data/lib/hrr_rb_ssh/transport/kex_algorithm/elliptic_curve_diffie_hellman.rb +9 -8
  62. data/lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb +5 -3
  63. data/lib/hrr_rb_ssh/transport/mac_algorithm/unfunctionable.rb +5 -3
  64. data/lib/hrr_rb_ssh/transport/receiver.rb +8 -7
  65. data/lib/hrr_rb_ssh/transport/sender.rb +5 -3
  66. data/lib/hrr_rb_ssh/transport/sequence_number.rb +0 -4
  67. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/functionable.rb +5 -3
  68. data/lib/hrr_rb_ssh/transport.rb +41 -40
  69. data/lib/hrr_rb_ssh/version.rb +1 -1
  70. data/lib/hrr_rb_ssh.rb +0 -1
  71. metadata +6 -6
  72. data/lib/hrr_rb_ssh/logger.rb +0 -56
@@ -1,12 +1,16 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  module Codable
8
- def logger
9
- @logger ||= Logger.new self.name
8
+ class LoggableClass
9
+ include Loggable
10
+
11
+ def initialize logger
12
+ self.logger = logger
13
+ end
10
14
  end
11
15
 
12
16
  def common_definition
@@ -22,15 +26,18 @@ module HrrRbSsh
22
26
  }
23
27
  end
24
28
 
25
- def encode message, complementary_message={}
26
- logger.debug { 'encoding message: ' + message.inspect }
29
+ def encode message, complementary_message={}, logger: nil
30
+ loggable_instalce = LoggableClass.new(logger)
31
+ loggable_instalce.log_key = self.to_s
32
+
33
+ loggable_instalce.log_debug { 'encoding message: ' + message.inspect }
27
34
  definition = common_definition + conditional_definition(message.merge complementary_message)
28
35
  definition.map{ |data_type, field_name|
29
36
  begin
30
37
  field_value = if message[field_name].instance_of? ::Proc then message[field_name].call else message[field_name] end
31
- data_type.encode( field_value )
38
+ data_type.encode field_value
32
39
  rescue => e
33
- logger.debug { "'field_name', 'field_value': #{field_name.inspect}, #{field_value.inspect}" }
40
+ loggable_instalce.log_debug { "'field_name', 'field_value': #{field_name.inspect}, #{field_value.inspect}" }
34
41
  raise e
35
42
  end
36
43
  }.join
@@ -49,20 +56,23 @@ module HrrRbSsh
49
56
  decoded_message = definition.map{ |data_type, field_name|
50
57
  [
51
58
  field_name,
52
- data_type.decode( payload_io )
59
+ data_type.decode(payload_io)
53
60
  ]
54
61
  }
55
62
  decoded_message + decode_recursively(payload_io, decoded_message)
56
63
  end
57
64
  end
58
65
 
59
- def decode payload, complementary_message={}
66
+ def decode payload, complementary_message={}, logger: nil
67
+ loggable_instalce = LoggableClass.new(logger)
68
+ loggable_instalce.log_key = self.to_s
69
+
60
70
  payload_io = StringIO.new payload
61
71
  decoded_message = decode_recursively(payload_io).inject(Hash.new){ |h, (k, v)| h.update({k => v}) }
62
72
  if complementary_message.any?
63
73
  decoded_message.merge! decode_recursively(payload_io, complementary_message.to_a).inject(Hash.new){ |h, (k, v)| h.update({k => v}) }
64
74
  end
65
- logger.debug { 'decoded message: ' + decoded_message.inspect }
75
+ loggable_instalce.log_debug { 'decoded message: ' + decoded_message.inspect }
66
76
  decoded_message
67
77
  end
68
78
  end
@@ -1,17 +1,19 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Connection
8
8
  class Channel
9
9
  class ChannelType
10
10
  class DirectTcpip < ChannelType
11
+ include Loggable
12
+
11
13
  NAME = 'direct-tcpip'
12
14
 
13
- def initialize connection, channel, message, socket=nil
14
- @logger = Logger.new self.class.name
15
+ def initialize connection, channel, message, socket=nil, logger: nil
16
+ self.logger = logger
15
17
  @connection = connection
16
18
  @channel = channel
17
19
  @host_to_connect = message[:'host to connect']
@@ -29,16 +31,16 @@ module HrrRbSsh
29
31
  def close
30
32
  begin
31
33
  if @sender_thread_finished && @receiver_thread_finished
32
- @logger.info { "closing direct-tcpip" }
34
+ log_info { "closing direct-tcpip" }
33
35
  @socket.close
34
- @logger.info { "closing channel IOs" }
36
+ log_info { "closing channel IOs" }
35
37
  @channel.io.each{ |io| io.close rescue nil }
36
- @logger.info { "channel IOs closed" }
38
+ log_info { "channel IOs closed" }
37
39
  @channel.close from=:channel_type_instance
38
- @logger.info { "direct-tcpip closed" }
40
+ log_info { "direct-tcpip closed" }
39
41
  end
40
42
  rescue => e
41
- @logger.error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
43
+ log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
42
44
  end
43
45
  end
44
46
 
@@ -49,24 +51,24 @@ module HrrRbSsh
49
51
  begin
50
52
  @channel.io[1].write s.readpartial(10240)
51
53
  rescue EOFError
52
- @logger.info { "socket is EOF" }
54
+ log_info { "socket is EOF" }
53
55
  @channel.io[1].close rescue nil
54
56
  break
55
57
  rescue IOError
56
- @logger.info { "socket is closed" }
58
+ log_info { "socket is closed" }
57
59
  @channel.io[1].close rescue nil
58
60
  break
59
61
  rescue => e
60
- @logger.error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
62
+ log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
61
63
  @channel.io[1].close rescue nil
62
64
  break
63
65
  end
64
66
  end
65
- @logger.info { "finishing sender thread" }
67
+ log_info { "finishing sender thread" }
66
68
  @sender_thread_finished = true
67
69
  close
68
70
  ensure
69
- @logger.info { "sender thread finished" }
71
+ log_info { "sender thread finished" }
70
72
  end
71
73
  }
72
74
  end
@@ -78,23 +80,23 @@ module HrrRbSsh
78
80
  begin
79
81
  s.write @channel.io[0].readpartial(10240)
80
82
  rescue EOFError
81
- @logger.info { "io is EOF" }
83
+ log_info { "io is EOF" }
82
84
  s.close_write
83
85
  break
84
86
  rescue IOError
85
- @logger.info { "socket is closed" }
87
+ log_info { "socket is closed" }
86
88
  break
87
89
  rescue => e
88
- @logger.error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
90
+ log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
89
91
  s.close_write
90
92
  break
91
93
  end
92
94
  end
93
- @logger.info { "finishing receiver thread" }
95
+ log_info { "finishing receiver thread" }
94
96
  @receiver_thread_finished = true
95
97
  close
96
98
  ensure
97
- @logger.info { "receiver thread finished" }
99
+ log_info { "receiver thread finished" }
98
100
  end
99
101
  }
100
102
  end
@@ -1,17 +1,19 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Connection
8
8
  class Channel
9
9
  class ChannelType
10
10
  class ForwardedTcpip < ChannelType
11
+ include Loggable
12
+
11
13
  NAME = 'forwarded-tcpip'
12
14
 
13
- def initialize connection, channel, message, socket
14
- @logger = Logger.new self.class.name
15
+ def initialize connection, channel, message, socket, logger: nil
16
+ self.logger = logger
15
17
  @connection = connection
16
18
  @channel = channel
17
19
  @socket = socket
@@ -25,16 +27,16 @@ module HrrRbSsh
25
27
  def close
26
28
  begin
27
29
  if @sender_thread_finished && @receiver_thread_finished
28
- @logger.info { "closing forwarded-tcpip" }
30
+ log_info { "closing forwarded-tcpip" }
29
31
  @socket.close
30
- @logger.info { "closing channel IOs" }
32
+ log_info { "closing channel IOs" }
31
33
  @channel.io.each{ |io| io.close rescue nil }
32
- @logger.info { "channel IOs closed" }
34
+ log_info { "channel IOs closed" }
33
35
  @channel.close from=:channel_type_instance
34
- @logger.info { "forwarded-tcpip closed" }
36
+ log_info { "forwarded-tcpip closed" }
35
37
  end
36
38
  rescue => e
37
- @logger.error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
39
+ log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
38
40
  end
39
41
  end
40
42
 
@@ -45,24 +47,24 @@ module HrrRbSsh
45
47
  begin
46
48
  @channel.io[1].write s.readpartial(10240)
47
49
  rescue EOFError
48
- @logger.info { "socket is EOF" }
50
+ log_info { "socket is EOF" }
49
51
  @channel.io[1].close rescue nil
50
52
  break
51
53
  rescue IOError
52
- @logger.info { "socket is closed" }
54
+ log_info { "socket is closed" }
53
55
  @channel.io[1].close rescue nil
54
56
  break
55
57
  rescue => e
56
- @logger.error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
58
+ log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
57
59
  @channel.io[1].close rescue nil
58
60
  break
59
61
  end
60
62
  end
61
- @logger.info { "finishing sender thread" }
63
+ log_info { "finishing sender thread" }
62
64
  @sender_thread_finished = true
63
65
  close
64
66
  ensure
65
- @logger.info { "sender thread finished" }
67
+ log_info { "sender thread finished" }
66
68
  end
67
69
  }
68
70
  end
@@ -74,23 +76,23 @@ module HrrRbSsh
74
76
  begin
75
77
  s.write @channel.io[0].readpartial(10240)
76
78
  rescue EOFError
77
- @logger.info { "io is EOF" }
79
+ log_info { "io is EOF" }
78
80
  s.close_write
79
81
  break
80
82
  rescue IOError
81
- @logger.info { "socket is closed" }
83
+ log_info { "socket is closed" }
82
84
  break
83
85
  rescue => e
84
- @logger.error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
86
+ log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
85
87
  s.close_write
86
88
  break
87
89
  end
88
90
  end
89
- @logger.info { "finishing receiver thread" }
91
+ log_info { "finishing receiver thread" }
90
92
  @receiver_thread_finished = true
91
93
  close
92
94
  ensure
93
- @logger.info { "receiver thread finished" }
95
+ log_info { "receiver thread finished" }
94
96
  end
95
97
  }
96
98
  end
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
-
6
4
  module HrrRbSsh
7
5
  class Connection
8
6
  class Channel
@@ -11,7 +9,6 @@ module HrrRbSsh
11
9
  class ProcChain
12
10
  class ChainContext
13
11
  def initialize proc_chain
14
- @logger = Logger.new self.class.name
15
12
  @proc_chain = proc_chain
16
13
  end
17
14
  def call_next *args
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
4
  require 'hrr_rb_ssh/connection/channel/channel_type/session/proc_chain/chain_context'
6
5
 
7
6
  module HrrRbSsh
@@ -11,7 +10,6 @@ module HrrRbSsh
11
10
  class Session
12
11
  class ProcChain
13
12
  def initialize
14
- @logger = Logger.new self.class.name
15
13
  @q = Queue.new
16
14
  end
17
15
  def connect next_proc
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Connection
@@ -11,8 +11,9 @@ module HrrRbSsh
11
11
  class RequestType
12
12
  class Env
13
13
  class Context
14
+ include Loggable
15
+
14
16
  attr_reader \
15
- :logger,
16
17
  :username,
17
18
  :io,
18
19
  :variables,
@@ -20,8 +21,8 @@ module HrrRbSsh
20
21
  :variable_name,
21
22
  :variable_value
22
23
 
23
- def initialize proc_chain, username, io, variables, message, session
24
- @logger = Logger.new self.class.name
24
+ def initialize proc_chain, username, io, variables, message, session, logger: nil
25
+ self.logger = logger
25
26
 
26
27
  @proc_chain = proc_chain
27
28
  @username = username
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
4
  require 'hrr_rb_ssh/connection/request_handler'
6
5
 
7
6
  module HrrRbSsh
@@ -13,10 +12,8 @@ module HrrRbSsh
13
12
  class Env < RequestType
14
13
  NAME = 'env'
15
14
 
16
- def self.run proc_chain, username, io, variables, message, options, session
17
- logger = Logger.new self.class.name
18
-
19
- context = Context.new proc_chain, username, io, variables, message, session
15
+ def self.run proc_chain, username, io, variables, message, options, session, logger: nil
16
+ context = Context.new proc_chain, username, io, variables, message, session, logger: logger
20
17
  handler = options.fetch('connection_channel_request_env', RequestHandler.new {})
21
18
  handler.run context
22
19
 
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Connection
@@ -11,16 +11,17 @@ module HrrRbSsh
11
11
  class RequestType
12
12
  class Exec
13
13
  class Context
14
+ include Loggable
15
+
14
16
  attr_reader \
15
- :logger,
16
17
  :username,
17
18
  :io,
18
19
  :variables,
19
20
  :vars,
20
21
  :command
21
22
 
22
- def initialize proc_chain, username, io, variables, message, session
23
- @logger = Logger.new self.class.name
23
+ def initialize proc_chain, username, io, variables, message, session, logger: nil
24
+ self.logger = logger
24
25
 
25
26
  @proc_chain = proc_chain
26
27
  @username = username
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
4
  require 'hrr_rb_ssh/connection/request_handler'
6
5
 
7
6
  module HrrRbSsh
@@ -13,10 +12,8 @@ module HrrRbSsh
13
12
  class Exec < RequestType
14
13
  NAME = 'exec'
15
14
 
16
- def self.run proc_chain, username, io, variables, message, options, session
17
- logger = Logger.new self.class.name
18
-
19
- context = Context.new proc_chain, username, io, variables, message, session
15
+ def self.run proc_chain, username, io, variables, message, options, session, logger: nil
16
+ context = Context.new proc_chain, username, io, variables, message, session, logger: logger
20
17
  handler = options.fetch('connection_channel_request_exec', RequestHandler.new {})
21
18
  handler.run context
22
19
 
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Connection
@@ -11,8 +11,9 @@ module HrrRbSsh
11
11
  class RequestType
12
12
  class PtyReq
13
13
  class Context
14
+ include Loggable
15
+
14
16
  attr_reader \
15
- :logger,
16
17
  :username,
17
18
  :io,
18
19
  :variables,
@@ -24,8 +25,8 @@ module HrrRbSsh
24
25
  :terminal_height_pixels,
25
26
  :encoded_terminal_modes
26
27
 
27
- def initialize proc_chain, username, io, variables, message, session
28
- @logger = Logger.new self.class.name
28
+ def initialize proc_chain, username, io, variables, message, session, logger: nil
29
+ self.logger = logger
29
30
 
30
31
  @proc_chain = proc_chain
31
32
  @username = username
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
4
  require 'hrr_rb_ssh/connection/request_handler'
6
5
 
7
6
  module HrrRbSsh
@@ -13,10 +12,8 @@ module HrrRbSsh
13
12
  class PtyReq < RequestType
14
13
  NAME = 'pty-req'
15
14
 
16
- def self.run proc_chain, username, io, variables, message, options, session
17
- logger = Logger.new self.class.name
18
-
19
- context = Context.new proc_chain, username, io, variables, message, session
15
+ def self.run proc_chain, username, io, variables, message, options, session, logger: nil
16
+ context = Context.new proc_chain, username, io, variables, message, session, logger: logger
20
17
  handler = options.fetch('connection_channel_request_pty_req', RequestHandler.new {})
21
18
  handler.run context
22
19
 
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Connection
@@ -11,15 +11,16 @@ module HrrRbSsh
11
11
  class RequestType
12
12
  class Shell
13
13
  class Context
14
+ include Loggable
15
+
14
16
  attr_reader \
15
- :logger,
16
17
  :username,
17
18
  :io,
18
19
  :variables,
19
20
  :vars
20
21
 
21
- def initialize proc_chain, username, io, variables, message, session
22
- @logger = Logger.new self.class.name
22
+ def initialize proc_chain, username, io, variables, message, session, logger: nil
23
+ self.logger = logger
23
24
 
24
25
  @proc_chain = proc_chain
25
26
  @username = username
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
4
  require 'hrr_rb_ssh/connection/request_handler'
6
5
 
7
6
  module HrrRbSsh
@@ -13,10 +12,8 @@ module HrrRbSsh
13
12
  class Shell < RequestType
14
13
  NAME = 'shell'
15
14
 
16
- def self.run proc_chain, username, io, variables, message, options, session
17
- logger = Logger.new self.class.name
18
-
19
- context = Context.new proc_chain, username, io, variables, message, session
15
+ def self.run proc_chain, username, io, variables, message, options, session, logger: nil
16
+ context = Context.new proc_chain, username, io, variables, message, session, logger: logger
20
17
  handler = options.fetch('connection_channel_request_shell', RequestHandler.new {})
21
18
  handler.run context
22
19
 
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Connection
@@ -11,16 +11,17 @@ module HrrRbSsh
11
11
  class RequestType
12
12
  class Subsystem
13
13
  class Context
14
+ include Loggable
15
+
14
16
  attr_reader \
15
- :logger,
16
17
  :username,
17
18
  :io,
18
19
  :variables,
19
20
  :vars,
20
21
  :subsystem_name
21
22
 
22
- def initialize proc_chain, username, io, variables, message, session
23
- @logger = Logger.new self.class.name
23
+ def initialize proc_chain, username, io, variables, message, session, logger: nil
24
+ self.logger = logger
24
25
 
25
26
  @proc_chain = proc_chain
26
27
  @username = username
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
4
  require 'hrr_rb_ssh/connection/request_handler'
6
5
 
7
6
  module HrrRbSsh
@@ -13,10 +12,8 @@ module HrrRbSsh
13
12
  class Subsystem < RequestType
14
13
  NAME = 'subsystem'
15
14
 
16
- def self.run proc_chain, username, io, variables, message, options, session
17
- logger = Logger.new self.class.name
18
-
19
- context = Context.new proc_chain, username, io, variables, message, session
15
+ def self.run proc_chain, username, io, variables, message, options, session, logger: nil
16
+ context = Context.new proc_chain, username, io, variables, message, session, logger: logger
20
17
  handler = options.fetch('connection_channel_request_subsystem', RequestHandler.new {})
21
18
  handler.run context
22
19
 
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Connection
@@ -11,8 +11,9 @@ module HrrRbSsh
11
11
  class RequestType
12
12
  class WindowChange
13
13
  class Context
14
+ include Loggable
15
+
14
16
  attr_reader \
15
- :logger,
16
17
  :username,
17
18
  :io,
18
19
  :variables,
@@ -22,8 +23,8 @@ module HrrRbSsh
22
23
  :terminal_width_pixels,
23
24
  :terminal_height_pixels
24
25
 
25
- def initialize proc_chain, username, io, variables, message, session
26
- @logger = Logger.new self.class.name
26
+ def initialize proc_chain, username, io, variables, message, session, logger: nil
27
+ self.logger = logger
27
28
 
28
29
  @proc_chain = proc_chain
29
30
  @username = username
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
4
  require 'hrr_rb_ssh/connection/request_handler'
6
5
 
7
6
  module HrrRbSsh
@@ -13,10 +12,8 @@ module HrrRbSsh
13
12
  class WindowChange < RequestType
14
13
  NAME = 'window-change'
15
14
 
16
- def self.run proc_chain, username, io, variables, message, options, session
17
- logger = Logger.new self.class.name
18
-
19
- context = Context.new proc_chain, username, io, variables, message, session
15
+ def self.run proc_chain, username, io, variables, message, options, session, logger: nil
16
+ context = Context.new proc_chain, username, io, variables, message, session, logger: logger
20
17
  handler = options.fetch('connection_channel_request_window_change', RequestHandler.new {})
21
18
  handler.run context
22
19