Module: Ftpd::DataServerFactory

Defined in:
lib/ftpd/data_server_factory.rb,
lib/ftpd/data_server_factory/specific_port_range.rb,
lib/ftpd/data_server_factory/random_ephemeral_port.rb

Overview

Factories for creating TCPServer used for passive mode connections.

Defined Under Namespace

Classes: RandomEphemeralPort, SpecificPortRange

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tcp_serverObject (readonly)

Returns the value of attribute tcp_server.



12
13
14
# File 'lib/ftpd/data_server_factory.rb', line 12

def tcp_server
  @tcp_server
end

Class Method Details

.make(interface, ports) ⇒ Object

Create a factory.

Parameters:

  • interface (String)

    The IP address of the interface to bind to (e.g. “127.0.0.1”)

  • ports (nil, Range)

    The range of ports to bind to. If nil, then binds to a random ephemeral port.



20
21
22
23
24
25
26
# File 'lib/ftpd/data_server_factory.rb', line 20

def self.make(interface, ports)
  if ports
    SpecificPortRange.new(interface, ports)
  else
    RandomEphemeralPort.new(interface)
  end
end

Instance Method Details

#initialize(interface, ports) ⇒ Object

Parameters:

  • interface (String)

    The IP address of the interface to bind to (e.g. “127.0.0.1”)

  • ports (nil, Range)

    The range of ports to bind to. If nil, then binds to a random ephemeral port.



32
33
34
35
# File 'lib/ftpd/data_server_factory.rb', line 32

def initialize(interface, ports)
  @interface = interface
  @ports = ports
end

#make_tcp_serverTCPServer

Returns:

  • (TCPServer)


38
39
40
# File 'lib/ftpd/data_server_factory.rb', line 38

def make_tcp_server
  TCPServer.new(@interface, 0)
end