Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TlsInterception] v2.4.x vs v2.3.1 differences #979

Merged
merged 4 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ htmlcov
dist
build

proxy/public
profile.svg
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ coverage:
# target: 100% # we always want 100% coverage here
paths:
- "tests/" # only include coverage in "tests/" folder
threshold: 1%
lib: # declare a new status context "lib"
paths:
- "!tests/" # remove all files in "tests/"
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
(_py_class_role, 'Work'),
(_py_class_role, 'proxy.core.acceptor.work.Work'),
(_py_class_role, 'connection.Connection'),
(_py_class_role, 'EventQueue'),
(_py_obj_role, 'proxy.core.work.threadless.T'),
(_py_obj_role, 'proxy.core.work.work.T'),
]
10 changes: 5 additions & 5 deletions proxy/core/work/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
import multiprocessing

from multiprocessing import connection

from typing import Any, Optional, List
from typing import TYPE_CHECKING, Any, Optional, List

from .remote import RemoteExecutor

from ..event import EventQueue

from ...common.flag import flags
from ...common.constants import DEFAULT_NUM_WORKERS, DEFAULT_THREADLESS

if TYPE_CHECKING:
from ..event import EventQueue

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -71,7 +71,7 @@ class ThreadlessPool:
def __init__(
self,
flags: argparse.Namespace,
event_queue: Optional[EventQueue] = None,
event_queue: Optional['EventQueue'] = None,
) -> None:
self.flags = flags
self.event_queue = event_queue
Expand Down
1 change: 0 additions & 1 deletion proxy/core/work/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import logging

from typing import Optional, Any

from multiprocessing import connection
from multiprocessing.reduction import recv_handle

Expand Down
8 changes: 5 additions & 3 deletions proxy/core/work/threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@
import socket
import argparse
import threading
from typing import Optional, Tuple

from .work import Work
from typing import TYPE_CHECKING, Optional, Tuple

from ..connection import TcpClientConnection
from ..event import EventQueue, eventNames

if TYPE_CHECKING:
from .work import Work


def start_threaded_work(
flags: argparse.Namespace,
conn: socket.socket,
addr: Optional[Tuple[str, int]],
event_queue: Optional[EventQueue] = None,
publisher_id: Optional[str] = None,
) -> Tuple[Work[TcpClientConnection], threading.Thread]:
) -> Tuple['Work[TcpClientConnection]', threading.Thread]:
"""Utility method to start a work in a new thread."""
work = flags.work_klass(
TcpClientConnection(conn, addr),
Expand Down
14 changes: 9 additions & 5 deletions proxy/core/work/threadless.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@
import multiprocessing

from abc import abstractmethod, ABC
from typing import Any, Dict, Optional, Tuple, List, Set, Generic, TypeVar, Union
from typing import TYPE_CHECKING, Dict, Optional, Tuple, List, Set, Generic, TypeVar, Union

from ...common.logger import Logger
from ...common.types import Readables, SelectableEvents, Writables
from ...common.constants import DEFAULT_INACTIVE_CONN_CLEANUP_TIMEOUT, DEFAULT_SELECTOR_SELECT_TIMEOUT
from ...common.constants import DEFAULT_WAIT_FOR_TASKS_TIMEOUT

from ..connection import TcpClientConnection, UpstreamConnectionPool
from ..event import eventNames, EventQueue
from ..event import eventNames

from .work import Work
if TYPE_CHECKING:
from typing import Any

from ..event import EventQueue
from .work import Work

T = TypeVar('T')

Expand Down Expand Up @@ -62,7 +66,7 @@ def __init__(
iid: str,
work_queue: T,
flags: argparse.Namespace,
event_queue: Optional[EventQueue] = None,
event_queue: Optional['EventQueue'] = None,
) -> None:
super().__init__()
self.iid = iid
Expand All @@ -71,7 +75,7 @@ def __init__(
self.event_queue = event_queue

self.running = multiprocessing.Event()
self.works: Dict[int, Work[Any]] = {}
self.works: Dict[int, 'Work[Any]'] = {}
self.selector: Optional[selectors.DefaultSelector] = None
# If we remove single quotes for typing hint below,
# runtime exceptions will occur for < Python 3.9.
Expand Down