Steve Spicklemire wrote:
Anyway... here's the patch: Comments welcome!
*** ./tcpwatch_orig.py Sat Jan 20 16:55:43 2001 --- ./tcpwatch.py Sun Jan 21 16:52:11 2001 *************** *** 130,135 **** --- 130,137 ---- pos = pos + 1 else: # Last line, may be incomplete. + line = "Partial line? " + data[oldpos:] + '\r\n' + self.watch_output(line, byClient) return data[oldpos:]
def cleanupRefs(self):
So you're saying the data still goes through, it just doesn't get displayed, right? What happens is tcpwatch receives a stream of data and immediately passes it along. It then scans the data just transferred for line feeds, calling watch_output() for each complete line it finds. At the end of a transferred block, there is often an incomplete line and in order for the little arrows to be consistent it can't display that data until it finds a line feed or the connection closes. This isn't usually a problem. In the case of HTTP connections, even keepalive connections usually close within 30 seconds. But that logic is only necessary because of the arrows. A better way to display the data would be use colors to distinguish transfer directions. And it could certainly be done IMHO. It would be the right way to solve the problem your patch is trying to solve. Perhaps next time I need TCPWatch I'll colorize it. Or maybe someone else will beat me to it. :-) BTW I tried to adapt TCPWatch for UDP and it *almost* worked... then I realized what a silly thing that was to do. In the case of UDP, it's better to just dump packets to the console, in which case kernel-level packet monitoring serves nicely and you don't have to set up a proxy connection. Shane