ftp, ssl,, tls nd tcllib:what is the best way to do sftp?

101 views
Skip to first unread message

alex...@gmail.com

unread,
May 22, 2008, 10:28:12 AM5/22/08
to
How is the best way to do this?

The back I can come up with some hacking...

package require ftp
package require tls

proc ::ftp::OpenControlConn {s {block 1}} {

upvar ::ftp::ftp$s ftp
variable DEBUG
variable VERBOSE

# open a control channel

####################
#set rc [catch {set ftp(CtrlSock) [socket $ftp(RemoteHost)
$ftp(Port)]} msg]
####################
set rc [catch {set ftp(CtrlSock) [tls::socket $ftp(RemoteHost)
$ftp(Port)]} msg]
#######################
if { $rc != 0 } {
if { $VERBOSE } {
DisplayMsg $s "C: No connection to server!" error
}
if { $DEBUG } {
DisplayMsg $s "[list $msg]" error
}
unset ftp(State)
return 0
}

# configure control channel

fconfigure $ftp(CtrlSock) -buffering line -blocking $block -
translation {auto crlf}
fileevent $ftp(CtrlSock) readable [list [namespace
current]::StateHandler $s $ftp(CtrlSock)]

# prepare local ip address for PORT command (convert pointed format
# to comma format)

set ftp(LocalAddr) [lindex [fconfigure $ftp(CtrlSock) -sockname] 0]
set ftp(LocalAddr) [string map {. ,} $ftp(LocalAddr)]

# report ready message

set peer [fconfigure $ftp(CtrlSock) -peername]
if { $VERBOSE } {
DisplayMsg $s "C: Connection from [lindex $peer 0]:[lindex
$peer 2]" control
}

return 1
}


Reply all
Reply to author
Forward
0 new messages