Class: Ftpd::Protocols

Inherits:
Object
  • Object
show all
Includes:
Codes
Defined in:
lib/ftpd/protocols.rb

Overview

With the commands EPORT and EPSV, the client sends a protocol code to indicate whether it wants an IPV4 or an IPV6 connection. This class contains functions related to that protocol code.

Defined Under Namespace

Modules: Codes

Constant Summary

Constants included from Codes

Codes::IPV4, Codes::IPV6

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ Protocols



21
22
23
# File 'lib/ftpd/protocols.rb', line 21

def initialize(socket)
  @socket = socket
end

Instance Method Details

#protocol_codesArray<Integer>

What protocol codes does the socket support?



37
38
39
40
41
42
# File 'lib/ftpd/protocols.rb', line 37

def protocol_codes
  [
    (IPV4 if supports_ipv4?),
    (IPV6 if supports_ipv6?),
  ].compact
end

#supports_protocol?(protocol_code) ⇒ Boolean

Can the socket support a connection in the indicated protocol?



29
30
31
# File 'lib/ftpd/protocols.rb', line 29

def supports_protocol?(protocol_code)
  protocol_codes.include?(protocol_code)
end