|
| 1 | +""" |
| 2 | + This file is part of the GetWVKeys project (https://github.com/GetWVKeys/getwvkeys) |
| 3 | + Copyright (C) 2022-2024 Notaghost, Puyodead1 and GetWVKeys contributors |
| 4 | + |
| 5 | + This program is free software: you can redistribute it and/or modify |
| 6 | + it under the terms of the GNU Affero General Public License as published |
| 7 | + by the Free Software Foundation, version 3 of the License. |
| 8 | +
|
| 9 | + This program is distributed in the hope that it will be useful, |
| 10 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + GNU Affero General Public License for more details. |
| 13 | +
|
| 14 | + You should have received a copy of the GNU Affero General Public License |
| 15 | + along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | +""" |
| 17 | + |
| 18 | +import logging |
| 19 | +import os |
| 20 | +import pathlib |
| 21 | +import time |
| 22 | + |
| 23 | +import toml |
| 24 | + |
| 25 | +logger = logging.getLogger(__name__) |
| 26 | + |
| 27 | +IS_DEVELOPMENT = bool(os.environ.get("DEVELOPMENT", False)) |
| 28 | +IS_STAGING = bool(os.environ.get("STAGING", False)) |
| 29 | +CONFIG_FILE = "config.dev.toml" if IS_DEVELOPMENT else "config.staging.toml" if IS_STAGING else "config.toml" |
| 30 | +CONFIG = toml.load(CONFIG_FILE) |
| 31 | + |
| 32 | +SECRET_KEY = CONFIG["general"]["secret_key"] # Flask secret key |
| 33 | +# auto generate secret key if not set |
| 34 | +if not SECRET_KEY: |
| 35 | + logger.warning("No secret key found in config.toml, generating a new one.") |
| 36 | + SECRET_KEY = os.urandom(32).hex() |
| 37 | + CONFIG["general"]["secret_key"] = SECRET_KEY |
| 38 | + with open(CONFIG_FILE, "w") as f: |
| 39 | + toml.dump(CONFIG, f) |
| 40 | + |
| 41 | +OAUTH2_CLIENT_ID = CONFIG["oauth"]["client_id"] # Discord OAuth Client ID |
| 42 | +OAUTH2_CLIENT_SECRET = CONFIG["oauth"]["client_secret"] # Discord OAuth Client Secret |
| 43 | +OAUTH2_REDIRECT_URL = CONFIG["oauth"]["redirect_url"] # Discord OAuth Callback URL |
| 44 | +SQLALCHEMY_DATABASE_URI = CONFIG["general"]["database_uri"] # Database connection URI |
| 45 | +REDIS_URI = CONFIG["general"].get("redis_uri", None) # Redis connection URI |
| 46 | + |
| 47 | +API_HOST = CONFIG.get("api", {}).get("host", "0.0.0.0") |
| 48 | +API_PORT = int(CONFIG.get("api", {}).get("port", 8080)) |
| 49 | +API_URL = CONFIG.get("api", {}).get("base_url", "https://getwvkeys.cc") |
| 50 | + |
| 51 | +MAX_SESSIONS = CONFIG["general"].get("max_sessions", 60) |
| 52 | +PROXY = {} |
| 53 | +DEFAULT_CDMS = CONFIG["general"].get("default_cdms", []) # list of build infos to use in key rotation |
| 54 | +APPENDERS = [] # passwords for dumping keys, deprecated in favor of flags |
| 55 | +GUILD_ID = CONFIG["general"]["guild_id"] # Discord Guild ID |
| 56 | +VERIFIED_ROLE_ID = CONFIG["general"]["verified_role_id"] # Discord Verified role ID |
| 57 | +LOGIN_DISABLED = CONFIG["general"].get("login_disabled", False) |
| 58 | +CONSOLE_LOG_LEVEL = logging.DEBUG |
| 59 | +FILE_LOG_LEVEL = logging.DEBUG |
| 60 | +LOG_FORMAT = CONFIG["general"].get( |
| 61 | + "log_format", |
| 62 | + "[%(asctime)s] [%(name)s] [%(funcName)s:%(lineno)d] %(levelname)s: %(message)s", |
| 63 | +) |
| 64 | +LOG_DATE_FORMAT = CONFIG["general"].get("log_date_format", "%I:%M:%S") |
| 65 | +WVK_LOG_FILE_PATH = pathlib.Path(os.getcwd(), "logs", f"GWVK_{time.strftime('%Y-%m-%d')}.log") |
| 66 | +URL_BLACKLIST = CONFIG.get("url_blacklist", []) |
| 67 | +EXTERNAL_API_BUILD_INFOS = CONFIG.get("external_build_info", []) |
| 68 | +# List of CDMs that should use the blacklist, these are considered to be GetWVKeys System CDMs. |
| 69 | +SYSTEM_CDMS = CONFIG["general"].get("system_cdms", []) |
0 commit comments