hrr_rb_ssh 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/demo/server.rb +13 -1
  3. data/lib/hrr_rb_ssh/authentication/method/none/context.rb +1 -1
  4. data/lib/hrr_rb_ssh/authentication/method/none.rb +4 -4
  5. data/lib/hrr_rb_ssh/authentication/method/password/context.rb +1 -1
  6. data/lib/hrr_rb_ssh/authentication/method/password.rb +4 -4
  7. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/codable.rb +5 -5
  8. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss.rb +29 -18
  9. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa.rb +27 -16
  10. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm.rb +7 -13
  11. data/lib/hrr_rb_ssh/authentication/method/publickey/context.rb +1 -1
  12. data/lib/hrr_rb_ssh/authentication/method/publickey.rb +5 -5
  13. data/lib/hrr_rb_ssh/authentication/method.rb +6 -12
  14. data/lib/hrr_rb_ssh/authentication.rb +1 -1
  15. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env/context.rb +2 -2
  16. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env.rb +2 -3
  17. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec/context.rb +2 -2
  18. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec.rb +2 -3
  19. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req/context.rb +2 -2
  20. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req.rb +2 -3
  21. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell/context.rb +2 -2
  22. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell.rb +2 -3
  23. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem/context.rb +2 -2
  24. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem.rb +2 -3
  25. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type.rb +16 -11
  26. data/lib/hrr_rb_ssh/connection/channel/channel_type/session.rb +1 -15
  27. data/lib/hrr_rb_ssh/connection/channel/channel_type.rb +15 -10
  28. data/lib/hrr_rb_ssh/connection/channel.rb +1 -1
  29. data/lib/hrr_rb_ssh/data_type.rb +153 -0
  30. data/lib/hrr_rb_ssh/message/001_ssh_msg_disconnect.rb +6 -6
  31. data/lib/hrr_rb_ssh/message/002_ssh_msg_ignore.rb +4 -4
  32. data/lib/hrr_rb_ssh/message/003_ssh_msg_unimplemented.rb +4 -4
  33. data/lib/hrr_rb_ssh/message/004_ssh_msg_debug.rb +6 -6
  34. data/lib/hrr_rb_ssh/message/005_ssh_msg_service_request.rb +4 -4
  35. data/lib/hrr_rb_ssh/message/006_ssh_msg_service_accept.rb +4 -4
  36. data/lib/hrr_rb_ssh/message/020_ssh_msg_kexinit.rb +31 -31
  37. data/lib/hrr_rb_ssh/message/021_ssh_msg_newkeys.rb +3 -3
  38. data/lib/hrr_rb_ssh/message/030_ssh_msg_kexdh_init.rb +4 -4
  39. data/lib/hrr_rb_ssh/message/031_ssh_msg_kexdh_reply.rb +6 -6
  40. data/lib/hrr_rb_ssh/message/050_ssh_msg_userauth_request.rb +18 -18
  41. data/lib/hrr_rb_ssh/message/051_ssh_msg_userauth_failure.rb +5 -5
  42. data/lib/hrr_rb_ssh/message/052_ssh_msg_userauth_success.rb +3 -3
  43. data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_pk_ok.rb +5 -5
  44. data/lib/hrr_rb_ssh/message/080_ssh_msg_global_request.rb +13 -13
  45. data/lib/hrr_rb_ssh/message/081_ssh_msg_request_success.rb +6 -6
  46. data/lib/hrr_rb_ssh/message/082_ssh_msg_request_failure.rb +3 -3
  47. data/lib/hrr_rb_ssh/message/090_ssh_msg_channel_open.rb +25 -25
  48. data/lib/hrr_rb_ssh/message/091_ssh_msg_channel_open_confirmation.rb +25 -25
  49. data/lib/hrr_rb_ssh/message/092_ssh_msg_channel_open_failure.rb +7 -7
  50. data/lib/hrr_rb_ssh/message/093_ssh_msg_channel_window_adjust.rb +5 -5
  51. data/lib/hrr_rb_ssh/message/094_ssh_msg_channel_data.rb +5 -5
  52. data/lib/hrr_rb_ssh/message/095_ssh_msg_channel_extended_data.rb +6 -6
  53. data/lib/hrr_rb_ssh/message/096_ssh_msg_channel_eof.rb +4 -4
  54. data/lib/hrr_rb_ssh/message/097_ssh_msg_channel_close.rb +4 -4
  55. data/lib/hrr_rb_ssh/message/098_ssh_msg_channel_request.rb +53 -53
  56. data/lib/hrr_rb_ssh/message/099_ssh_msg_channel_success.rb +4 -4
  57. data/lib/hrr_rb_ssh/message/100_ssh_msg_channel_failure.rb +4 -4
  58. data/lib/hrr_rb_ssh/message/codable.rb +2 -3
  59. data/lib/hrr_rb_ssh/subclass_with_preference_listable.rb +29 -0
  60. data/lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb +4 -4
  61. data/lib/hrr_rb_ssh/transport/compression_algorithm/none.rb +1 -6
  62. data/lib/hrr_rb_ssh/transport/compression_algorithm/unfunctionable.rb +4 -0
  63. data/lib/hrr_rb_ssh/transport/compression_algorithm/zlib.rb +1 -6
  64. data/lib/hrr_rb_ssh/transport/compression_algorithm.rb +5 -11
  65. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes128_cbc.rb +1 -2
  66. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes128_ctr.rb +1 -2
  67. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes192_cbc.rb +1 -2
  68. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes192_ctr.rb +1 -2
  69. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes256_cbc.rb +1 -2
  70. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes256_ctr.rb +1 -2
  71. data/lib/hrr_rb_ssh/transport/encryption_algorithm/arcfour.rb +1 -2
  72. data/lib/hrr_rb_ssh/transport/encryption_algorithm/blowfish_cbc.rb +1 -2
  73. data/lib/hrr_rb_ssh/transport/encryption_algorithm/cast128_cbc.rb +1 -2
  74. data/lib/hrr_rb_ssh/transport/encryption_algorithm/functionable.rb +1 -2
  75. data/lib/hrr_rb_ssh/transport/encryption_algorithm/none.rb +1 -6
  76. data/lib/hrr_rb_ssh/transport/encryption_algorithm/three_des_cbc.rb +1 -2
  77. data/lib/hrr_rb_ssh/transport/encryption_algorithm/unfunctionable.rb +6 -0
  78. data/lib/hrr_rb_ssh/transport/encryption_algorithm.rb +5 -11
  79. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +14 -14
  80. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group14_sha1.rb +2 -5
  81. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group1_sha1.rb +2 -5
  82. data/lib/hrr_rb_ssh/transport/kex_algorithm.rb +5 -10
  83. data/lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb +2 -3
  84. data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_md5.rb +3 -5
  85. data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_md5_96.rb +3 -5
  86. data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_sha1.rb +3 -5
  87. data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_sha1_96.rb +3 -5
  88. data/lib/hrr_rb_ssh/transport/mac_algorithm/none.rb +2 -8
  89. data/lib/hrr_rb_ssh/transport/mac_algorithm/unfunctionable.rb +4 -0
  90. data/lib/hrr_rb_ssh/transport/mac_algorithm.rb +5 -11
  91. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss.rb +14 -13
  92. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa.rb +12 -11
  93. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm.rb +5 -10
  94. data/lib/hrr_rb_ssh/transport.rb +147 -108
  95. data/lib/hrr_rb_ssh/version.rb +1 -1
  96. metadata +4 -12
  97. data/lib/hrr_rb_ssh/authentication/method/method.rb +0 -34
  98. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/algorithm.rb +0 -41
  99. data/lib/hrr_rb_ssh/connection/channel/channel_type/channel_type.rb +0 -30
  100. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type.rb +0 -34
  101. data/lib/hrr_rb_ssh/transport/compression_algorithm/compression_algorithm.rb +0 -34
  102. data/lib/hrr_rb_ssh/transport/data_type.rb +0 -163
  103. data/lib/hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm.rb +0 -34
  104. data/lib/hrr_rb_ssh/transport/kex_algorithm/kex_algorithm.rb +0 -34
  105. data/lib/hrr_rb_ssh/transport/mac_algorithm/mac_algorithm.rb +0 -34
  106. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/server_host_key_algorithm.rb +0 -34
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,14 +15,14 @@ module HrrRbSsh
15
15
  VALUE = 81
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
20
  ]
21
21
 
22
22
  TCPIP_FORWARD_DEFINITION = [
23
- # [Data Type, Field Name]
24
- # ['string', 'request name' : "tcpip-forward"],
25
- ['uint32', 'port that was bound on the server'],
23
+ #[DataType, Field Name]
24
+ #[DataType::String, 'request name' : "tcpip-forward"],
25
+ [DataType::Uint32, 'port that was bound on the server'],
26
26
  ]
27
27
 
28
28
  CONDITIONAL_DEFINITION = {
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,8 +15,8 @@ module HrrRbSsh
15
15
  VALUE = 82
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
20
  ]
21
21
  end
22
22
  end
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,42 +15,42 @@ module HrrRbSsh
15
15
  VALUE = 90
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
20
- ['string', 'channel type'],
21
- ['uint32', 'sender channel'],
22
- ['uint32', 'initial window size'],
23
- ['uint32', 'maximum packet size'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
+ [DataType::String, 'channel type'],
21
+ [DataType::Uint32, 'sender channel'],
22
+ [DataType::Uint32, 'initial window size'],
23
+ [DataType::Uint32, 'maximum packet size'],
24
24
  ]
25
25
 
26
26
  SESSION_DEFINITION = [
27
- # [Data Type, Field Name]
28
- # ['string', 'channel type' : "session"],
27
+ #[DataType, Field Name]
28
+ #[DataType::String, 'channel type' : "session"],
29
29
  ]
30
30
 
31
31
  X11_DEFINITION = [
32
- # [Data Type, Field Name]
33
- # ['string', 'channel type' : "x11"],
34
- ['string', 'originator address'],
35
- ['uint32', 'originator port'],
32
+ #[DataType, Field Name]
33
+ #[DataType::String, 'channel type' : "x11"],
34
+ [DataType::String, 'originator address'],
35
+ [DataType::Uint32, 'originator port'],
36
36
  ]
37
37
 
38
38
  FORWARDED_TCPIP_DEFINITION = [
39
- # [Data Type, Field Name]
40
- # ['string', 'channel type' : "forwarded-tcpip"],
41
- ['string', 'address that was connected'],
42
- ['uint32', 'port that was connected'],
43
- ['string', 'originator IP address'],
44
- ['uint32', 'originator port'],
39
+ #[DataType, Field Name]
40
+ #[DataType::String, 'channel type' : "forwarded-tcpip"],
41
+ [DataType::String, 'address that was connected'],
42
+ [DataType::Uint32, 'port that was connected'],
43
+ [DataType::String, 'originator IP address'],
44
+ [DataType::Uint32, 'originator port'],
45
45
  ]
46
46
 
47
47
  DIRECT_TCPIP_DEFINITION = [
48
- # [Data Type, Field Name]
49
- # ['string', 'channel type' : "direct-tcpip"],
50
- ['string', 'host to connect'],
51
- ['uint32', 'port to connect'],
52
- ['string', 'originator IP address'],
53
- ['uint32', 'originator port'],
48
+ #[DataType, Field Name]
49
+ #[DataType::String, 'channel type' : "direct-tcpip"],
50
+ [DataType::String, 'host to connect'],
51
+ [DataType::Uint32, 'port to connect'],
52
+ [DataType::String, 'originator IP address'],
53
+ [DataType::Uint32, 'originator port'],
54
54
  ]
55
55
 
56
56
  CONDITIONAL_DEFINITION = {
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,42 +15,42 @@ module HrrRbSsh
15
15
  VALUE = 91
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
20
- ['uint32', 'recipient channel'],
21
- ['uint32', 'sender channel'],
22
- ['uint32', 'initial window size'],
23
- ['uint32', 'maximum packet size'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
+ [DataType::Uint32, 'recipient channel'],
21
+ [DataType::Uint32, 'sender channel'],
22
+ [DataType::Uint32, 'initial window size'],
23
+ [DataType::Uint32, 'maximum packet size'],
24
24
  ]
25
25
 
26
26
  SESSION_DEFINITION = [
27
- # [Data Type, Field Name]
28
- # ['string', 'channel type' : "session"],
27
+ #[DataType, Field Name]
28
+ #[DataType::String, 'channel type' : "session"],
29
29
  ]
30
30
 
31
31
  X11_DEFINITION = [
32
- # [Data Type, Field Name]
33
- # ['string', 'channel type' : "x11"],
34
- ['string', 'originator address'],
35
- ['uint32', 'originator port'],
32
+ #[DataType, Field Name]
33
+ #[DataType::String, 'channel type' : "x11"],
34
+ [DataType::String, 'originator address'],
35
+ [DataType::Uint32, 'originator port'],
36
36
  ]
37
37
 
38
38
  FORWARDED_TCPIP_DEFINITION = [
39
- # [Data Type, Field Name]
40
- # ['string', 'channel type' : "forwarded-tcpip"],
41
- ['string', 'address that was connected'],
42
- ['uint32', 'port that was connected'],
43
- ['string', 'originator IP address'],
44
- ['uint32', 'originator port'],
39
+ #[DataType, Field Name]
40
+ #[DataType::String, 'channel type' : "forwarded-tcpip"],
41
+ [DataType::String, 'address that was connected'],
42
+ [DataType::Uint32, 'port that was connected'],
43
+ [DataType::String, 'originator IP address'],
44
+ [DataType::Uint32, 'originator port'],
45
45
  ]
46
46
 
47
47
  DIRECT_TCPIP_DEFINITION = [
48
- # [Data Type, Field Name]
49
- # ['string', 'channel type' : "direct-tcpip"],
50
- ['string', 'host to connect'],
51
- ['uint32', 'port to connect'],
52
- ['string', 'originator IP address'],
53
- ['uint32', 'originator port'],
48
+ #[DataType, Field Name]
49
+ #[DataType::String, 'channel type' : "direct-tcpip"],
50
+ [DataType::String, 'host to connect'],
51
+ [DataType::Uint32, 'port to connect'],
52
+ [DataType::String, 'originator IP address'],
53
+ [DataType::Uint32, 'originator port'],
54
54
  ]
55
55
 
56
56
  CONDITIONAL_DEFINITION = {
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -22,12 +22,12 @@ module HrrRbSsh
22
22
  VALUE = 92
23
23
 
24
24
  DEFINITION = [
25
- # [Data Type, Field Name]
26
- ['byte', 'message number'],
27
- ['uint32', 'recipient channel'],
28
- ['uint32', 'reason code'],
29
- ['string', 'description'],
30
- ['string', 'language tag'],
25
+ #[DataType, Field Name]
26
+ [DataType::Byte, 'message number'],
27
+ [DataType::Uint32, 'recipient channel'],
28
+ [DataType::Uint32, 'reason code'],
29
+ [DataType::String, 'description'],
30
+ [DataType::String, 'language tag'],
31
31
  ]
32
32
  end
33
33
  end
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,10 +15,10 @@ module HrrRbSsh
15
15
  VALUE = 93
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
20
- ['uint32', 'recipient channel'],
21
- ['uint32', 'bytes to add'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
+ [DataType::Uint32, 'recipient channel'],
21
+ [DataType::Uint32, 'bytes to add'],
22
22
  ]
23
23
  end
24
24
  end
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,10 +15,10 @@ module HrrRbSsh
15
15
  VALUE = 94
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
20
- ['uint32', 'recipient channel'],
21
- ['string', 'data'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
+ [DataType::Uint32, 'recipient channel'],
21
+ [DataType::String, 'data'],
22
22
  ]
23
23
  end
24
24
  end
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -19,11 +19,11 @@ module HrrRbSsh
19
19
  VALUE = 95
20
20
 
21
21
  DEFINITION = [
22
- # [Data Type, Field Name]
23
- ['byte', 'message number'],
24
- ['uint32', 'recipient channel'],
25
- ['uint32', 'data type code'],
26
- ['string', 'data'],
22
+ #[DataType, Field Name]
23
+ [DataType::Byte, 'message number'],
24
+ [DataType::Uint32, 'recipient channel'],
25
+ [DataType::Uint32, 'data type code'],
26
+ [DataType::String, 'data'],
27
27
  ]
28
28
  end
29
29
  end
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,9 +15,9 @@ module HrrRbSsh
15
15
  VALUE = 96
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
20
- ['uint32', 'recipient channel'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
+ [DataType::Uint32, 'recipient channel'],
21
21
  ]
22
22
  end
23
23
  end
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,9 +15,9 @@ module HrrRbSsh
15
15
  VALUE = 97
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
20
- ['uint32', 'recipient channel'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
+ [DataType::Uint32, 'recipient channel'],
21
21
  ]
22
22
  end
23
23
  end
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -31,91 +31,91 @@ module HrrRbSsh
31
31
  VALUE = 98
32
32
 
33
33
  DEFINITION = [
34
- # [Data Type, Field Name]
35
- ['byte', 'message number'],
36
- ['uint32', 'recipient channel'],
37
- ['string', 'request type'],
38
- ['boolean', 'want reply'],
34
+ #[DataType, Field Name]
35
+ [DataType::Byte, 'message number'],
36
+ [DataType::Uint32, 'recipient channel'],
37
+ [DataType::String, 'request type'],
38
+ [DataType::Boolean, 'want reply'],
39
39
  ]
40
40
 
41
41
  PTY_REQ_DEFINITION = [
42
- # [Data Type, Field Name]
43
- # ['string', 'request type' : "pty-req"],
44
- ['string', 'TERM environment variable value'],
45
- ['uint32', 'terminal width, characters'],
46
- ['uint32', 'terminal height, rows'],
47
- ['uint32', 'terminal width, pixels'],
48
- ['uint32', 'terminal height, pixels'],
49
- ['string', 'encoded terminal modes'],
42
+ #[DataType, Field Name]
43
+ #[DataType::String, 'request type' : "pty-req"],
44
+ [DataType::String, 'TERM environment variable value'],
45
+ [DataType::Uint32, 'terminal width, characters'],
46
+ [DataType::Uint32, 'terminal height, rows'],
47
+ [DataType::Uint32, 'terminal width, pixels'],
48
+ [DataType::Uint32, 'terminal height, pixels'],
49
+ [DataType::String, 'encoded terminal modes'],
50
50
  ]
51
51
 
52
52
  X11_REQ_DEFINITION = [
53
- # [Data Type, Field Name]
54
- # ['string', 'request type' : "x11-req"],
55
- ['boolean', 'single connection'],
56
- ['string', 'x11 authentication protocol'],
57
- ['string', 'x11 authentication cookie'],
58
- ['uint32', 'x11 screen number'],
53
+ #[DataType, Field Name]
54
+ #[DataType::String, 'request type' : "x11-req"],
55
+ [DataType::Boolean, 'single connection'],
56
+ [DataType::String, 'x11 authentication protocol'],
57
+ [DataType::String, 'x11 authentication cookie'],
58
+ [DataType::Uint32, 'x11 screen number'],
59
59
  ]
60
60
 
61
61
  ENV_DEFINITION = [
62
- # [Data Type, Field Name]
63
- # ['string', 'request type' : "env"],
64
- ['string', 'variable name'],
65
- ['string', 'variable value'],
62
+ #[DataType, Field Name]
63
+ #[DataType::String, 'request type' : "env"],
64
+ [DataType::String, 'variable name'],
65
+ [DataType::String, 'variable value'],
66
66
  ]
67
67
 
68
68
  SHELL_DEFINITION = [
69
- # [Data Type, Field Name]
70
- # ['string', 'request type' : "shell"],
69
+ #[DataType, Field Name]
70
+ #[DataType::String, 'request type' : "shell"],
71
71
  ]
72
72
 
73
73
  EXEC_DEFINITION = [
74
- # [Data Type, Field Name]
75
- # ['string', 'request type' : "exec"],
76
- ['string', 'command'],
74
+ #[DataType, Field Name]
75
+ #[DataType::String, 'request type' : "exec"],
76
+ [DataType::String, 'command'],
77
77
  ]
78
78
 
79
79
  SUBSYSTEM_DEFINITION = [
80
- # [Data Type, Field Name]
81
- # ['string', 'request type' : "subsystem"],
82
- ['string', 'subsystem name'],
80
+ #[DataType, Field Name]
81
+ #[DataType::String, 'request type' : "subsystem"],
82
+ [DataType::String, 'subsystem name'],
83
83
  ]
84
84
 
85
85
  WINDOW_CHANGE_DEFINITION = [
86
- # [Data Type, Field Name]
87
- # ['string', 'request type' : "window-change"],
88
- ['uint32', 'terminal width, columns'],
89
- ['uint32', 'terminal height, rows'],
90
- ['uint32', 'terminal width, pixels'],
91
- ['uint32', 'terminal height, pixels'],
86
+ #[DataType, Field Name]
87
+ #[DataType::String, 'request type' : "window-change"],
88
+ [DataType::Uint32, 'terminal width, columns'],
89
+ [DataType::Uint32, 'terminal height, rows'],
90
+ [DataType::Uint32, 'terminal width, pixels'],
91
+ [DataType::Uint32, 'terminal height, pixels'],
92
92
  ]
93
93
 
94
94
  XON_XOFF_DEFINITION = [
95
- # [Data Type, Field Name]
96
- # ['string', 'request type' : "xon-xoff"],
97
- ['boolean', 'client can do'],
95
+ #[DataType, Field Name]
96
+ #[DataType::String, 'request type' : "xon-xoff"],
97
+ [DataType::Boolean, 'client can do'],
98
98
  ]
99
99
 
100
100
  SIGNAL_DEFINITION = [
101
- # [Data Type, Field Name]
102
- # ['string', 'request type' : "signal"],
103
- ['string', 'signal name'],
101
+ #[DataType, Field Name]
102
+ #[DataType::String, 'request type' : "signal"],
103
+ [DataType::String, 'signal name'],
104
104
  ]
105
105
 
106
106
  EXIT_STATUS_DEFINITION = [
107
- # [Data Type, Field Name]
108
- # ['string', 'request type' : "exit-status"],
109
- ['uint32', 'exit status'],
107
+ #[DataType, Field Name]
108
+ #[DataType::String, 'request type' : "exit-status"],
109
+ [DataType::Uint32, 'exit status'],
110
110
  ]
111
111
 
112
112
  EXIT_SIGNAL_DEFINITION = [
113
- # [Data Type, Field Name]
114
- # ['string', 'request type' : "exit-signal"],
115
- ['string', 'signal name'],
116
- ['boolean', 'core dumped'],
117
- ['string', 'error message'],
118
- ['string', 'language tag'],
113
+ #[DataType, Field Name]
114
+ #[DataType::String, 'request type' : "exit-signal"],
115
+ [DataType::String, 'signal name'],
116
+ [DataType::Boolean, 'core dumped'],
117
+ [DataType::String, 'error message'],
118
+ [DataType::String, 'language tag'],
119
119
  ]
120
120
 
121
121
  CONDITIONAL_DEFINITION = {
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,9 +15,9 @@ module HrrRbSsh
15
15
  VALUE = 99
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
20
- ['uint32', 'recipient channel'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
+ [DataType::Uint32, 'recipient channel'],
21
21
  ]
22
22
  end
23
23
  end
@@ -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/data_type'
5
5
  require 'hrr_rb_ssh/message/codable'
6
6
 
7
7
  module HrrRbSsh
@@ -15,9 +15,9 @@ module HrrRbSsh
15
15
  VALUE = 100
16
16
 
17
17
  DEFINITION = [
18
- # [Data Type, Field Name]
19
- ['byte', 'message number'],
20
- ['uint32', 'recipient channel'],
18
+ #[DataType, Field Name]
19
+ [DataType::Byte, 'message number'],
20
+ [DataType::Uint32, 'recipient channel'],
21
21
  ]
22
22
  end
23
23
  end
@@ -2,7 +2,6 @@
2
2
  # vim: et ts=2 sw=2
3
3
 
4
4
  require 'hrr_rb_ssh/logger'
5
- require 'hrr_rb_ssh/transport/data_type'
6
5
 
7
6
  module HrrRbSsh
8
7
  module Message
@@ -28,7 +27,7 @@ module HrrRbSsh
28
27
  definition = common_definition + conditional_definition(message.merge complementary_message)
29
28
  definition.map{ |data_type, field_name|
30
29
  field_value = if message[field_name].instance_of? ::Proc then message[field_name].call else message[field_name] end
31
- HrrRbSsh::Transport::DataType[data_type].encode( field_value )
30
+ data_type.encode( field_value )
32
31
  }.join
33
32
  end
34
33
 
@@ -46,7 +45,7 @@ module HrrRbSsh
46
45
  decoded_message = definition.map{ |data_type, field_name|
47
46
  [
48
47
  field_name,
49
- HrrRbSsh::Transport::DataType[data_type].decode( payload_io )
48
+ data_type.decode( payload_io )
50
49
  ]
51
50
  }
52
51
 
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ # vim: et ts=2 sw=2
3
+
4
+ module HrrRbSsh
5
+ module SubclassWithPreferenceListable
6
+ def inherited klass
7
+ @subclass_list.push klass if @subclass_list
8
+ end
9
+
10
+ def [] key
11
+ __subclass_list__(__method__).find{ |klass| klass::NAME == key }
12
+ end
13
+
14
+ def list_supported
15
+ __subclass_list__(__method__).map{ |klass| klass::NAME }
16
+ end
17
+
18
+ def list_preferred
19
+ __subclass_list__(__method__).select{ |klass| klass::PREFERENCE > 0 }.sort_by{ |klass| klass::PREFERENCE }.reverse.map{ |klass| klass::NAME }
20
+ end
21
+
22
+ def __subclass_list__ method_name
23
+ send(:method_missing, method_name) unless @subclass_list
24
+ @subclass_list
25
+ end
26
+
27
+ private :__subclass_list__
28
+ end
29
+ end
@@ -2,18 +2,18 @@
2
2
  # vim: et ts=2 sw=2
3
3
 
4
4
  require 'zlib'
5
+ require 'hrr_rb_ssh/logger'
5
6
 
6
7
  module HrrRbSsh
7
8
  class Transport
8
9
  class CompressionAlgorithm
9
10
  module Functionable
10
11
  def initialize direction
11
- super
12
-
12
+ @logger = HrrRbSsh::Logger.new(self.class.name)
13
13
  case direction
14
- when HrrRbSsh::Transport::Direction::OUTGOING
14
+ when Direction::OUTGOING
15
15
  @deflator = ::Zlib::Deflate.new
16
- when HrrRbSsh::Transport::Direction::INCOMING
16
+ when Direction::INCOMING
17
17
  @inflator = ::Zlib::Inflate.new
18
18
  end
19
19
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/compression_algorithm/compression_algorithm'
5
4
  require 'hrr_rb_ssh/transport/compression_algorithm/unfunctionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,11 +8,7 @@ module HrrRbSsh
9
8
  class CompressionAlgorithm
10
9
  class None < CompressionAlgorithm
11
10
  NAME = 'none'
12
-
13
- def initialize direction=nil
14
- super
15
- end
16
-
11
+ PREFERENCE = 20
17
12
  include Unfunctionable
18
13
  end
19
14
  end