Fork project

This commit is contained in:
2025-09-19 15:59:08 +08:00
commit 2f921b6209
52 changed files with 4012 additions and 0 deletions

34
utils/routers/__init__.py Normal file
View File

@ -0,0 +1,34 @@
from CTFd.utils import get_config
from .frp import FrpRouter
from .trp import TrpRouter
_routers = {
'frp': FrpRouter,
'trp': TrpRouter,
}
def instanciate(cls):
return cls()
@instanciate
class Router:
_name = ''
_router = None
def __getattr__(self, name: str):
router_conftype = get_config("whale:router_type", "frp")
if Router._name != router_conftype:
Router._router = _routers[router_conftype]()
Router._name = router_conftype
return getattr(Router._router, name)
@staticmethod
def reset():
Router._name = ''
Router._router = None
__all__ = ["Router"]