From: Pat Thoyts Date: Sun, 29 Nov 2009 11:32:59 +0000 (+0000) Subject: Enable optional display of client socket name. X-Git-Tag: v2.6~6 X-Git-Url: https://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;h=3b641d7ef6141d54c740bf49ae3e381b5f83a917;p=sockspy Enable optional display of client socket name. Added a view menu item to show the socket name of the client socket next to the timestamp to aid tracking pipeline responses. Signed-off-by: Pat Thoyts --- diff --git a/bin/sockspy.tcl b/bin/sockspy.tcl index 9f0aab4..94ebf47 100644 --- a/bin/sockspy.tcl +++ b/bin/sockspy.tcl @@ -79,6 +79,7 @@ array set state { autoscroll 1 autowrap 1 capture 1 + showsockname 0 msg "" fixed {} fixedbold {} @@ -106,6 +107,7 @@ set saveList { state(time) state(timeFormat) state(fontSize) + state(showsockname) extract(client) extract(server) extract(meta2) @@ -200,6 +202,8 @@ proc createMain {} { .m.view add checkbutton -label " Capture" -underline 5 \ -variable state(capture) -command ToggleCapture .m.view add separator + .m.view add checkbutton -label " Socket names" \ + -variable state(showsockname) -command togglesockname .m.view add checkbutton -label " Time" \ -variable state(time) -command redraw .m.view add command -label " Time Format ..." -command timestampWindow @@ -249,6 +253,7 @@ proc createMain {} { .out tag configure time_$t -background $colors($t) -borderwidth 1 \ -relief raised -lmargin1 5 -lmargin2 5 -font $state(fixedbold) } + .out tag configure sockname -elide 1 .out tag configure client2 -font $state(fixedbold) .out tag raise sel ;# Selection is most prominent @@ -368,6 +373,12 @@ proc redraw {} { } set state(autoscroll) $save_as } + +proc togglesockname {} { + global state + .out tag configure sockname -elide [expr {!$state(showsockname)}] +} + ##+########################################################################## # # saveOutput -- Saves the content of the output window. @@ -425,6 +436,7 @@ proc printable {s {spaces 0}} { # proc insertData {who data {time {}} {force 0}} { global state + foreach {who sockname} $who break array set prefix {meta = meta2 = client > server <} if {$time == ""} { ;# If not set, then set to now @@ -445,7 +457,9 @@ proc insertData {who data {time {}} {force 0}} { lappend tag client2 } if {$state(gui)} { - .out insert end "$timestamp" time_$tag "$line\n" $tag + .out insert end "$timestamp" time_$tag \ + "$sockname " [concat $tag sockname] \ + "$line\n" $tag } else { puts "$timestamp$prefix($who)$line" } @@ -458,7 +472,9 @@ proc insertData {who data {time {}} {force 0}} { regsub -all {([0-9a-f][0-9a-f])} $hex {\1 } hex set line [format "%-48.48s %-16.16s\n" $hex [printable $line 1]] if {$state(gui)} { - .out insert end "$timestamp" time_$who "$line" $who + .out insert end "$timestamp" time_$who \ + "$sockname " [list $who sockname] \ + "$line" $who } else { puts "$timestamp$prefix(who)$line" } @@ -593,7 +609,7 @@ proc sockReadable {fromSock toSock who} { } else { catch { puts -nonewline $toSock $data } ;# Forward if we have a socket } - insertData $who $data + insertData [list $who $fromSock] $data update idletasks } ##+##########################################################################