-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
218 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = lunar-interceptor | ||
version = 0.3.1 | ||
version = 0.3.2 | ||
description = The Lunar interceptor used to manage the framwork traffic. | ||
author = Lunar | ||
author_email = [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
...tors/lunar-py-interceptor/lunar_interceptor/src/lunar_interceptor/interceptor/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
from lunar_interceptor.interceptor.interceptor import Interceptor | ||
from lunar_interceptor.interceptor.configuration import ( | ||
InterceptorConfig, | ||
ENV_LUNAR_PROXY_HOST_KEY, | ||
) | ||
|
||
__all__ = ["Interceptor"] | ||
__all__ = ["Interceptor", "InterceptorConfig", "ENV_LUNAR_PROXY_HOST_KEY"] |
48 changes: 48 additions & 0 deletions
48
...lunar-py-interceptor/lunar_interceptor/src/lunar_interceptor/interceptor/configuration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from typing import Optional | ||
from dataclasses import dataclass, field | ||
|
||
from lunar_interceptor.interceptor.hooks.const import VERSION | ||
from lunar_interceptor.interceptor.helpers import load_env_value | ||
|
||
ENV_LUNAR_PROXY_HOST_KEY = "LUNAR_PROXY_HOST" | ||
_LUNAR_TENANT_ID = "LUNAR_TENANT_ID" | ||
_ENV_LUNAR_HANDSHAKE_PORT_KEY = "LUNAR_HEALTHCHECK_PORT" | ||
_ENV_PROXY_SUPPORT_TLS_KEY = "LUNAR_PROXY_SUPPORT_TLS" | ||
_ENV_TRAFFIC_FILTER_ALLOW_LIST = "LUNAR_ALLOW_LIST" | ||
_ENV_TRAFFIC_FILTER_BLOCK_LIST = "LUNAR_BLOCK_LIST" | ||
_ENV_FAIL_SAFE_EXIT_COOLDOWN_SEC = "LUNAR_EXIT_COOLDOWN_AFTER_SEC" | ||
_ENV_FAIL_SAFE_ENTER_AFTER = "LUNAR_ENTER_COOLDOWN_AFTER_ATTEMPTS" | ||
_ENV_LUNAR_INTERCEPTOR_LOG_LEVEL = "LUNAR_INTERCEPTOR_LOG_LEVEL" | ||
|
||
|
||
@dataclass | ||
class TrafficFilterConfig: | ||
allow_list: Optional[str] = load_env_value( | ||
_ENV_TRAFFIC_FILTER_ALLOW_LIST, str, None | ||
) | ||
block_list: Optional[str] = load_env_value( | ||
_ENV_TRAFFIC_FILTER_BLOCK_LIST, str, None | ||
) | ||
|
||
|
||
@dataclass | ||
class FailSafeConfig: | ||
cooldown_time: int = load_env_value(_ENV_FAIL_SAFE_ENTER_AFTER, int, 10) | ||
max_errors: int = load_env_value(_ENV_FAIL_SAFE_EXIT_COOLDOWN_SEC, int, 5) | ||
|
||
|
||
@dataclass | ||
class ConnectionConfig: | ||
proxy_host: str = load_env_value(ENV_LUNAR_PROXY_HOST_KEY, str, "") | ||
tls_supported = load_env_value(_ENV_PROXY_SUPPORT_TLS_KEY, int, 0) | ||
tenant_id: str = load_env_value(_LUNAR_TENANT_ID, str, "unknown") | ||
handshake_port: str = load_env_value(_ENV_LUNAR_HANDSHAKE_PORT_KEY, str, "8040") | ||
|
||
|
||
@dataclass | ||
class InterceptorConfig: | ||
version: str = VERSION | ||
connection_config: ConnectionConfig = field(default_factory=ConnectionConfig) | ||
traffic_filter: TrafficFilterConfig = field(default_factory=TrafficFilterConfig) | ||
fail_safe_config: FailSafeConfig = field(default_factory=FailSafeConfig) | ||
log_level: str = load_env_value(_ENV_LUNAR_INTERCEPTOR_LOG_LEVEL, str, "INFO") |
Oops, something went wrong.