lib/fake_ftp/server.rb in fake_ftp-0.0.5 vs lib/fake_ftp/server.rb in fake_ftp-0.0.6
- old
+ new
@@ -51,11 +51,11 @@
@server.close
@server = nil
end
if passive_port
- @data_server = ::TCPserver.new('127.0.0.1', passive_port)
+ @data_server = ::TCPServer.new('127.0.0.1', passive_port)
end
end
def stop
@started = false
@@ -83,11 +83,11 @@
command = request[0, 4].downcase.strip
contents = request.split
message = contents[1..contents.length]
case command
when *CMDS
- __send__ "_#{command}", message
+ __send__ "_#{command}", *message
else
'500 Unknown command'
end
end
@@ -113,12 +113,12 @@
else
'502 Aww hell no, use Active'
end
end
- def _port(remote)
- remote = remote.first.split(',')
+ def _port(remote = '')
+ remote = remote.split(',')
remote_port = remote[4].to_i * 256 + remote[5].to_i
unless @active_connection.nil?
@active_connection.close
@active_connection = nil
end
@@ -135,11 +135,11 @@
respond_with '221 OMG bye!'
@client.close if @client
@client = nil
end
- def _stor(filename)
+ def _stor(filename = '')
respond_with('425 Ain\'t no data port!') && return if active? && @active_connection.nil?
respond_with('125 Do it!')
data_client = active? ? @active_connection : @data_server.accept
@@ -150,11 +150,11 @@
data_client.close
@active_connection = nil
'226 Did it!'
end
- def _retr(filename)
+ def _retr(filename = '')
respond_with('501 No filename given') if filename.empty?
file = file(::File.basename(filename.to_s))
return respond_with('550 File not found') if file.nil?
@@ -168,11 +168,11 @@
data_client.close
@active_connection = nil
'226 File transferred'
end
- def _list(args)
+ def _list(*args)
respond_with('425 Ain\'t no data port!') && return if active? && @active_connection.nil?
respond_with('150 Listing status ok, about to open data connection')
data_client = active? ? @active_connection : @data_server.accept
@@ -183,10 +183,10 @@
@active_connection = nil
'226 List information transferred'
end
- def _nlst(args)
+ def _nlst(*args)
respond_with('425 Ain\'t no data port!') && return if active? && @active_connection.nil?
respond_with('150 Listing status ok, about to open data connection')
data_client = active? ? @active_connection : @data_server.accept