This section describes the Chomper code base for developers interested in contributing to Chomper.
Chomper is a wrapper around a Python proxy library called mitmproxy. When the
chomper executable is called with arguments
block-time, the Python interpreter in calls
./chomper/block.py to enact a block.
./chomper/block.py first checks to see if a block is in effect by reading
- If a block is not in effect,
1. Set a new block (using
chomper.block.enact_block). 2. Create a new set of block settings (using
chomper.block.create_block_dict). 3. Schedule a task on root’s Crontab to remove the block in
block-timeminutes by calling
./chomper/reset.py. 4. Provide a message informing users that a new block has been enacted, and tell them when the block will end.
- If a block is in effect, 1. Reinstate the old block. 2. Provide a message informing users that the old block is still in effect, and tell them when the block will end.
This function enacts new blocks. It does the following:
- Remove any existing rules on iptables’ NAT chain.
- Kill any currently running mitmdump or mitmproxy processes.
- Forward all outgoing HTTP/HTTPS traffic from ports 80/443 to port 8080.
- Start a mitmdump process listening on port 8080 as a daemon inside a detached screen process.