Maintenance

This commit is contained in:
drmext 2023-10-07 12:06:24 +00:00
parent 586b4e71a0
commit 5af8d89ac7
No known key found for this signature in database
GPG Key ID: F1ED48FFE79A6961
13 changed files with 161 additions and 82 deletions

View File

@ -26,23 +26,8 @@ for module_path in [
router = APIRouter(tags=["slashless_forwarder"]) 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") @router.post("/fwdr")
async def forward_game( async def forward_slashless(
request: Request, request: Request,
model: Optional[str] = None, model: Optional[str] = None,
f: Optional[str] = None, f: Optional[str] = None,
@ -52,30 +37,30 @@ async def forward_game(
if f != None: if f != None:
module, method = f.split(".") module, method = f.split(".")
game_code = model.split(":")[0]
# TODO: check for more edge cases
try: try:
if game_code == "MDX" and module == "eventlog" or module == "eventlog_2": find_response = globals()[f"{module}_{method}".lower()]
find_response = globals()[f"ddr_{module}_{method}"] return await find_response(request)
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()]
except KeyError: except KeyError:
print("Try URL Slash 1 (On) if this game is supported.") try:
return Response(status_code=404) game_code = model.split(":")[0]
# TODO: check for more edge cases
return await find_response(request) 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) routers.append(router)

View 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)

View File

@ -76,11 +76,7 @@ async def cardmng_authpass(request: Request):
async def cardmng_bindmodel(request: Request): async def cardmng_bindmodel(request: Request):
request_info = await core_process_request(request) request_info = await core_process_request(request)
response = E.response( response = E.response(E.bindmodel(dataid=1))
E.bindmodel(
dataid=1,
)
)
response_body, response_headers = await core_prepare_response(request, response) response_body, response_headers = await core_prepare_response(request, response)
return Response(content=response_body, headers=response_headers) return Response(content=response_body, headers=response_headers)

25
modules/core/dlstatus.py Normal file
View 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)

View File

@ -27,6 +27,16 @@ async def eacoin_checkin(request: Request):
return Response(content=response_body, headers=response_headers) 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") @router.post("/{gameinfo}/eacoin/consume")
async def eacoin_consume(request: Request): async def eacoin_consume(request: Request):
request_info = await core_process_request(request) request_info = await core_process_request(request)

25
modules/core/ins.py Normal file
View 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)

View File

@ -9,12 +9,17 @@ router = APIRouter(prefix="/core", tags=["package"])
async def package_list(request: Request): async def package_list(request: Request):
request_info = await core_process_request(request) request_info = await core_process_request(request)
response = E.response( response = E.response(E.package(expire=1200, status=0))
E.package(
expire=600, response_body, response_headers = await core_prepare_response(request, response)
status=0, 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) response_body, response_headers = await core_prepare_response(request, response)
return Response(content=response_body, headers=response_headers) return Response(content=response_body, headers=response_headers)

15
modules/core/package2.py Normal file
View 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)

View File

@ -9,11 +9,7 @@ router = APIRouter(prefix="/core", tags=["pcbevent"])
async def pcbevent_put(request: Request): async def pcbevent_put(request: Request):
request_info = await core_process_request(request) request_info = await core_process_request(request)
response = E.response( response = E.response(E.pcbevent(expire=600))
E.pcbevent(
expire=600,
)
)
response_body, response_headers = await core_prepare_response(request, response) response_body, response_headers = await core_prepare_response(request, response)
return Response(content=response_body, headers=response_headers) return Response(content=response_body, headers=response_headers)

View File

@ -1,5 +1,7 @@
import config import config
from time import time
from fastapi import APIRouter, Request, Response from fastapi import APIRouter, Request, Response
from core_common import core_process_request, core_prepare_response, E from core_common import core_process_request, core_prepare_response, E
@ -13,10 +15,12 @@ async def pcbtracker_alive(request: Request):
response = E.response( response = E.response(
E.pcbtracker( E.pcbtracker(
status=0,
expire=1200, expire=1200,
ecenable=not config.maintenance_mode, ecenable=not config.maintenance_mode,
eclimit=0, eclimit=0,
limit=0, limit=0,
time=int(time()),
) )
) )

View File

@ -97,14 +97,15 @@ if __name__ == "__main__":
for server_services_url in server_services_urls: for server_services_url in server_services_urls:
print(f"<services>\033[92m{server_services_url}\033[0m</services>") 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 \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()
print("\033[1mWeb Interface\033[0m:")
if webui: if webui:
print("\033[1mWeb Interface\033[0m:")
for server_address in server_addresses: for server_address in server_addresses:
print(f"http://{server_address}/webui/") 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("\033[1mSource Repository\033[0m:")
print("https://github.com/drmext/MonkeyBusiness") print("https://github.com/drmext/MonkeyBusiness")
print() print()
@ -145,20 +146,13 @@ async def services_get(
k = (service.tags[0] if service.tags else service.prefix).strip("/") k = (service.tags[0] if service.tags else service.prefix).strip("/")
if f == "services.get" or module == "services" and method == "get": if f == "services.get" or module == "services" and method == "get":
if service.prefix == "/core": # url_slash 0
non_slash_prefix = "/core_fwdr" pre = "/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
else: else:
if k not in services: # url_slash 1
services[k] = urlunparse( pre = service.prefix
("http", request_address, service.prefix, None, None, None) if k not in services:
) services[k] = urlunparse(("http", request_address, pre, None, None, None))
keepalive_params = { keepalive_params = {
"pa": loopback, "pa": loopback,

View File

@ -1,32 +1,38 @@
@echo off @echo off
TITLE MB
cd /d %~dp0 cd /d %~dp0
if exist .venv\Lib\site-packages\ujson*.pyd ( if exist .venv\Scripts\activate.bat (
( (
REM goto :make_venv_portable REM goto :make_venv_portable
:start_server :start_server
.venv\Scripts\activate.bat && python pyeamu.py .venv\Scripts\activate.bat
python pyeamu.py
) )
) else ( ) else (
( (
:create_venv :create_venv
python -m venv .venv python -m venv .venv
.venv\Scripts\activate.bat .venv\Scripts\activate.bat
pip install -U -r requirements.txt python -m pip install -U -r requirements.txt
python pyeamu.py python pyeamu.py
) )
) )
echo: echo:
echo Install python with "Add python.exe to PATH" checked 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: echo:
pause pause
goto :eof goto :eof
REM breaks when special characters are in path
:make_venv_portable :make_venv_portable
set pyvenv="%~dp0.venv\pyvenv.cfg" set pyvenv="%~dp0.venv\pyvenv.cfg"
set pyvenvtemp="%~dp0.venv\pyvenv.tmp" set pyvenvtemp="%~dp0.venv\pyvenv.tmp"

View File

@ -1,18 +1,21 @@
#!/bin/bash #!/bin/bash
if ! command -v python3.11 &> /dev/null ver="3.11"
py="python$ver"
if ! command -v $py &> /dev/null
then then
echo "python3.11 not found" echo "$py not found"
exit exit
fi fi
if [ -e .venv/lib/python3.11/site-packages/ujson*.so ] if [ -d .venv/ ]
then then
source .venv/bin/activate source .venv/bin/activate
python pyeamu.py $py pyeamu.py
else else
python3.11 -m venv .venv $py -m venv .venv
source .venv/bin/activate source .venv/bin/activate
pip install -U -r requirements.txt $py -m pip install -U -r requirements.txt
python pyeamu.py $py pyeamu.py
fi fi