All new documentation
This patch does a lot.
- Ditch sphinx in favor of hugo. This gives us complete control of the layout
and presentation of our docs. Henceforth, docs will be hosted on our website
rather than ReadTheDocs.
- Create a simple, clean doc layout and theme.
- Remove large parts of the documentaion. I've ditched anything that was a)
woefully out of date, b) too detailed, or c) too hard to maintain in the long
term.
- Huge updates to the docs themselves: completely rewrite addons documentation,
add docs for core concepts like commands and options, and revise and tweak a
lot of the existing docs.
With this patch, we're also changing the way we publish and maintain the docs.
From now on, we don't publish docs for every release. Instead, the website will
contain ONE set of docs for each major release. The online docs will be updated
if needed as minor releases are made. Docs are free to improve during minor
releases, but anything that changes behaviour sufficiently to require a doc
change warrants a new major release. This also leaves us free to progressively
update and improve docs out of step with our release cadence.
With this new scheme, I feel CI over the docs is less important. I've removed
it for now, but won't object if someone wants to add it back in.
2018-02-22 04:21:34 +00:00
|
|
|
import typing
|
|
|
|
|
|
|
|
import mitmproxy.addonmanager
|
|
|
|
import mitmproxy.connections
|
|
|
|
import mitmproxy.http
|
|
|
|
import mitmproxy.log
|
|
|
|
import mitmproxy.tcp
|
|
|
|
import mitmproxy.websocket
|
|
|
|
import mitmproxy.proxy.protocol
|
|
|
|
|
|
|
|
|
|
|
|
class Events:
|
|
|
|
# Network lifecycle
|
|
|
|
def clientconnect(self, layer: mitmproxy.proxy.protocol.Layer):
|
|
|
|
"""
|
|
|
|
A client has connected to mitmproxy. Note that a connection can
|
|
|
|
correspond to multiple HTTP requests.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def clientdisconnect(self, layer: mitmproxy.proxy.protocol.Layer):
|
|
|
|
"""
|
|
|
|
A client has disconnected from mitmproxy.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def serverconnect(self, conn: mitmproxy.connections.ServerConnection):
|
|
|
|
"""
|
|
|
|
Mitmproxy has connected to a server. Note that a connection can
|
|
|
|
correspond to multiple requests.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def serverdisconnect(self, conn: mitmproxy.connections.ServerConnection):
|
|
|
|
"""
|
|
|
|
Mitmproxy has disconnected from a server.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def next_layer(self, layer: mitmproxy.proxy.protocol.Layer):
|
|
|
|
"""
|
|
|
|
Network layers are being switched. You may change which layer will
|
|
|
|
be used by returning a new layer object from this event.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# General lifecycle
|
|
|
|
def configure(self, updated: typing.Set[str]):
|
|
|
|
"""
|
|
|
|
Called when configuration changes. The updated argument is a
|
|
|
|
set-like object containing the keys of all changed options. This
|
|
|
|
event is called during startup with all options in the updated set.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def done(self):
|
|
|
|
"""
|
2018-05-07 23:09:10 +00:00
|
|
|
Called when the addon shuts down, either by being removed from
|
|
|
|
the mitmproxy instance, or when mitmproxy itself shuts down. On
|
|
|
|
shutdown, this event is called after the event loop is
|
|
|
|
terminated, guaranteeing that it will be the final event an addon
|
|
|
|
sees. Note that log handlers are shut down at this point, so
|
|
|
|
calls to log functions will produce no output.
|
All new documentation
This patch does a lot.
- Ditch sphinx in favor of hugo. This gives us complete control of the layout
and presentation of our docs. Henceforth, docs will be hosted on our website
rather than ReadTheDocs.
- Create a simple, clean doc layout and theme.
- Remove large parts of the documentaion. I've ditched anything that was a)
woefully out of date, b) too detailed, or c) too hard to maintain in the long
term.
- Huge updates to the docs themselves: completely rewrite addons documentation,
add docs for core concepts like commands and options, and revise and tweak a
lot of the existing docs.
With this patch, we're also changing the way we publish and maintain the docs.
From now on, we don't publish docs for every release. Instead, the website will
contain ONE set of docs for each major release. The online docs will be updated
if needed as minor releases are made. Docs are free to improve during minor
releases, but anything that changes behaviour sufficiently to require a doc
change warrants a new major release. This also leaves us free to progressively
update and improve docs out of step with our release cadence.
With this new scheme, I feel CI over the docs is less important. I've removed
it for now, but won't object if someone wants to add it back in.
2018-02-22 04:21:34 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def load(self, entry: mitmproxy.addonmanager.Loader):
|
|
|
|
"""
|
|
|
|
Called when an addon is first loaded. This event receives a Loader
|
|
|
|
object, which contains methods for adding options and commands. This
|
|
|
|
method is where the addon configures itself.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def log(self, entry: mitmproxy.log.LogEntry):
|
|
|
|
"""
|
2018-02-25 02:45:11 +00:00
|
|
|
Called whenever a new log entry is created through the mitmproxy
|
All new documentation
This patch does a lot.
- Ditch sphinx in favor of hugo. This gives us complete control of the layout
and presentation of our docs. Henceforth, docs will be hosted on our website
rather than ReadTheDocs.
- Create a simple, clean doc layout and theme.
- Remove large parts of the documentaion. I've ditched anything that was a)
woefully out of date, b) too detailed, or c) too hard to maintain in the long
term.
- Huge updates to the docs themselves: completely rewrite addons documentation,
add docs for core concepts like commands and options, and revise and tweak a
lot of the existing docs.
With this patch, we're also changing the way we publish and maintain the docs.
From now on, we don't publish docs for every release. Instead, the website will
contain ONE set of docs for each major release. The online docs will be updated
if needed as minor releases are made. Docs are free to improve during minor
releases, but anything that changes behaviour sufficiently to require a doc
change warrants a new major release. This also leaves us free to progressively
update and improve docs out of step with our release cadence.
With this new scheme, I feel CI over the docs is less important. I've removed
it for now, but won't object if someone wants to add it back in.
2018-02-22 04:21:34 +00:00
|
|
|
context. Be careful not to log from this event, which will cause an
|
|
|
|
infinite loop!
|
|
|
|
"""
|
|
|
|
|
|
|
|
def running(self):
|
|
|
|
"""
|
|
|
|
Called when the proxy is completely up and running. At this point,
|
|
|
|
you can expect the proxy to be bound to a port, and all addons to be
|
|
|
|
loaded.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def update(self, flows: typing.Sequence[mitmproxy.flow.Flow]):
|
|
|
|
"""
|
|
|
|
Update is called when one or more flow objects have been modified,
|
|
|
|
usually from a different addon.
|
|
|
|
"""
|