gitscope
https://dev.kronoz.win/r/marzneshin.git
config.py · v0.3.0-alpha4
Source
1 a47eb4c Dawsh 2y ago import os
2 a47eb4c Dawsh 2y ago from decouple import config
3 a47eb4c Dawsh 2y ago from dotenv import load_dotenv
4 a47eb4c Dawsh 2y ago
5 a47eb4c Dawsh 2y ago load_dotenv()
6 a47eb4c Dawsh 2y ago
7 a47eb4c Dawsh 2y ago
8 01cdf2e Dawsh 2y ago SQLALCHEMY_DATABASE_URL = config(
9 01cdf2e Dawsh 2y ago "SQLALCHEMY_DATABASE_URL", default="sqlite:///db.sqlite3"
10 01cdf2e Dawsh 2y ago )
11 a47eb4c Dawsh 2y ago
12 a47eb4c Dawsh 2y ago
13 a47eb4c Dawsh 2y ago UVICORN_HOST = config("UVICORN_HOST", default="0.0.0.0")
14 a47eb4c Dawsh 2y ago UVICORN_PORT = config("UVICORN_PORT", cast=int, default=8000)
15 a47eb4c Dawsh 2y ago UVICORN_UDS = config("UVICORN_UDS", default=None)
16 a47eb4c Dawsh 2y ago UVICORN_SSL_CERTFILE = config("UVICORN_SSL_CERTFILE", default=None)
17 a47eb4c Dawsh 2y ago UVICORN_SSL_KEYFILE = config("UVICORN_SSL_KEYFILE", default=None)
18 a47eb4c Dawsh 2y ago
19 a47eb4c Dawsh 2y ago
20 a47eb4c Dawsh 2y ago DEBUG = config("DEBUG", default=False, cast=bool)
21 a47eb4c Dawsh 2y ago DOCS = config("DOCS", default=False, cast=bool)
22 a47eb4c Dawsh 2y ago
23 01cdf2e Dawsh 2y ago VITE_BASE_API = (
24 01cdf2e Dawsh 2y ago f"http://127.0.0.1:{UVICORN_PORT}/api/"
25 01cdf2e Dawsh 2y ago if DEBUG and config("VITE_BASE_API", default="/api/") == "/api/"
26 a47eb4c Dawsh 2y ago else config("VITE_BASE_API", default="/api/")
27 01cdf2e Dawsh 2y ago )
28 a47eb4c Dawsh 2y ago
29 01cdf2e Dawsh 2y ago XRAY_FALLBACKS_INBOUND_TAG = config(
30 01cdf2e Dawsh 2y ago "XRAY_FALLBACKS_INBOUND_TAG", cast=str, default=""
31 01cdf2e Dawsh 2y ago ) or config("XRAY_FALLBACK_INBOUND_TAG", cast=str, default="")
32 01cdf2e Dawsh 2y ago XRAY_SUBSCRIPTION_URL_PREFIX = config("XRAY_SUBSCRIPTION_URL_PREFIX", default="").strip(
33 01cdf2e Dawsh 2y ago "/"
34 a47eb4c Dawsh 2y ago )
35 a47eb4c Dawsh 2y ago
36 a47eb4c Dawsh 2y ago TELEGRAM_API_TOKEN = config("TELEGRAM_API_TOKEN", default="")
37 a47eb4c Dawsh 2y ago TELEGRAM_ADMIN_ID = config(
38 01cdf2e Dawsh 2y ago "TELEGRAM_ADMIN_ID",
39 a47eb4c Dawsh 2y ago default="",
40 01cdf2e Dawsh 2y ago cast=lambda v: [
41 01cdf2e Dawsh 2y ago int(i) for i in filter(str.isdigit, (s.strip() for s in v.split(",")))
42 01cdf2e Dawsh 2y ago ],
43 a47eb4c Dawsh 2y ago )
44 a47eb4c Dawsh 2y ago TELEGRAM_PROXY_URL = config("TELEGRAM_PROXY_URL", default="")
45 a47eb4c Dawsh 2y ago TELEGRAM_LOGGER_CHANNEL_ID = config("TELEGRAM_LOGGER_CHANNEL_ID", cast=int, default=0)
46 a47eb4c Dawsh 2y ago TELEGRAM_DEFAULT_VLESS_FLOW = config("TELEGRAM_DEFAULT_VLESS_FLOW", default="")
47 a47eb4c Dawsh 2y ago
48 01cdf2e Dawsh 2y ago JWT_ACCESS_TOKEN_EXPIRE_MINUTES = config(
49 01cdf2e Dawsh 2y ago "JWT_ACCESS_TOKEN_EXPIRE_MINUTES", cast=int, default=1440
50 01cdf2e Dawsh 2y ago )
51 a47eb4c Dawsh 2y ago
52 a47eb4c Dawsh 2y ago CUSTOM_TEMPLATES_DIRECTORY = config("CUSTOM_TEMPLATES_DIRECTORY", default=None)
53 01cdf2e Dawsh 2y ago CLASH_SUBSCRIPTION_TEMPLATE = config(
54 01cdf2e Dawsh 2y ago "CLASH_SUBSCRIPTION_TEMPLATE", default="clash/default.yml"
55 01cdf2e Dawsh 2y ago )
56 01cdf2e Dawsh 2y ago SUBSCRIPTION_PAGE_TEMPLATE = config(
57 01cdf2e Dawsh 2y ago "SUBSCRIPTION_PAGE_TEMPLATE", default="subscription/index.html"
58 01cdf2e Dawsh 2y ago )
59 a47eb4c Dawsh 2y ago HOME_PAGE_TEMPLATE = config("HOME_PAGE_TEMPLATE", default="home/index.html")
60 fcfb963 Mardin 2y ago
61 fcfb963 Mardin 2y ago SINGBOX_SUBSCRIPTION_TEMPLATE = config(
62 01cdf2e Dawsh 2y ago "SINGBOX_SUBSCRIPTION_TEMPLATE", default="singbox/default.json"
63 fcfb963 Mardin 2y ago )
64 a47eb4c Dawsh 2y ago
65 a47eb4c Dawsh 2y ago
66 a47eb4c Dawsh 2y ago # USERNAME: PASSWORD
67 01cdf2e Dawsh 2y ago SUDOERS = (
68 01cdf2e Dawsh 2y ago {config("SUDO_USERNAME"): config("SUDO_PASSWORD")}
69 01cdf2e Dawsh 2y ago if config("SUDO_USERNAME", default="") and config("SUDO_PASSWORD", default="")
70 a47eb4c Dawsh 2y ago else {}
71 01cdf2e Dawsh 2y ago )
72 a47eb4c Dawsh 2y ago
73 a47eb4c Dawsh 2y ago
74 a47eb4c Dawsh 2y ago WEBHOOK_ADDRESS = config("WEBHOOK_ADDRESS", default=None)
75 a47eb4c Dawsh 2y ago WEBHOOK_SECRET = config("WEBHOOK_SECRET", default=None)
76 a47eb4c Dawsh 2y ago
77 a47eb4c Dawsh 2y ago # recurrent notifications
78 a47eb4c Dawsh 2y ago
79 a47eb4c Dawsh 2y ago # timeout between each retry of sending a notification in seconds
80 01cdf2e Dawsh 2y ago RECURRENT_NOTIFICATIONS_TIMEOUT = config(
81 01cdf2e Dawsh 2y ago "RECURRENT_NOTIFICATIONS_TIMEOUT", default=180, cast=int
82 01cdf2e Dawsh 2y ago )
83 a47eb4c Dawsh 2y ago # how many times to try after ok response not recevied after sending a notifications
84 01cdf2e Dawsh 2y ago NUMBER_OF_RECURRENT_NOTIFICATIONS = config(
85 01cdf2e Dawsh 2y ago "NUMBER_OF_RECURRENT_NOTIFICATIONS", default=3, cast=int
86 01cdf2e Dawsh 2y ago )
87 a47eb4c Dawsh 2y ago
88 a47eb4c Dawsh 2y ago # sends a notification when the user uses this much of thier data
89 01cdf2e Dawsh 2y ago NOTIFY_REACHED_USAGE_PERCENT = config(
90 01cdf2e Dawsh 2y ago "NOTIFY_REACHED_USAGE_PERCENT", default=80, cast=int
91 01cdf2e Dawsh 2y ago )
92 a47eb4c Dawsh 2y ago
93 a47eb4c Dawsh 2y ago # sends a notification when there is n days left of their service
94 a47eb4c Dawsh 2y ago NOTIFY_DAYS_LEFT = config("NOTIFY_DAYS_LEFT", default=3, cast=int)
95 a47eb4c Dawsh 2y ago
96 01cdf2e Dawsh 2y ago DISABLE_RECORDING_NODE_USAGE = config(
97 01cdf2e Dawsh 2y ago "DISABLE_RECORDING_NODE_USAGE", cast=bool, default=False
98 01cdf2e Dawsh 2y ago )
99 a47eb4c Dawsh 2y ago
100 a47eb4c Dawsh 2y ago # headers: profile-update-interval, support-url, profile-title
101 a47eb4c Dawsh 2y ago SUB_UPDATE_INTERVAL = config("SUB_UPDATE_INTERVAL", default="12")
102 a47eb4c Dawsh 2y ago SUB_SUPPORT_URL = config("SUB_SUPPORT_URL", default="https://t.me/")
103 01cdf2e Dawsh 2y ago SUB_PROFILE_TITLE = config("SUB_PROFILE_TITLE", default="Subscription")