Class: FtpProxy
- Inherits:
-
Object
- Object
- FtpProxy
- Defined in:
- lib/ftpproxy.rb
Defined Under Namespace
Classes: ActiveRelay, Relay, Session
Constant Summary collapse
- VERSION =
'1.2.0'
- WHITELIST =
%w[cwd cdup dele list mdtm mkd nlst pass pwd quit retr rmd rnfr rnto size stor syst type user xpwd]
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ FtpProxy
constructor
A new instance of FtpProxy.
- #start ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ FtpProxy
Returns a new instance of FtpProxy.
217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/ftpproxy.rb', line 217 def initialize params={} params = {:mode => :client, :port => 21, :proxy => nil}.merge(params) params[:mode] = nil if params[:mode] == :client @params = params unless @log = params[:log] @log = @params[:log] = Logger.new(STDERR) end @log.info "Starting ftpproxy v#{VERSION} on #{Socket.gethostname}:#{params[:port]}" @server = TCPServer.new '', params[:port] Process.egid = params[:gid] if params[:gid] Process.euid = params[:uid] if params[:uid] end |
Instance Method Details
#start ⇒ Object
230 231 232 233 234 235 236 237 238 |
# File 'lib/ftpproxy.rb', line 230 def start threads = [] @log.debug 'Waiting for connections' while socket = @server.accept @log.debug "Accepted connection from #{socket.peeraddr.join(', ')}" threads << Thread.new { Session.new(socket, @params).start } end threads.each { |t| t.join } end |