Skip to content
Open
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
6 changes: 4 additions & 2 deletions proxy/flow_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class FlowStack:
"""FlowStack class."""

stack = {}
cookies = []

def __init__(self, max_size: int = 1024) -> None:
"""Construct a new FlowStack."""
Expand All @@ -85,6 +86,7 @@ def set_flow(
flow = Flow(
cookie, direction_allowed, transport_allowed, application_allowed, direction
)
self.cookies.append(cookie)
else:
if direction_allowed is not None:
flow.direction_allowed = direction_allowed
Expand All @@ -107,6 +109,6 @@ def get_flow(self, cookie: bytes) -> Flow:
return None

def trim_stack(self) -> None:
"""Drop the oldest flows to resize the stack to max size."""
"""Drop the oldest flow to resize the stack to max size."""
if len(self.stack) > self.max_size:
self.stack = self.stack[-self.max_size:]
self.stack.pop(self.cookies.pop(0))