set p $state(playback) ;# Save what gets displayed
clearOutput ;# Erase current screen
foreach {who data time} $p { ;# Replay the input stream
set p $state(playback) ;# Save what gets displayed
clearOutput ;# Erase current screen
foreach {who data time} $p { ;# Replay the input stream
- close $fromSock
- catch { close $toSock }
- if {$died} { INFO $err }
- INFO "----- closed connection $fromSock \[eof\] -----"
- INFO "waiting for new connection..."
- return
+ close $fromSock
+ catch { close $toSock }
+ if {$died} { INFO $err }
+ INFO "----- closed connection $fromSock \[eof\] -----"
+ INFO "waiting for new connection..."
+ return
}
if {$toSock == ""} { ;# Make socks or http proxy connection
if {[catch {ProxyConnect $fromSock $data} err]} {
INFO $err
close $fromSock
INFO "----- closed connection $fromSock -----"
}
if {$toSock == ""} { ;# Make socks or http proxy connection
if {[catch {ProxyConnect $fromSock $data} err]} {
INFO $err
close $fromSock
INFO "----- closed connection $fromSock -----"
set line1 [string trimright $line1 "\r\n"]
INFO "proxy request \"$line1\"" meta2
if {![regexp {^([^ ]+) +([^ ]+)} $line1 -> method uri]} {
set line1 [string trimright $line1 "\r\n"]
INFO "proxy request \"$line1\"" meta2
if {![regexp {^([^ ]+) +([^ ]+)} $line1 -> method uri]} {
set method [string trim [string toupper $method]]
if {$method eq "CONNECT"} {
foreach {host port} [split $uri :] break
set method [string trim [string toupper $method]]
if {$method eq "CONNECT"} {
foreach {host port} [split $uri :] break
if {$URI(port) == ""} { set URI(port) 80 }
set bad [catch {set sockServ [socket $URI(host) $URI(port)]} reason]
if {$bad} {
if {$URI(port) == ""} { set URI(port) 80 }
set bad [catch {set sockServ [socket $URI(host) $URI(port)]} reason]
if {$bad} {
- # We must send an HTTP response header to the client
- set s "HTTP/1.0 200 OK\nServer: SockSpy/$::state(version)\n"
- insertData meta $s
- puts $fromSock $s
+ # We must send an HTTP response header to the client
+ set s "HTTP/1.0 200 OK\nServer: SockSpy/$::state(version)\n"
+ insertData meta $s
+ puts $fromSock $s
- close $fromSock
- catch { close $toSock }
- INFO "----- closed connection -----"
- INFO "waiting for new connection..."
- return
+ close $fromSock
+ catch { close $toSock }
+ INFO "----- closed connection -----"
+ INFO "waiting for new connection..."
+ return
- set n [catch {set sockServ [socket $SP(servHost) $SP(servPort)]} reason]
- if {$n} {
- INFO "cannot connect: $reason"
- close $sockClnt
- ERROR "cannot connect to $SP(servHost) $SP(servPort): $reason"
- insertData meta "----- closed connection -----"
- insertData meta "waiting for new connection..."
-
- }
- INFO "connecting to $SP(servHost):$SP(servPort)" meta2
+ set n [catch {set sockServ [socket $SP(servHost) $SP(servPort)]} reason]
+ if {$n} {
+ INFO "cannot connect: $reason"
+ close $sockClnt
+ ERROR "cannot connect to $SP(servHost) $SP(servPort): $reason"
+ insertData meta "----- closed connection -----"
+ insertData meta "waiting for new connection..."
+ }
+ INFO "connecting to $SP(servHost):$SP(servPort)" meta2
}
;# Configure connection to the client
fconfigure $sockClnt -blocking 0 -buffering none -translation binary
fileevent $sockClnt readable \
}
;# Configure connection to the client
fconfigure $sockClnt -blocking 0 -buffering none -translation binary
fileevent $sockClnt readable \
- fconfigure $sockServ -blocking 0 -buffering none -translation binary
- fileevent $sockServ readable \
- [list sockReadable $sockServ $sockClnt server]
+ fconfigure $sockServ -blocking 0 -buffering none -translation binary
+ fileevent $sockServ readable \
+ [list sockReadable $sockServ $sockClnt server]
- if {[info exists env(DOTDIR)]} {
- set stateFile [file join $env(DOTDIR) .sockspy]
- } else {
- set stateFile [file join $env(HOME) .sockspy]
- }
+ if {[info exists env(DOTDIR)]} {
+ set stateFile [file join $env(DOTDIR) .sockspy]
+ } else {
+ set stateFile [file join $env(HOME) .sockspy]
+ }