Skip to content
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
8 changes: 4 additions & 4 deletions proxy/core/threadless.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
:license: BSD, see LICENSE for more details.
"""
import os
import uuid
import socket
import logging
import asyncio
Expand All @@ -21,6 +20,7 @@

from abc import ABC, abstractmethod
from typing import Dict, Optional, Tuple, List, Union, Generator, Any, Type
from uuid import uuid4, UUID

from .connection import TcpClientConnection
from .event import EventQueue, eventNames
Expand All @@ -41,11 +41,11 @@ def __init__(
client: TcpClientConnection,
flags: Optional[Flags],
event_queue: Optional[EventQueue] = None,
uid: Optional[str] = None) -> None:
uid: Optional[UUID] = None) -> None:
self.client = client
self.flags = flags if flags else Flags()
self.event_queue = event_queue
self.uid: str = uid if uid is not None else uuid.uuid4().hex
self.uid: UUID = uid if uid is not None else uuid4()

@abstractmethod
def initialize(self) -> None:
Expand Down Expand Up @@ -80,7 +80,7 @@ def publish_event(
return
assert self.event_queue
self.event_queue.publish(
self.uid,
self.uid.hex,
event_name,
event_payload,
publisher_id
Expand Down
8 changes: 4 additions & 4 deletions proxy/http/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
from abc import ABC, abstractmethod
from typing import Tuple, List, Union, Optional, Generator, Dict

from uuid import UUID
from .parser import HttpParser, httpParserStates, httpParserTypes
from .exception import HttpProtocolException

Expand Down Expand Up @@ -54,12 +54,12 @@ class HttpProtocolHandlerPlugin(ABC):

def __init__(
self,
uid: str,
uid: UUID,
flags: Flags,
client: TcpClientConnection,
request: HttpParser,
event_queue: EventQueue):
self.uid: str = uid
self.uid: UUID = uid
self.flags: Flags = flags
self.client: TcpClientConnection = client
self.request: HttpParser = request
Expand Down Expand Up @@ -116,7 +116,7 @@ class HttpProtocolHandler(ThreadlessWork):
def __init__(self, client: TcpClientConnection,
flags: Optional[Flags] = None,
event_queue: Optional[EventQueue] = None,
uid: Optional[str] = None):
uid: Optional[UUID] = None):
super().__init__(client, flags, event_queue, uid)

self.start_time: float = time.time()
Expand Down
4 changes: 2 additions & 2 deletions proxy/http/proxy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
from abc import ABC, abstractmethod
from typing import Optional

from uuid import UUID
from ..parser import HttpParser

from ...common.flags import Flags
Expand All @@ -26,7 +26,7 @@ class HttpProxyBasePlugin(ABC):

def __init__(
self,
uid: str,
uid: UUID,
flags: Flags,
client: TcpClientConnection,
event_queue: EventQueue) -> None:
Expand Down
4 changes: 2 additions & 2 deletions proxy/http/proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def generate_upstream_certificate(
stderr=subprocess.PIPE)
sign_cert = subprocess.Popen(
['openssl', 'x509', '-req', '-days', '365', '-CA', self.flags.ca_cert_file, '-CAkey',
self.flags.ca_key_file, '-set_serial', str(int(time.time())), '-out', cert_file_path],
self.flags.ca_key_file, '-set_serial', str(self.uid.int), '-out', cert_file_path],
stdin=gen_cert.stdout,
stderr=subprocess.PIPE)
# TODO: Ensure sign_cert success.
Expand Down Expand Up @@ -437,7 +437,7 @@ def emit_request_complete(self) -> None:
assert self.request.path
assert self.request.port
self.event_queue.publish(
request_id=self.uid,
request_id=self.uid.hex,
event_name=eventNames.REQUEST_COMPLETE,
event_payload={
'url': text_(self.request.path)
Expand Down
4 changes: 2 additions & 2 deletions proxy/http/server/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
from abc import ABC, abstractmethod
from typing import List, Tuple

from uuid import UUID
from ..websocket import WebsocketFrame
from ..parser import HttpParser

Expand All @@ -24,7 +24,7 @@ class HttpWebServerBasePlugin(ABC):

def __init__(
self,
uid: str,
uid: UUID,
flags: Flags,
client: TcpClientConnection,
event_queue: EventQueue):
Expand Down
4 changes: 2 additions & 2 deletions proxy/plugin/cache/store/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"""
from abc import ABC, abstractmethod
from typing import Optional

from uuid import UUID
from ....http.parser import HttpParser


class CacheStore(ABC):

def __init__(self, uid: str) -> None:
def __init__(self, uid: UUID) -> None:
self.uid = uid

@abstractmethod
Expand Down
5 changes: 3 additions & 2 deletions proxy/plugin/cache/store/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import logging
import os
from typing import Optional, BinaryIO
from uuid import UUID

from ....common.utils import text_
from ....http.parser import HttpParser
Expand All @@ -22,7 +23,7 @@

class OnDiskCacheStore(CacheStore):

def __init__(self, uid: str, cache_dir: str) -> None:
def __init__(self, uid: UUID, cache_dir: str) -> None:
super().__init__(uid)
self.cache_dir = cache_dir
self.cache_file_path: Optional[str] = None
Expand All @@ -31,7 +32,7 @@ def __init__(self, uid: str, cache_dir: str) -> None:
def open(self, request: HttpParser) -> None:
self.cache_file_path = os.path.join(
self.cache_dir,
'%s-%s.txt' % (text_(request.host), self.uid))
'%s-%s.txt' % (text_(request.host), self.uid.hex))
self.cache_file = open(self.cache_file_path, "wb")

def cache_request(self, request: HttpParser) -> Optional[HttpParser]:
Expand Down