[Zope-CVS] CVS: Packages/tcpwatch - launch:1.1 tcpwatch.py:1.1 tcpwatch:NONE

Shane Hathaway shane@cvs.zope.org
Sat, 2 Mar 2002 16:18:22 -0500


Update of /cvs-repository/Packages/tcpwatch
In directory cvs.zope.org:/tmp/cvs-serv25483

Added Files:
	launch tcpwatch.py 
Removed Files:
	tcpwatch 
Log Message:
Renamed tcpwatch to tcpwatch.py, added a launch script, and bumped up the version to 1.1.

=== Added File Packages/tcpwatch/launch ===
#!/usr/bin/env python

# TCPWatch launcher script.

from tcpwatch import main
import sys
main(sys.argv[1:])


=== Added File Packages/tcpwatch/tcpwatch.py === (1231/1331 lines abridged)
#!/usr/bin/env python

"""TCPWatch, a connection forwarder and HTTP proxy for monitoring connections.

Requires Python 2.1 or above.

Revision information:
$Id: tcpwatch.py,v 1.1 2002/03/02 21:18:21 shane Exp $
"""

#############################################################################
# 
# Zope Public License (ZPL) Version 2.0
# -----------------------------------------------
# 
# This software is Copyright (c) Zope Corporation (tm) and
# Contributors. All rights reserved.
# 
# This license has been certified as open source. It has also
# been designated as GPL compatible by the Free Software
# Foundation (FSF).
# 
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the
# following conditions are met:
# 
# 1. Redistributions in source code must retain the above
#    copyright notice, this list of conditions, and the following
#    disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above
#    copyright notice, this list of conditions, and the following
#    disclaimer in the documentation and/or other materials
#    provided with the distribution.
# 
# 3. The name Zope Corporation (tm) must not be used to
#    endorse or promote products derived from this software
#    without prior written permission from Zope Corporation.
# 
# 4. The right to distribute this software or to use it for
#    any purpose does not give you the right to use Servicemarks
#    (sm) or Trademarks (tm) of Zope Corporation. Use of them is
#    covered in a separate agreement (see
#    http://www.zope.com/Marks).
# 
# 5. If any files are modified, you must cause the modified
#    files to carry prominent notices stating that you changed
#    the files and the date of any change.
# 
# Disclaimer

[-=- -=- -=- 1231 lines omitted -=- -=- -=-]

        config_info_lines.extend(map(
            lambda args: 'HTTP proxy listening on %s:%d' % args, proxy_params))
        title_lst.extend(map(
            lambda args: '%s:%d -> proxy' % args, proxy_params))
    if split_http:
        config_info_lines.append('HTTP connection splitting enabled.')
    config_info = '\n'.join(config_info_lines)
    titlepart = ', '.join(title_lst)

    if obs_factory is None:
        # If no observer factory has been specified, use Tkinter.
        obs_factory = setupTk(titlepart, config_info, colorized)

    chosen_factory = obs_factory
    if split_http:
        # Put an HTTPConnectionSplitter between the events and the output.
        def _factory(fci, sub_factory=obs_factory):
            return HTTPConnectionSplitter(sub_factory, fci)
        chosen_factory = _factory
    
    services = []
    try:
        # Start forwarding services.
        for params in fwd_params:
            args = params + (chosen_factory,)
            s = ForwardingService(*args)
            services.append(s)

        # Start proxy services.
        for params in proxy_params:
            args = params + (obs_factory,)  # Don't parse HTTP twice.
            s = HTTPProxyService(*args)
            services.append(s)

        if show_config:
            print config_info

        # Run the main loop.
        try:
            asyncore.loop(timeout=1.0)
        except KeyboardInterrupt:
            print >> sys.stderr, 'TCPWatch finished.'
    finally:
        for s in services:
            s.close()


if __name__ == '__main__':
    main(sys.argv[1:])


=== Removed File Packages/tcpwatch/tcpwatch ===