Skip to content

Commit

Permalink
alvistack/v10.1.6
Browse files Browse the repository at this point in the history
    git clean -xdf
    tar zcvf ../python-mitmproxy_10.1.6.orig.tar.gz --exclude=.git .
    debuild -uc -us
    cp python-mitmproxy.spec ../python-mitmproxy_10.1.6-1.spec
    cp ../python*-mitmproxy*10.1.6*.{gz,xz,spec,dsc} /osc/home\:alvistack/mitmproxy-mitmproxy-10.1.6/
    rm -rf ../*mitmproxy*10.1.6*.*

See mitmproxy#6557
See mitmproxy#6573

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
  • Loading branch information
hswong3i committed Jan 8, 2024
1 parent d79862c commit 40ff9c8
Show file tree
Hide file tree
Showing 27 changed files with 376 additions and 432 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -31,3 +31,5 @@ sslkeylogfile.log
coverage.xml
web/coverage/
.mypy_cache/

.pybuild/
6 changes: 6 additions & 0 deletions debian/.gitignore
@@ -0,0 +1,6 @@
*.substvars
*debhelper*
.debhelper
files
mitmproxy
tmp
5 changes: 5 additions & 0 deletions debian/changelog
@@ -0,0 +1,5 @@
python-mitmproxy (100:10.1.6-1) UNRELEASED; urgency=medium

* https://github.com/mitmproxy/mitmproxy/releases/tag/10.1.6

-- Wong Hoi Sing Edison <hswong3i@pantarei-design.com> Sun, 07 Jan 2024 11:07:35 +0800
54 changes: 54 additions & 0 deletions debian/control
@@ -0,0 +1,54 @@
Source: python-mitmproxy
Section: python
Priority: optional
Standards-Version: 4.5.0
Maintainer: Wong Hoi Sing Edison <hswong3i@gmail.com>
Homepage: https://github.com/mitmproxy/mitmproxy/tags
Vcs-Browser: https://github.com/alvistack/mitmproxy-mitmproxy
Vcs-Git: https://github.com/alvistack/mitmproxy-mitmproxy.git
Build-Depends:
debhelper,
debhelper-compat (= 10),
dh-python,
fdupes,
python3-dev,
python3-setuptools,

Package: mitmproxy
Architecture: all
Description: Interactive, SSL/TLS-capable intercepting proxy
mitmproxy is an interactive, SSL/TLS-capable intercepting proxy with a
console interface for HTTP/1, HTTP/2, and WebSockets.
Depends:
${misc:Depends},
${python3:Depends},
${shlibs:Depends},
python3,
python3-aioquic (>= 0.9.24),
python3-asgiref (>= 3.2.10),
python3-brotli (>= 1.0),
python3-certifi (>= 2019.9.11),
python3-cryptography (>= 38.0),
python3-flask (>= 1.1.1),
python3-h11 (>= 0.11),
python3-h2 (>= 4.1),
python3-hyperframe (>= 6.0),
python3-kaitaistruct (>= 0.10),
python3-ldap3 (>= 2.8),
python3-mitmproxy-rs (>= 0.4),
python3-msgpack (>= 1.0.0),
python3-openssl (>= 22.1),
python3-passlib (>= 1.6.5),
python3-protobuf (>= 3.14),
python3-publicsuffix2 (>= 2.20190812),
python3-pyparsing (>= 2.4.2),
python3-pyperclip (>= 1.6.0),
python3-ruamel.yaml (>= 0.16),
python3-sortedcontainers (>= 2.3),
python3-tornado (>= 6.2),
python3-typing-extensions (>= 4.3),
python3-urwid (>= 2.1.2+20230718.237d1275),
python3-wsproto (>= 1.0),
python3-zstandard (>= 0.11),
Provides:
python3-mitmproxy,
21 changes: 21 additions & 0 deletions debian/copyright
@@ -0,0 +1,21 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/

Files: debian/*
Copyright: 2024 Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
License: Apache-2.0

License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.
http://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.
The complete text of the Apache version 2.0 license
can be found in "/usr/share/common-licenses/Apache-2.0".
2 changes: 2 additions & 0 deletions debian/mitmproxy.install
@@ -0,0 +1,2 @@
usr/bin/*
usr/lib/python*/*-packages/*
4 changes: 4 additions & 0 deletions debian/mitmproxy.lintian-overrides
@@ -0,0 +1,4 @@
mitmproxy: copyright-without-copyright-notice
mitmproxy: initial-upload-closes-no-bugs
mitmproxy: no-manual-page
mitmproxy: zero-byte-file-in-doc-directory
15 changes: 15 additions & 0 deletions debian/rules
@@ -0,0 +1,15 @@
#!/usr/bin/make -f

SHELL := /bin/bash

override_dh_auto_install:
dh_auto_install --destdir=debian/tmp
find debian/tmp/usr/lib/python*/*-packages -type f -name '*.pyc' -exec rm -rf {} \;
fdupes -qnrps debian/tmp/usr/lib/python*/*-packages

override_dh_auto_test:

override_dh_auto_clean:

%:
dh $@ --buildsystem=pybuild --with python3
1 change: 1 addition & 0 deletions debian/source/format
@@ -0,0 +1 @@
3.0 (quilt)
5 changes: 5 additions & 0 deletions debian/source/lintian-overrides
@@ -0,0 +1,5 @@
python-mitmproxy source: file-without-copyright-information
python-mitmproxy source: no-debian-changes
python-mitmproxy source: source-contains-prebuilt-windows-binary
python-mitmproxy source: source-is-missing
python-mitmproxy source: source-package-encodes-python-version
5 changes: 4 additions & 1 deletion mitmproxy/addons/keepserving.py
Expand Up @@ -3,6 +3,7 @@
import asyncio

from mitmproxy import ctx
from mitmproxy.utils import asyncio_utils


class KeepServing:
Expand Down Expand Up @@ -44,4 +45,6 @@ def running(self):
ctx.options.rfile,
]
if any(opts) and not ctx.options.keepserving:
self._watch_task = asyncio.get_running_loop().create_task(self.watch())
self._watch_task = asyncio_utils.create_task(
self.watch(), name="keepserving"
)
5 changes: 4 additions & 1 deletion mitmproxy/addons/proxyserver.py
Expand Up @@ -33,6 +33,7 @@
from mitmproxy.proxy.mode_servers import ProxyConnectionHandler
from mitmproxy.proxy.mode_servers import ServerInstance
from mitmproxy.proxy.mode_servers import ServerManager
from mitmproxy.utils import asyncio_utils
from mitmproxy.utils import human
from mitmproxy.utils import signals

Expand Down Expand Up @@ -276,7 +277,9 @@ def configure(self, updated) -> None:
)

if self.is_running:
self._update_task = asyncio.create_task(self.servers.update(modes))
self._update_task = asyncio_utils.create_task(
self.servers.update(modes), name="update servers"
)

async def setup_servers(self) -> bool:
"""Setup proxy servers. This may take an indefinite amount of time to complete (e.g. on permission prompts)."""
Expand Down
4 changes: 3 additions & 1 deletion mitmproxy/addons/readfile.py
Expand Up @@ -11,6 +11,8 @@
from mitmproxy import flowfilter
from mitmproxy import io

logger = logging.getLogger(__name__)


class ReadFile:
"""
Expand Down Expand Up @@ -68,7 +70,7 @@ async def doread(self, rfile: str) -> None:
try:
await self.load_flows_from_path(rfile)
except exceptions.FlowReadException as e:
raise exceptions.OptionsError(e) from e
logger.exception(f"Failed to read {ctx.options.rfile}: {e}")
finally:
self._read_task = None

Expand Down
3 changes: 3 additions & 0 deletions mitmproxy/addons/script.py
Expand Up @@ -128,6 +128,9 @@ def loadscript(self):
ctx.master.addons.invoke_addon_sync(self.ns, hooks.RunningHook())

async def watcher(self):
# Script loading is terminally confused at the moment.
# This here is a stopgap workaround to defer loading.
await asyncio.sleep(0)
last_mtime = 0.0
while True:
try:
Expand Down
6 changes: 5 additions & 1 deletion mitmproxy/certs.py
Expand Up @@ -100,16 +100,20 @@ def issuer(self) -> list[tuple[str, str]]:

@property
def notbefore(self) -> datetime.datetime:
# TODO: Use self._cert.not_valid_before_utc once cryptography 42 hits.
# x509.Certificate.not_valid_before is a naive datetime in UTC
return self._cert.not_valid_before.replace(tzinfo=datetime.timezone.utc)

@property
def notafter(self) -> datetime.datetime:
# TODO: Use self._cert.not_valid_after_utc once cryptography 42 hits.
# x509.Certificate.not_valid_after is a naive datetime in UTC
return self._cert.not_valid_after.replace(tzinfo=datetime.timezone.utc)

def has_expired(self) -> bool:
return datetime.datetime.utcnow() > self._cert.not_valid_after
if sys.version_info < (3, 11): # pragma: no cover
return datetime.datetime.utcnow() > self._cert.not_valid_after
return datetime.datetime.now(datetime.UTC) > self.notafter

@property
def subject(self) -> list[tuple[str, str]]:
Expand Down
2 changes: 1 addition & 1 deletion mitmproxy/io/har.py
Expand Up @@ -13,7 +13,7 @@


def fix_headers(
request_headers: list[dict[str, str]] | list[tuple[str, str]]
request_headers: list[dict[str, str]] | list[tuple[str, str]],
) -> http.Headers:
"""Converts provided headers into (b"header-name", b"header-value") tuples"""
flow_headers: list[tuple[bytes, bytes]] = []
Expand Down
12 changes: 6 additions & 6 deletions mitmproxy/master.py
Expand Up @@ -4,6 +4,7 @@
from . import ctx as mitmproxy_ctx
from .addons import termlog
from .proxy.mode_specs import ReverseMode
from .utils import asyncio_utils
from mitmproxy import addonmanager
from mitmproxy import command
from mitmproxy import eventsequence
Expand Down Expand Up @@ -51,9 +52,10 @@ def __init__(
mitmproxy_ctx.options = self.options

async def run(self) -> None:
old_handler = self.event_loop.get_exception_handler()
self.event_loop.set_exception_handler(self._asyncio_exception_handler)
try:
with (
asyncio_utils.install_exception_handler(self._asyncio_exception_handler),
asyncio_utils.set_eager_task_factory(),
):
self.should_exit.clear()

if ec := self.addons.get("errorcheck"):
Expand All @@ -67,17 +69,15 @@ async def run(self) -> None:
],
return_when=asyncio.FIRST_COMPLETED,
)
await self.running()
if ec := self.addons.get("errorcheck"):
await ec.shutdown_if_errored()
ec.finish()
await self.running()
try:
await self.should_exit.wait()
finally:
# .wait might be cancelled (e.g. by sys.exit)
await self.done()
finally:
self.event_loop.set_exception_handler(old_handler)

def shutdown(self):
"""
Expand Down

0 comments on commit 40ff9c8

Please sign in to comment.