-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
83bd1f2
commit 36bb3c0
Showing
7 changed files
with
381 additions
and
188 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from Modules.utils import get_documents_folder, resource_path | ||
|
||
import re | ||
from pathlib import Path | ||
from datetime import datetime | ||
|
||
USERIP_INI_SETTINGS_LIST = ["ENABLED", "COLOR", "NOTIFICATIONS", "VOICE_NOTIFICATIONS", "LOG", "PROTECTION", "PROTECTION_PROCESS_PATH", "PROTECTION_RESTART_PROCESS_PATH", "PROTECTION_SUSPEND_PROCESS_MODE"] | ||
ANSI_ESCAPE = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])") | ||
RE_MAC_ADDRESS_PATTERN = re.compile(r"^([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})$") | ||
USERIP_DATABASES_PATH = Path("UserIP Databases") | ||
SESSIONS_LOGGING_PATH = Path("Sessions Logging") / datetime.now().strftime("%Y/%m/%d") / f"{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log" | ||
USERIP_LOGGING_PATH = Path("UserIP_Logging.log") | ||
TWO_TAKE_ONE__PLUGIN__LOG_PATH = Path.home() / "AppData/Roaming/PopstarDevs/2Take1Menu/scripts/GTA_V_Session_Sniffer-plugin/log.txt" | ||
STAND__PLUGIN__LOG_PATH = Path.home() / "AppData/Roaming/Stand/Lua Scripts/GTA_V_Session_Sniffer-plugin/log.txt" | ||
CHERAX__PLUGIN__LOG_PATH = get_documents_folder() / "Cherax/Lua/GTA_V_Session_Sniffer-plugin/log.txt" | ||
TTS_PATH = resource_path(Path("TTS/")) | ||
RE_SETTINGS_INI_PARSER_PATTERN = re.compile(r"^(?![;#])(?P<key>[^=]+)=(?P<value>[^;#]+)") | ||
RE_USERIP_INI_PARSER_PATTERN = re.compile(r"^(?![;#])(?P<username>[^=]+)=(?P<ip>[^;#]+)") | ||
RE_MODMENU_LOGS_USER_PATTERN = re.compile(r"^user:(?P<username>[\w._-]{1,16}), scid:\d{1,9}, ip:(?P<ip>[\d.]+), timestamp:\d{10}$") | ||
WIRESHARK_REQUIRED_VERSION = "TShark (Wireshark) 4.2.9 (v4.2.9-0-g2acaabc9099c)." | ||
WIRESHARK_REQUIRED_DL = "https://www.wireshark.org/download/win64/" |
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,42 @@ | ||
from pathlib import Path | ||
|
||
|
||
def get_documents_folder(): | ||
"""Retrieves the Path object to the current user's \"Documents\" folder by querying the Windows registry.""" | ||
import winreg | ||
|
||
reg_key = R"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" | ||
|
||
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, reg_key) as key: | ||
documents_path, _ = winreg.QueryValueEx(key, "Personal") | ||
|
||
if not isinstance(documents_path, str): | ||
raise TypeError(f'Expected "str", got "{type(documents_path)}"') | ||
|
||
return Path(documents_path) | ||
|
||
""" NOTE: Alternative code: | ||
import os | ||
import sys | ||
from pathlib import Path | ||
# Windows - Use SHGetKnownFolderPath for Documents | ||
from win32com.shell import shell, shellcon | ||
# Get the Documents folder path | ||
documents_path = Path(shell.SHGetKnownFolderPath(shellcon.FOLDERID_Documents, 0)) | ||
# Append the desired file path | ||
log_path = documents_path / "Cherax" / "Lua" / "GTA_V_Session_Sniffer-plugin" / "log.txt" | ||
print(log_path) | ||
""" | ||
|
||
def resource_path(relative_path: Path): | ||
"""Get absolute path to resource, works for dev and for PyInstaller.""" | ||
import sys | ||
|
||
base_path = getattr(sys, "_MEIPASS", Path(__file__).resolve().parent.parent) # .parent twice because of modularizing bruh | ||
if not isinstance(base_path, Path): | ||
base_path = Path(base_path) | ||
return base_path / relative_path |
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