ftpd 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +7 -1
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +1 -1
  5. data/README.md +28 -4
  6. data/VERSION +1 -1
  7. data/examples/foo.rb +114 -0
  8. data/ftpd.gemspec +56 -8
  9. data/lib/ftpd.rb +77 -31
  10. data/lib/ftpd/ascii_helper.rb +16 -0
  11. data/lib/ftpd/cmd_abor.rb +13 -0
  12. data/lib/ftpd/cmd_allo.rb +20 -0
  13. data/lib/ftpd/cmd_appe.rb +23 -0
  14. data/lib/ftpd/cmd_auth.rb +21 -0
  15. data/lib/ftpd/cmd_cdup.rb +16 -0
  16. data/lib/ftpd/cmd_cwd.rb +20 -0
  17. data/lib/ftpd/cmd_dele.rb +21 -0
  18. data/lib/ftpd/cmd_eprt.rb +23 -0
  19. data/lib/ftpd/cmd_epsv.rb +30 -0
  20. data/lib/ftpd/cmd_feat.rb +44 -0
  21. data/lib/ftpd/cmd_help.rb +29 -0
  22. data/lib/ftpd/cmd_list.rb +33 -0
  23. data/lib/ftpd/cmd_login.rb +60 -0
  24. data/lib/ftpd/cmd_mdtm.rb +27 -0
  25. data/lib/ftpd/cmd_mkd.rb +23 -0
  26. data/lib/ftpd/cmd_mode.rb +27 -0
  27. data/lib/ftpd/cmd_nlst.rb +27 -0
  28. data/lib/ftpd/cmd_noop.rb +14 -0
  29. data/lib/ftpd/cmd_opts.rb +14 -0
  30. data/lib/ftpd/cmd_pasv.rb +28 -0
  31. data/lib/ftpd/cmd_pbsz.rb +23 -0
  32. data/lib/ftpd/cmd_port.rb +28 -0
  33. data/lib/ftpd/cmd_prot.rb +34 -0
  34. data/lib/ftpd/cmd_pwd.rb +15 -0
  35. data/lib/ftpd/cmd_quit.rb +18 -0
  36. data/lib/ftpd/cmd_rein.rb +13 -0
  37. data/lib/ftpd/cmd_rename.rb +32 -0
  38. data/lib/ftpd/cmd_rest.rb +13 -0
  39. data/lib/ftpd/cmd_retr.rb +23 -0
  40. data/lib/ftpd/cmd_rmd.rb +22 -0
  41. data/lib/ftpd/cmd_site.rb +13 -0
  42. data/lib/ftpd/cmd_size.rb +21 -0
  43. data/lib/ftpd/cmd_smnt.rb +13 -0
  44. data/lib/ftpd/cmd_stat.rb +15 -0
  45. data/lib/ftpd/cmd_stor.rb +24 -0
  46. data/lib/ftpd/cmd_stou.rb +24 -0
  47. data/lib/ftpd/cmd_stru.rb +27 -0
  48. data/lib/ftpd/cmd_syst.rb +16 -0
  49. data/lib/ftpd/cmd_type.rb +28 -0
  50. data/lib/ftpd/command_handler.rb +91 -0
  51. data/lib/ftpd/command_handler_factory.rb +51 -0
  52. data/lib/ftpd/command_handlers.rb +60 -0
  53. data/lib/ftpd/command_loop.rb +77 -0
  54. data/lib/ftpd/data_connection_helper.rb +124 -0
  55. data/lib/ftpd/disk_file_system.rb +22 -6
  56. data/lib/ftpd/error.rb +4 -0
  57. data/lib/ftpd/file_system_helper.rb +67 -0
  58. data/lib/ftpd/ftp_server.rb +1 -1
  59. data/lib/ftpd/server.rb +1 -0
  60. data/lib/ftpd/session.rb +31 -749
  61. data/lib/ftpd/tls_server.rb +2 -0
  62. data/spec/server_spec.rb +66 -0
  63. metadata +81 -30
@@ -1,3 +1,5 @@
1
+ require_relative 'server'
2
+
1
3
  module Ftpd
2
4
  class TlsServer < Server
3
5
 
@@ -0,0 +1,66 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ module Ftpd
4
+
5
+ describe Server do
6
+
7
+ describe 'reuse explicit port (github #23)' do
8
+
9
+ # The bug being tested involves a race condition. Monkey patch
10
+ # the server so that start does not return until "accept" has
11
+ # been called on the server socket. This causes the test to
12
+ # reliably expose the bug.
13
+
14
+ def monkey_patch_server(server)
15
+
16
+ class << server
17
+
18
+ def start
19
+ @accepting = Queue.new
20
+ super
21
+ wait_for_accept
22
+ end
23
+
24
+ def accept
25
+ @accepting.enq true
26
+ super
27
+ end
28
+
29
+ private
30
+
31
+ def wait_for_accept
32
+ @accepting.deq
33
+ # There's a potential race condition in _this_ code:
34
+ # @accepting is triggered just before the accept is done
35
+ # on the socket, but it's possible that the server thread
36
+ # has been preempted and accept has not yet been called.
37
+ # A little sleep gives the server thread another shot at
38
+ # actually getting the accept done before we continue.
39
+ sleep 0.01
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ it do
47
+ port = find_open_port
48
+ 2.times do
49
+ server = Server.new
50
+ monkey_patch_server server
51
+ server.port = port
52
+ server.start
53
+ server.stop
54
+ end
55
+ end
56
+
57
+ def find_open_port
58
+ socket = TCPServer.new('localhost', 0)
59
+ socket.addr[1].tap {socket.close}
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+
66
+ end
metadata CHANGED
@@ -1,144 +1,147 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftpd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wayne Conrad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-16 00:00:00.000000000 Z
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memoizer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.1
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.1
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: cucumber
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: double-bag-ftps
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: jeweler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: redcarpet
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: timecop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: yard
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description: ftpd is a pure Ruby FTP server library. It supports implicit and explicit
140
- TLS, IPV6, passive and active mode, and is unconditionally compliant per [RFC-1123][1]. It
141
- can be used as part of a test fixture or embedded in a program.
139
+ description: '[![Code Climate](https://codeclimate.com/github/wconrad/ftpd.png)](https://codeclimate.com/github/wconrad/ftpd)
140
+ [![Build Status](https://travis-ci.org/wconrad/ftpd.png)](https://travis-ci.org/wconrad/ftpd)
141
+ [![Gem Version](https://badge.fury.io/rb/ftpd.png)](http://badge.fury.io/rb/ftpd) ftpd
142
+ is a pure Ruby FTP server library. It supports implicit and explicit TLS, IPV6,
143
+ passive and active mode, and is unconditionally compliant per [RFC-1123][1]. It
144
+ can be used as part of a test fixture or embedded in a program.'
142
145
  email: wconrad@yagni.com
143
146
  executables: []
144
147
  extensions: []
@@ -146,8 +149,8 @@ extra_rdoc_files:
146
149
  - LICENSE.md
147
150
  - README.md
148
151
  files:
149
- - ".travis.yml"
150
- - ".yardopts"
152
+ - .travis.yml
153
+ - .yardopts
151
154
  - Changelog.md
152
155
  - Gemfile
153
156
  - Gemfile.lock
@@ -160,6 +163,7 @@ files:
160
163
  - doc/rfc-compliance.md
161
164
  - examples/example.rb
162
165
  - examples/example_spec.rb
166
+ - examples/foo.rb
163
167
  - examples/hello_world.rb
164
168
  - features/example/eplf.feature
165
169
  - features/example/example.feature
@@ -268,17 +272,63 @@ files:
268
272
  - ftpd.gemspec
269
273
  - insecure-test-cert.pem
270
274
  - lib/ftpd.rb
275
+ - lib/ftpd/ascii_helper.rb
271
276
  - lib/ftpd/auth_levels.rb
277
+ - lib/ftpd/cmd_abor.rb
278
+ - lib/ftpd/cmd_allo.rb
279
+ - lib/ftpd/cmd_appe.rb
280
+ - lib/ftpd/cmd_auth.rb
281
+ - lib/ftpd/cmd_cdup.rb
282
+ - lib/ftpd/cmd_cwd.rb
283
+ - lib/ftpd/cmd_dele.rb
284
+ - lib/ftpd/cmd_eprt.rb
285
+ - lib/ftpd/cmd_epsv.rb
286
+ - lib/ftpd/cmd_feat.rb
287
+ - lib/ftpd/cmd_help.rb
288
+ - lib/ftpd/cmd_list.rb
289
+ - lib/ftpd/cmd_login.rb
290
+ - lib/ftpd/cmd_mdtm.rb
291
+ - lib/ftpd/cmd_mkd.rb
292
+ - lib/ftpd/cmd_mode.rb
293
+ - lib/ftpd/cmd_nlst.rb
294
+ - lib/ftpd/cmd_noop.rb
295
+ - lib/ftpd/cmd_opts.rb
296
+ - lib/ftpd/cmd_pasv.rb
297
+ - lib/ftpd/cmd_pbsz.rb
298
+ - lib/ftpd/cmd_port.rb
299
+ - lib/ftpd/cmd_prot.rb
300
+ - lib/ftpd/cmd_pwd.rb
301
+ - lib/ftpd/cmd_quit.rb
302
+ - lib/ftpd/cmd_rein.rb
303
+ - lib/ftpd/cmd_rename.rb
304
+ - lib/ftpd/cmd_rest.rb
305
+ - lib/ftpd/cmd_retr.rb
306
+ - lib/ftpd/cmd_rmd.rb
307
+ - lib/ftpd/cmd_site.rb
308
+ - lib/ftpd/cmd_size.rb
309
+ - lib/ftpd/cmd_smnt.rb
310
+ - lib/ftpd/cmd_stat.rb
311
+ - lib/ftpd/cmd_stor.rb
312
+ - lib/ftpd/cmd_stou.rb
313
+ - lib/ftpd/cmd_stru.rb
314
+ - lib/ftpd/cmd_syst.rb
315
+ - lib/ftpd/cmd_type.rb
316
+ - lib/ftpd/command_handler.rb
317
+ - lib/ftpd/command_handler_factory.rb
318
+ - lib/ftpd/command_handlers.rb
319
+ - lib/ftpd/command_loop.rb
272
320
  - lib/ftpd/command_sequence_checker.rb
273
321
  - lib/ftpd/config.rb
274
322
  - lib/ftpd/connection_throttle.rb
275
323
  - lib/ftpd/connection_tracker.rb
324
+ - lib/ftpd/data_connection_helper.rb
276
325
  - lib/ftpd/disk_file_system.rb
277
326
  - lib/ftpd/error.rb
278
327
  - lib/ftpd/exception_translator.rb
279
328
  - lib/ftpd/exceptions.rb
280
329
  - lib/ftpd/file_info.rb
281
330
  - lib/ftpd/file_system_error_translator.rb
331
+ - lib/ftpd/file_system_helper.rb
282
332
  - lib/ftpd/ftp_server.rb
283
333
  - lib/ftpd/insecure_certificate.rb
284
334
  - lib/ftpd/list_format/eplf.rb
@@ -312,6 +362,7 @@ files:
312
362
  - spec/list_path_spec.rb
313
363
  - spec/null_logger_spec.rb
314
364
  - spec/protocols_spec.rb
365
+ - spec/server_spec.rb
315
366
  - spec/spec_helper.rb
316
367
  - spec/telnet_spec.rb
317
368
  - spec/translate_exceptions_spec.rb
@@ -325,17 +376,17 @@ require_paths:
325
376
  - lib
326
377
  required_ruby_version: !ruby/object:Gem::Requirement
327
378
  requirements:
328
- - - ">="
379
+ - - '>='
329
380
  - !ruby/object:Gem::Version
330
381
  version: '0'
331
382
  required_rubygems_version: !ruby/object:Gem::Requirement
332
383
  requirements:
333
- - - ">="
384
+ - - '>='
334
385
  - !ruby/object:Gem::Version
335
386
  version: '0'
336
387
  requirements: []
337
388
  rubyforge_project:
338
- rubygems_version: 2.2.1
389
+ rubygems_version: 2.2.2
339
390
  signing_key:
340
391
  specification_version: 4
341
392
  summary: Pure Ruby FTP server library