Class ::ftpd::Session

::ftpd::Session[i] create ... \
           [ -channel channel ] \
           [ -currentdir:substdefault (default "[file normalize [ns_server pagedir]/]") ] \
           [ -data data ] \
           [ -host host ] \
           [ -listen listen ] \
           [ -permission_bits (default "0 --- 1 --x 2 -w- 3 -wx 4 r-- 5 r-x 6 rw- 7 rwx") ] \
           [ -rootdir rootdir ] \
           [ -type (default "L8") ]

Defined in

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::ftpd::Infrastructure[i]
::nx::Class create ::ftpd::Session \
     -superclass ::ftpd::Infrastructure

Methods (to be applied on instances)

  • close_data (scripted, public)

     <instance of ftpd::Session[i]> close_data

    Testcases:
    No testcase defined.
    if {[info exists :data]} {
        :log debug "closing data channel ${:data}"
        ns_connchan close ${:data}
        unset :data
    }
  • listen_data (scripted, public)

     <instance of ftpd::Session[i]> listen_data channel
    Parameters:
    channel (required)

    Testcases:
    No testcase defined.
    ns_connchan close ${:listen}
    unset :listen
    :log debug "listen_data sets :data <$channel>"
    set :data $channel
    :log debug "have delayed cmds [info exists :delayed_cmds]"
    if {[info exists :delayed_cmds]} {
        foreach {lambda arg} ${:delayed_cmds} {
            apply $lambda $arg
        }
        unset :delayed_cmds
    }
  • read_handler (scripted, public)

     <instance of ftpd::Session[i]> read_handler condition
    Parameters:
    condition (required)

    Testcases:
    No testcase defined.
    set bytes [encoding convertfrom utf-8 [ns_connchan read ${:channel}]]
    set rlen [string length $bytes]
    #:log debug "read_handler: ${:channel} $rlen <[string trim $bytes]>"
    set result 0
    if {0 && $rlen == 0} {
        :log debug "client has closed connection"
    } else {
        #
        # Some clients send multiple lines/commands in one transmission
        #
        foreach line [split [string trim $bytes] \n] {
            set line [string trim $line]
            :log debug "${:channel} <<< $line"
            if {$line eq ""} continue
            if {[regexp {^([A-Za-z]+)\s?(.*)$} $line . cmd arg]} {
                set cmd [string toupper $cmd]
                if {[:info lookup method $cmd] ne ""} {
                    :$cmd $arg
                    set result 1
                } else {
                    :log warning "502 Requested action <$cmd> not taken"
                    :reply "502 Requested action <$cmd> not taken"
                }
            } else {
                :log warning "line <$line> does not look like a valid command"
            }
        }
    }
    return $result