mirror of
https://github.com/drmext/MonkeyBusiness.git
synced 2024-11-23 22:51:03 +01:00
Maintenance
This commit is contained in:
parent
586b4e71a0
commit
5af8d89ac7
@ -26,23 +26,8 @@ for module_path in [
|
||||
router = APIRouter(tags=["slashless_forwarder"])
|
||||
|
||||
|
||||
@router.post("/core_fwdr")
|
||||
async def forward_core(
|
||||
request: Request,
|
||||
f: Optional[str] = None,
|
||||
module: Optional[str] = None,
|
||||
method: Optional[str] = None,
|
||||
):
|
||||
if f != None:
|
||||
module, method = f.split(".")
|
||||
|
||||
find_response = globals()[f"{module}_{method}"]
|
||||
|
||||
return await find_response(request)
|
||||
|
||||
|
||||
@router.post("/fwdr")
|
||||
async def forward_game(
|
||||
async def forward_slashless(
|
||||
request: Request,
|
||||
model: Optional[str] = None,
|
||||
f: Optional[str] = None,
|
||||
@ -52,30 +37,30 @@ async def forward_game(
|
||||
if f != None:
|
||||
module, method = f.split(".")
|
||||
|
||||
game_code = model.split(":")[0]
|
||||
|
||||
# TODO: check for more edge cases
|
||||
try:
|
||||
if game_code == "MDX" and module == "eventlog" or module == "eventlog_2":
|
||||
find_response = globals()[f"ddr_{module}_{method}"]
|
||||
elif game_code == "REC":
|
||||
find_response = globals()[f"drs_{module}_{method}"]
|
||||
elif game_code == "KFC" and module == "eventlog":
|
||||
find_response = globals()[f"sdvx_{module}_{method}"]
|
||||
elif game_code == "M32":
|
||||
if module == "lobby":
|
||||
find_response = globals()[f"gitadora_{module}_{method}"]
|
||||
else:
|
||||
gd_module = module.split("_")
|
||||
find_response = globals()[f"gitadora_{gd_module[-1]}_{method}"]
|
||||
return await find_response(gd_module[0], request)
|
||||
else:
|
||||
find_response = globals()[f"{module}_{method}".lower()]
|
||||
find_response = globals()[f"{module}_{method}".lower()]
|
||||
return await find_response(request)
|
||||
except KeyError:
|
||||
print("Try URL Slash 1 (On) if this game is supported.")
|
||||
return Response(status_code=404)
|
||||
|
||||
return await find_response(request)
|
||||
try:
|
||||
game_code = model.split(":")[0]
|
||||
# TODO: check for more edge cases
|
||||
if game_code == "MDX" and module == "eventlog" or module == "eventlog_2":
|
||||
find_response = globals()[f"ddr_{module}_{method}"]
|
||||
elif game_code == "REC":
|
||||
find_response = globals()[f"drs_{module}_{method}"]
|
||||
elif game_code == "KFC" and module == "eventlog":
|
||||
find_response = globals()[f"sdvx_{module}_{method}"]
|
||||
elif game_code == "M32":
|
||||
if module == "lobby":
|
||||
find_response = globals()[f"gitadora_{module}_{method}"]
|
||||
else:
|
||||
gd_module = module.split("_")
|
||||
find_response = globals()[f"gitadora_{gd_module[-1]}_{method}"]
|
||||
return await find_response(gd_module[0], request)
|
||||
return await find_response(request)
|
||||
except (KeyError, UnboundLocalError):
|
||||
print("Try URL Slash 1 (On) if this game is supported.")
|
||||
return Response(status_code=404)
|
||||
|
||||
|
||||
routers.append(router)
|
||||
|
15
modules/core/apsmanager.py
Normal file
15
modules/core/apsmanager.py
Normal file
@ -0,0 +1,15 @@
|
||||
from fastapi import APIRouter, Request, Response
|
||||
|
||||
from core_common import core_process_request, core_prepare_response, E
|
||||
|
||||
router = APIRouter(prefix="/core", tags=["apsmanager"])
|
||||
|
||||
|
||||
@router.post("/{gameinfo}/apsmanager/getstat")
|
||||
async def apsmanager_getstat(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(E.apsmanager(expire=600))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
@ -76,11 +76,7 @@ async def cardmng_authpass(request: Request):
|
||||
async def cardmng_bindmodel(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(
|
||||
E.bindmodel(
|
||||
dataid=1,
|
||||
)
|
||||
)
|
||||
response = E.response(E.bindmodel(dataid=1))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
||||
|
25
modules/core/dlstatus.py
Normal file
25
modules/core/dlstatus.py
Normal file
@ -0,0 +1,25 @@
|
||||
from fastapi import APIRouter, Request, Response
|
||||
|
||||
from core_common import core_process_request, core_prepare_response, E
|
||||
|
||||
router = APIRouter(prefix="/core", tags=["dlstatus"])
|
||||
|
||||
|
||||
@router.post("/{gameinfo}/dlstatus/done")
|
||||
async def dlstatus_done(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(E.dlstatus(status=0))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
||||
|
||||
|
||||
@router.post("/{gameinfo}/dlstatus/progress")
|
||||
async def dlstatus_progress(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(E.dlstatus(status=0))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
@ -27,6 +27,16 @@ async def eacoin_checkin(request: Request):
|
||||
return Response(content=response_body, headers=response_headers)
|
||||
|
||||
|
||||
@router.post("/{gameinfo}/eacoin/checkout")
|
||||
async def eacoin_checkout(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(E.eacoin())
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
||||
|
||||
|
||||
@router.post("/{gameinfo}/eacoin/consume")
|
||||
async def eacoin_consume(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
25
modules/core/ins.py
Normal file
25
modules/core/ins.py
Normal file
@ -0,0 +1,25 @@
|
||||
from fastapi import APIRouter, Request, Response
|
||||
|
||||
from core_common import core_process_request, core_prepare_response, E
|
||||
|
||||
router = APIRouter(prefix="/core", tags=["ins"])
|
||||
|
||||
|
||||
@router.post("/{gameinfo}/ins/netlog")
|
||||
async def ins_netlog(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(E.netlog(status=0))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
||||
|
||||
|
||||
@router.post("/{gameinfo}/ins/send")
|
||||
async def ins_send(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(E.netlog(status=0))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
@ -9,12 +9,17 @@ router = APIRouter(prefix="/core", tags=["package"])
|
||||
async def package_list(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(
|
||||
E.package(
|
||||
expire=600,
|
||||
status=0,
|
||||
)
|
||||
)
|
||||
response = E.response(E.package(expire=1200, status=0))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
||||
|
||||
|
||||
@router.post("/{gameinfo}/package/intend")
|
||||
async def package_intend(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(E.package(status=0))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
||||
|
15
modules/core/package2.py
Normal file
15
modules/core/package2.py
Normal file
@ -0,0 +1,15 @@
|
||||
from fastapi import APIRouter, Request, Response
|
||||
|
||||
from core_common import core_process_request, core_prepare_response, E
|
||||
|
||||
router = APIRouter(prefix="/core", tags=["package2"])
|
||||
|
||||
|
||||
@router.post("/{gameinfo}/package2/list")
|
||||
async def package2_list(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(E.package2(expire=1200, status=0))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
@ -9,11 +9,7 @@ router = APIRouter(prefix="/core", tags=["pcbevent"])
|
||||
async def pcbevent_put(request: Request):
|
||||
request_info = await core_process_request(request)
|
||||
|
||||
response = E.response(
|
||||
E.pcbevent(
|
||||
expire=600,
|
||||
)
|
||||
)
|
||||
response = E.response(E.pcbevent(expire=600))
|
||||
|
||||
response_body, response_headers = await core_prepare_response(request, response)
|
||||
return Response(content=response_body, headers=response_headers)
|
||||
|
@ -1,5 +1,7 @@
|
||||
import config
|
||||
|
||||
from time import time
|
||||
|
||||
from fastapi import APIRouter, Request, Response
|
||||
|
||||
from core_common import core_process_request, core_prepare_response, E
|
||||
@ -13,10 +15,12 @@ async def pcbtracker_alive(request: Request):
|
||||
|
||||
response = E.response(
|
||||
E.pcbtracker(
|
||||
status=0,
|
||||
expire=1200,
|
||||
ecenable=not config.maintenance_mode,
|
||||
eclimit=0,
|
||||
limit=0,
|
||||
time=int(time()),
|
||||
)
|
||||
)
|
||||
|
||||
|
28
pyeamu.py
28
pyeamu.py
@ -97,14 +97,15 @@ if __name__ == "__main__":
|
||||
for server_services_url in server_services_urls:
|
||||
print(f"<services>\033[92m{server_services_url}\033[0m</services>")
|
||||
print("<!-- url_slash \033[92m0\033[0m or \033[92m1\033[0m -->")
|
||||
# print('<url_slash __type="bool">\033[92m0\033[0m</url_slash>')
|
||||
# print('<url_slash __type="bool">\033[92m1\033[0m</url_slash>')
|
||||
print()
|
||||
print("\033[1mWeb Interface\033[0m:")
|
||||
if webui:
|
||||
print("\033[1mWeb Interface\033[0m:")
|
||||
for server_address in server_addresses:
|
||||
print(f"http://{server_address}/webui/")
|
||||
print()
|
||||
else:
|
||||
print("/webui missing")
|
||||
print("download it here: https://github.com/drmext/BounceTrippy/releases")
|
||||
print()
|
||||
print("\033[1mSource Repository\033[0m:")
|
||||
print("https://github.com/drmext/MonkeyBusiness")
|
||||
print()
|
||||
@ -145,20 +146,13 @@ async def services_get(
|
||||
|
||||
k = (service.tags[0] if service.tags else service.prefix).strip("/")
|
||||
if f == "services.get" or module == "services" and method == "get":
|
||||
if service.prefix == "/core":
|
||||
non_slash_prefix = "/core_fwdr"
|
||||
else:
|
||||
non_slash_prefix = "/fwdr"
|
||||
if k not in services:
|
||||
services[k] = urlunparse(
|
||||
("http", request_address, non_slash_prefix, None, None, None)
|
||||
)
|
||||
# url_slash
|
||||
# url_slash 0
|
||||
pre = "/fwdr"
|
||||
else:
|
||||
if k not in services:
|
||||
services[k] = urlunparse(
|
||||
("http", request_address, service.prefix, None, None, None)
|
||||
)
|
||||
# url_slash 1
|
||||
pre = service.prefix
|
||||
if k not in services:
|
||||
services[k] = urlunparse(("http", request_address, pre, None, None, None))
|
||||
|
||||
keepalive_params = {
|
||||
"pa": loopback,
|
||||
|
14
start.bat
14
start.bat
@ -1,32 +1,38 @@
|
||||
@echo off
|
||||
|
||||
TITLE MB
|
||||
|
||||
cd /d %~dp0
|
||||
|
||||
if exist .venv\Lib\site-packages\ujson*.pyd (
|
||||
if exist .venv\Scripts\activate.bat (
|
||||
(
|
||||
REM goto :make_venv_portable
|
||||
:start_server
|
||||
.venv\Scripts\activate.bat && python pyeamu.py
|
||||
.venv\Scripts\activate.bat
|
||||
python pyeamu.py
|
||||
)
|
||||
) else (
|
||||
(
|
||||
:create_venv
|
||||
python -m venv .venv
|
||||
.venv\Scripts\activate.bat
|
||||
pip install -U -r requirements.txt
|
||||
python -m pip install -U -r requirements.txt
|
||||
python pyeamu.py
|
||||
)
|
||||
)
|
||||
|
||||
echo:
|
||||
echo Install python with "Add python.exe to PATH" checked
|
||||
echo https://www.python.org/ftp/python/3.11.4/python-3.11.4-amd64.exe
|
||||
echo https://www.python.org/downloads/
|
||||
echo:
|
||||
echo Note: Choose the previous version if latest is 3.xx.0
|
||||
echo:
|
||||
|
||||
pause
|
||||
|
||||
goto :eof
|
||||
|
||||
REM breaks when special characters are in path
|
||||
:make_venv_portable
|
||||
set pyvenv="%~dp0.venv\pyvenv.cfg"
|
||||
set pyvenvtemp="%~dp0.venv\pyvenv.tmp"
|
||||
|
17
start.sh
17
start.sh
@ -1,18 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
if ! command -v python3.11 &> /dev/null
|
||||
ver="3.11"
|
||||
py="python$ver"
|
||||
|
||||
if ! command -v $py &> /dev/null
|
||||
then
|
||||
echo "python3.11 not found"
|
||||
echo "$py not found"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -e .venv/lib/python3.11/site-packages/ujson*.so ]
|
||||
if [ -d .venv/ ]
|
||||
then
|
||||
source .venv/bin/activate
|
||||
python pyeamu.py
|
||||
$py pyeamu.py
|
||||
else
|
||||
python3.11 -m venv .venv
|
||||
$py -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -U -r requirements.txt
|
||||
python pyeamu.py
|
||||
$py -m pip install -U -r requirements.txt
|
||||
$py pyeamu.py
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user