Put DumpMaster in its own file.
It's going to become a more important part of the mitmproxy suite now.
This commit is contained in:
parent
0188cf8a1a
commit
ba92d22e1d
|
@ -86,39 +86,3 @@ class Master:
|
|||
self.server.shutdown()
|
||||
|
||||
|
||||
class DumpMaster(Master):
|
||||
"""
|
||||
A simple master that just dumps to screen.
|
||||
"""
|
||||
def __init__(self, server, verbosity):
|
||||
self.verbosity = verbosity
|
||||
Master.__init__(self, server)
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
return Master.run(self)
|
||||
except KeyboardInterrupt:
|
||||
self.shutdown()
|
||||
|
||||
def handle_response(self, msg):
|
||||
if 0 < self.verbosity < 3:
|
||||
print >> sys.stderr, ">>",
|
||||
print >> sys.stderr, msg.request.short()
|
||||
if self.verbosity == 1:
|
||||
print >> sys.stderr, "<<",
|
||||
print >> sys.stderr, msg.short()
|
||||
elif self.verbosity == 2:
|
||||
print >> sys.stderr, "<<"
|
||||
for i in msg.assemble().splitlines():
|
||||
print >> sys.stderr, "\t", i
|
||||
print >> sys.stderr, "<<"
|
||||
elif self.verbosity == 3:
|
||||
print >> sys.stderr, ">>"
|
||||
for i in msg.request.assemble().splitlines():
|
||||
print >> sys.stderr, "\t", i
|
||||
print >> sys.stderr, ">>"
|
||||
print >> sys.stderr, "<<"
|
||||
for i in msg.assemble().splitlines():
|
||||
print >> sys.stderr, "\t", i
|
||||
print >> sys.stderr, "<<"
|
||||
msg.ack()
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import sys
|
||||
import controller
|
||||
|
||||
class DumpMaster(controller.Master):
|
||||
"""
|
||||
A simple master that just dumps to screen.
|
||||
"""
|
||||
def __init__(self, server, verbosity):
|
||||
self.verbosity = verbosity
|
||||
controller.Master.__init__(self, server)
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
return controller.Master.run(self)
|
||||
except KeyboardInterrupt:
|
||||
self.shutdown()
|
||||
|
||||
def handle_response(self, msg):
|
||||
if 0 < self.verbosity < 3:
|
||||
print >> sys.stderr, ">>",
|
||||
print >> sys.stderr, msg.request.short()
|
||||
if self.verbosity == 1:
|
||||
print >> sys.stderr, "<<",
|
||||
print >> sys.stderr, msg.short()
|
||||
elif self.verbosity == 2:
|
||||
print >> sys.stderr, "<<"
|
||||
for i in msg.assemble().splitlines():
|
||||
print >> sys.stderr, "\t", i
|
||||
print >> sys.stderr, "<<"
|
||||
elif self.verbosity == 3:
|
||||
print >> sys.stderr, ">>"
|
||||
for i in msg.request.assemble().splitlines():
|
||||
print >> sys.stderr, "\t", i
|
||||
print >> sys.stderr, ">>"
|
||||
print >> sys.stderr, "<<"
|
||||
for i in msg.assemble().splitlines():
|
||||
print >> sys.stderr, "\t", i
|
||||
print >> sys.stderr, "<<"
|
||||
msg.ack()
|
4
mitmdump
4
mitmdump
|
@ -16,7 +16,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import sys, os.path
|
||||
from libmproxy import proxy, controller, console, utils
|
||||
from libmproxy import proxy, dump, utils
|
||||
from optparse import OptionParser, OptionGroup
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ if __name__ == '__main__':
|
|||
certpath
|
||||
)
|
||||
server = proxy.ProxyServer(options.port)
|
||||
m = controller.DumpMaster(server, options.verbose)
|
||||
m = dump.DumpMaster(server, options.verbose)
|
||||
if options.verbose > 0:
|
||||
print >> sys.stderr, "Running on port %s"%options.port
|
||||
m.run()
|
||||
|
|
Loading…
Reference in New Issue