From: Pat Thoyts Date: Wed, 24 Jul 2024 08:08:22 +0000 (+0100) Subject: Whitespace changes X-Git-Url: https://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=sockspy Whitespace changes --- diff --git a/bin/sockspy.tcl b/bin/sockspy.tcl index 204a396..d37a16a 100644 --- a/bin/sockspy.tcl +++ b/bin/sockspy.tcl @@ -373,8 +373,8 @@ proc doFont {delta} { proc clearOutput {} { global state if {$state(gui)} { - .out delete 0.0 end - catch {.extract.out delete 0.0 end} + .out delete 0.0 end + catch {.extract.out delete 0.0 end} } set state(playback) "" } @@ -393,7 +393,7 @@ proc redraw {} { set p $state(playback) ;# Save what gets displayed clearOutput ;# Erase current screen foreach {who data time} $p { ;# Replay the input stream - insertData $who $data $time 1 + insertData $who $data $time 1 } set state(autoscroll) $save_as } @@ -657,13 +657,13 @@ proc timestampWindow {} { # proc tfButton {who} { if {$who == "default"} { - set ::state(timeFormat) $::state(timeFormatDefault) + set ::state(timeFormat) $::state(timeFormatDefault) } elseif {$who == "ok"} { - destroy .tf - redraw + destroy .tf + redraw } elseif {$who == "cancel"} { - set ::state(timeFormat) $::state(oldTimeFormat) - destroy .tf + set ::state(timeFormat) $::state(oldTimeFormat) + destroy .tf } } ##+########################################################################## @@ -680,9 +680,9 @@ proc INFO {msg {who meta} {time {}} {display 0}} { } proc ERROR {emsg} { if {$::state(gui)} { - tk_messageBox -title "SockSpy Error" -message $emsg -icon error + tk_messageBox -title "SockSpy Error" -message $emsg -icon error } else { - puts $emsg + puts $emsg } } ##+########################################################################## @@ -693,23 +693,23 @@ proc sockReadable {fromSock toSock who} { global state set died [catch {set data [read $fromSock]} err] if {$died || [eof $fromSock]} { - 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 -----" - INFO "waiting for new connection..." + INFO "waiting for new connection..." return 0 } } else { - catch { puts -nonewline $toSock $data } ;# Forward if we have a socket + catch { puts -nonewline $toSock $data } ;# Forward if we have a socket } insertData [list $who $fromSock] $data update idletasks @@ -731,9 +731,9 @@ proc ProxyConnect {fromSock data} { set line1 [string trimright $line1 "\r\n"] INFO "proxy request \"$line1\"" meta2 if {![regexp {^([^ ]+) +([^ ]+)} $line1 -> method uri]} { - return -code error "failed to parse a uri from '$line1'" + return -code error "failed to parse a uri from '$line1'" } - + set method [string trim [string toupper $method]] if {$method eq "CONNECT"} { foreach {host port} [split $uri :] break @@ -760,26 +760,26 @@ proc ProxyConnect {fromSock data} { if {$URI(port) == ""} { set URI(port) 80 } set bad [catch {set sockServ [socket $URI(host) $URI(port)]} reason] if {$bad} { - return -code error "cannot connect to $URI(host):$URI(port) => $reason" + return -code error "cannot connect to $URI(host):$URI(port) => $reason" } if {$method eq "CONNECT"} { - # 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 } INFO "fowarding $method request to $URI(host):$URI(port)" meta2 if {$skip} { - fileevent $fromSock readable \ - [list ProxySkip $fromSock $sockServ] + fileevent $fromSock readable \ + [list ProxySkip $fromSock $sockServ] } else { - fileevent $fromSock readable \ - [list sockReadable $fromSock $sockServ client] + fileevent $fromSock readable \ + [list sockReadable $fromSock $sockServ client] } fconfigure $sockServ -blocking 0 -buffering none -translation binary fileevent $sockServ readable \ - [list sockReadable $sockServ $fromSock server] - + [list sockReadable $sockServ $fromSock server] + puts -nonewline $sockServ $data return } @@ -824,22 +824,22 @@ proc ProxySkip {fromSock toSock} { global state set data [read $fromSock] if {[string length $data] == 0} { - 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 pos [string first \r\n\r\n $data] if { $pos == -1 } { - # Just drop the data. - return + # Just drop the data. + return } incr pos 4 set data [string range $data $pos end] if { [string length $data] > 0 } { - # Forward the real payload - catch { puts -nonewline $toSock $data } ; + # Forward the real payload + catch { puts -nonewline $toSock $data } ; insertData client $data } # And let the normal data handler do the rest: @@ -887,35 +887,34 @@ proc clntConnect {sockClnt ip port} { set state(sockClnt) $sockClnt set state(meta) "" - + INFO "connect from [fconfigure $sockClnt -sockname] $port" meta2 if {$state(proxy) ne "none" - || $SP(servHost) == {} + || $SP(servHost) == {} || $SP(servHost) == "none"} { - set sockServ "" + set sockServ "" } else { - 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 \ - [list sockReadable $sockClnt $sockServ client] + [list sockReadable $sockClnt $sockServ client] ;# Configure connection to the server if {[string length $sockServ]} { - 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] } } ##+########################################################################## @@ -1455,20 +1454,20 @@ proc stateRestore {} { } switch $::tcl_platform(platform) "macintosh" { - set stateFile [file join $env(PREF_FOLDER) "SockSpy Preferences"] + set stateFile [file join $env(PREF_FOLDER) "SockSpy Preferences"] } "windows" { - set stateFile [file join $env(HOME) "sockspy.cfg"] + set stateFile [file join $env(HOME) "sockspy.cfg"] } "unix" { - 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] + } } # complain only if it exists and we fail to read it successsfully if {[file exists $stateFile]} { - uplevel #0 [list source $stateFile] + uplevel #0 [list source $stateFile] } set state(stateFile) $stateFile @@ -1476,7 +1475,7 @@ proc stateRestore {} { if {$state(proxy) eq "1"} {set state(proxy) "http"} foreach v $::saveList { - trace variable $v w stateSave + trace variable $v w stateSave } }