diff --git a/WebServer/Controllers/MuipServerRoutes.cs b/WebServer/Controllers/MuipServerRoutes.cs index 5db822a6..9df0273f 100644 --- a/WebServer/Controllers/MuipServerRoutes.cs +++ b/WebServer/Controllers/MuipServerRoutes.cs @@ -11,7 +11,6 @@ namespace EggLink.DanhengServer.WebServer.Controllers; [Route("/")] public class MuipServerRoutes { - [HttpGet("/muip/auth_admin")] [HttpPost("/muip/auth_admin")] public IActionResult AuthAdminKey([FromBody] AuthAdminKeyRequestBody req) { @@ -23,22 +22,42 @@ public class MuipServerRoutes } [HttpGet("/muip/exec_cmd")] + public IActionResult ExecuteCommandGet([FromQuery] AdminExecRequest req) + { + var resp = MuipManager.ExecuteCommand(req.SessionId, req.Command, req.TargetUid); + return new JsonResult(resp); + } + [HttpPost("/muip/exec_cmd")] - public IActionResult ExecuteCommand([FromBody] AdminExecRequest req) + public IActionResult ExecuteCommandPost([FromBody] AdminExecRequest req) { var resp = MuipManager.ExecuteCommand(req.SessionId, req.Command, req.TargetUid); return new JsonResult(resp); } [HttpGet("/muip/server_information")] - public IActionResult GetServerInformation([FromQuery] ServerInformationRequest req) + public IActionResult GetServerInformationGet([FromQuery] ServerInformationRequest req) + { + var resp = MuipManager.GetInformation(req.SessionId); + return new JsonResult(resp); + } + + [HttpPost("/muip/server_information")] + public IActionResult GetServerInformationPost([FromBody] ServerInformationRequest req) { var resp = MuipManager.GetInformation(req.SessionId); return new JsonResult(resp); } [HttpGet("/muip/player_information")] - public IActionResult GetPlayerInformation([FromQuery] PlayerInformationRequest req) + public IActionResult GetPlayerInformationGet([FromQuery] PlayerInformationRequest req) + { + var resp = MuipManager.GetPlayerInformation(req.SessionId, req.Uid); + return new JsonResult(resp); + } + + [HttpPost("/muip/player_information")] + public IActionResult GetPlayerInformationPost([FromBody] PlayerInformationRequest req) { var resp = MuipManager.GetPlayerInformation(req.SessionId, req.Uid); return new JsonResult(resp); diff --git a/docs/MuipAPI.md b/docs/MuipAPI.md new file mode 100644 index 00000000..7679a895 --- /dev/null +++ b/docs/MuipAPI.md @@ -0,0 +1,88 @@ +[EN](MuipAPI.md) | [简中](MuipAPI_zh-CN.md) | [繁中](MuipAPI_zh-TW.md) | [JP](MuipAPI_ja-JP.md) +## 💡API Help +- Since version 2.3, external APIs are supported +- For example, your Dispatch is http://127.0.0.1:8080, and the request parameters and returns are in json format +- (1) Authorization interface: http://127.0.0.1:8080/muip/auth_admin (support POST) + - -Required parameter 1: admin_key (MuipServer/AdminKey configuration in config.php) + - -Required parameter 2: key_type (type, e.g. PEM or XML) + - -Return example: + ```json + { + "code": 0, + //codeResponse: `code`: `0 -> Success` `1 -> Token incorrect or not enable` + "message": "Authorized admin key successfully!", + "data": { + "rsaPublicKey": "***", + "sessionId": "***", + "expireTimeStamp": *** + } + } + ``` +- (2)Submit command interface: http://127.0.0.1:8080/muip/exec_cmd (support POST/GET) + - -Required parameter 1: SessionId (obtained after authorization API request) + - -Required parameter 2: Command (the command to be executed is encrypted by RSA[pacs#1] under rsaPublicKey) + - -Required parameter 3: TargetUid (UID of the player executing the command) + - -Return example: + ```json + { + "code": 0, + //codeResponse: `code`: `0 -> Success` `1 -> Session expired` `2 -> session not found` `3 -> encryption error` + "message": "Success", + "data": { + "sessionId": "***", + "message": "*** //base64 + } + } + ``` +- (3)Interface to get server status: http://127.0.0.1:8080/muip/server_information (support POST/GET) + - -Required parameter 1: SessionId (obtained after authorization API request) + - -Return example: + ```json + { + "code": 0, + //codeResponse: `code`: `0 -> Success` `1 -> Session expired` `2 -> session not found` + "message": "Success", + "data": { + "onlinePlayers": [ + { + "uid": 10001, + "name": "KEVIN", + "headIconId": 208001 + }, + .... + ], + "serverTime": 1720626191, + "maxMemory": 16002.227, + "usedMemory": 7938.5547, + "programUsedMemory": 323 + } + } + ``` +- (4)Interface to get player information: http://127.0.0.1:8080/muip/player_information (support POST/GET) + - -Required parameter 1: SessionId (obtained after authorization API request) + - -Required parameter 2: Uid (player UID) + - -Return example: + ```json + { + "code": 0, + //Response: `code`: `0 -> Success` `1 -> Session expired` `2 -> player not exist` `3 -> session not found` + "message": "Success", + "data": { + "uid": 10001, + "name": "KEVIN", + "signature": "", + "headIconId": 208001, + "curPlaneId": 10001, + "curFloorId": 10001001, + "playerStatus": "Explore", + "stamina": 182, + "recoveryStamina": 4, + "assistAvatarList": Array[0], + "displayAvatarList": Array[0], + "finishedMainMissionIdList": Array[38], + "finishedSubMissionIdList": Array[273], + "acceptedMainMissionIdList": Array[67], + "acceptedSubMissionIdList": Array[169] + } + } + ``` diff --git a/docs/MuipAPI_ja-JP.md b/docs/MuipAPI_ja-JP.md new file mode 100644 index 00000000..bfe313ee --- /dev/null +++ b/docs/MuipAPI_ja-JP.md @@ -0,0 +1,86 @@ +[EN](MuipAPI.md) | [简中](MuipAPI_zh-CN.md) | [繁中](MuipAPI_zh-TW.md) | [JP](MuipAPI_ja-JP.md) + +##💡API支援です + +-バージョン2.3から、外部API呼び出しインタフェースをサポートします。 +-全体のインタフェースはDispatchインタフェースに入口を加えます。例えば、Dispatchはhttp://127.0.0.1:8080、要求パラメータとリターンはjson形式です。 +-(1)ライセンスインタフェース:http://127.0.0.1:8080/muip/auth_admin(支持ポスト/ get) +- -必須引数1:admin_key (config.phpでのMuipServer/AdminKey構成) +- -必須パラメータ2:key_type(タイプ、例えばPEM)です。 +- -リターン例です: +```json + { + "code": 0, + "message": "Authorized admin key successfully!", + "data": { + "rsaPublicKey": "***", + "sessionId": "***", + "expireTimeStamp": *** + } + } +``` +—(2)提出命令インタフェース:http://127.0.0.1:8080/muip/exec_cmd(支持ポスト/ get) +- -必伝パラメータ1:SessionId(ライセンスインターフェース要求後に取得します) +- -必須引数2:Command(実行するコマンドをrsaPublicKey[ライセンスインターフェース取得]でRSA[pacs#1]で暗号化します) +- -必伝パラメータ3:TargetUid(コマンドを実行するプレイヤーUID)です +- -リターン例です: +```json + { + "code": 0, + "message": "Success", + "data": { + "sessionId": "***", + "message": "*** //base64编码后 + } + } +``` +—(3)サーバーの状態をインタフェース:http://127.0.0.1:8080/muip/server_information(支持get)だけ +- -必伝パラメータ1:SessionId(ライセンスインターフェース要求後に取得します) +- -リターン例です: +```json + { + "code": 0, + "message": "Success", + "data": { + "onlinePlayers": [ + { + "uid": 10001, + "name": "KEVIN", + "headIconId": 208001 + }, + .... + ], + "serverTime": 1720626191, + "maxMemory": 16002.227, + "usedMemory": 7938.5547, + "programUsedMemory": 323 + } + } +``` +—(4)プレイヤー情報を盗み出すインタフェース:http://127.0.0.1:8080/muip/player_information(支持get)だけ +- -必伝パラメータ1:SessionId(ライセンスインターフェース要求後に取得します) +- -必伝パラメーター2:Uid(プレイヤーUid) +- -リターン例です: +```json + { + "code": 0, + "message": "Success", + "data": { + "uid": 10001, + "name": "KEVIN", + "signature": "", + "headIconId": 208001, + "curPlaneId": 10001, + "curFloorId": 10001001, + "playerStatus": "Explore", + "stamina": 182, + "recoveryStamina": 4, + "assistAvatarList": Array[0], + "displayAvatarList": Array[0], + "finishedMainMissionIdList": Array[38], + "finishedSubMissionIdList": Array[273], + "acceptedMainMissionIdList": Array[67], + "acceptedSubMissionIdList": Array[169] + } + } +``` diff --git a/docs/MuipAPI_zh-CN.md b/docs/MuipAPI_zh-CN.md new file mode 100644 index 00000000..ccd8e42a --- /dev/null +++ b/docs/MuipAPI_zh-CN.md @@ -0,0 +1,85 @@ +[EN](MuipAPI.md) | [简中](MuipAPI_zh-CN.md) | [繁中](MuipAPI_zh-TW.md) | [JP](MuipAPI_ja-JP.md) +## 💡API帮助 + +- 自2.3版本开始,支持外部API调用接口 +- 总接口为Dispatch接口加上入口,比如你的Dispatch为 http://127.0.0.1:8080,请求参数和返回都为json格式 +- (1)授权接口: http://127.0.0.1:8080/muip/auth_admin (支持POST) + - -必传参数1:admin_key (在config.php的MuipServer/AdminKey配置) + - -必传参数2:key_type (类型,比如PEM) + - -返回示例: + ```json + { + "code": 0, + "message": "Authorized admin key successfully!", + "data": { + "rsaPublicKey": "***", + "sessionId": "***", + "expireTimeStamp": *** + } + } + ``` +- (2)提交命令接口: http://127.0.0.1:8080/muip/exec_cmd (支持POST/GET) + - -必传参数1:SessionId (在授权接口请求后获得) + - -必传参数2:Command (需要执行的命令经过rsaPublicKey[授权接口获取]下RSA[pacs#1]加密) + - -必传参数3:TargetUid (执行命令的玩家UID) + - -返回示例: + ```json + { + "code": 0, + "message": "Success", + "data": { + "sessionId": "***", + "message": "*** //base64编码后 + } + } + ``` +- (3)获取服务器状态接口: http://127.0.0.1:8080/muip/server_information (支持POST/GET) + - -必传参数1:SessionId (在授权接口请求后获得) + - -返回示例: + ```json + { + "code": 0, + "message": "Success", + "data": { + "onlinePlayers": [ + { + "uid": 10001, + "name": "KEVIN", + "headIconId": 208001 + }, + .... + ], + "serverTime": 1720626191, + "maxMemory": 16002.227, + "usedMemory": 7938.5547, + "programUsedMemory": 323 + } + } + ``` +- (4)获取玩家信息接口: http://127.0.0.1:8080/muip/player_information (支持POST/GET) + - -必传参数1:SessionId (在授权接口请求后获得) + - -必传参数2:Uid (玩家UID) + - -返回示例: + ```json + { + "code": 0, + "message": "Success", + "data": { + "uid": 10001, + "name": "KEVIN", + "signature": "", + "headIconId": 208001, + "curPlaneId": 10001, + "curFloorId": 10001001, + "playerStatus": "Explore", + "stamina": 182, + "recoveryStamina": 4, + "assistAvatarList": Array[0], + "displayAvatarList": Array[0], + "finishedMainMissionIdList": Array[38], + "finishedSubMissionIdList": Array[273], + "acceptedMainMissionIdList": Array[67], + "acceptedSubMissionIdList": Array[169] + } + } + ``` diff --git a/docs/MuipAPI_zh-TW.md b/docs/MuipAPI_zh-TW.md new file mode 100644 index 00000000..fd134ab9 --- /dev/null +++ b/docs/MuipAPI_zh-TW.md @@ -0,0 +1,85 @@ +[EN](MuipAPI.md) | [简中](MuipAPI_zh-CN.md) | [繁中](MuipAPI_zh-TW.md) | [JP](MuipAPI_ja-JP.md) +## 💡API幫助 + +- 自2.3版本開始,支持外部API調用接口 +- 總接口為Dispatch接口加上入口,比如你的Dispatch為 http://127.0.0.1:8080 ,請求參數和返回都為json格式 +- (1)授權接口: http://127.0.0.1:8080/muip/auth_admin (支持POST) + - -必傳參數1:admin_key (在config.php的MuipServer/AdminKey配置) + - -必傳參數2:key_type (類型,比如PEM) + - -返回示例: + ```json + { + "code": 0, + "message": "Authorized admin key successfully!", + "data": { + "rsaPublicKey": "***", + "sessionId": "***", + "expireTimeStamp": *** + } + } + ``` +- (2)提交命令接口: http://127.0.0.1:8080/muip/exec_cmd (支持POST/GET) + - -必傳參數1:SessionId (在授權接口請求後獲得) + - -必傳參數2:Command (需要執行的命令經過rsaPublicKey[授權接口獲取]下RSA[pacs#1]加密) + - -必傳參數3:TargetUid (執行命令的玩家UID) + - -返回示例: + ```json + { + "code": 0, + "message": "Success", + "data": { + "sessionId": "***", + "message": "*** //base64編碼後 + } + } + ``` +- (3)獲取服務器狀態接口: http://127.0.0.1:8080/muip/server_information (支持POST/GET) + - -必傳參數1:SessionId (在授權接口請求後獲得) + - -返回示例: + ```json + { + "code": 0, + "message": "Success", + "data": { + "onlinePlayers": [ + { + "uid": 10001, + "name": "KEVIN", + "headIconId": 208001 + }, + .... + ], + "serverTime": 1720626191, + "maxMemory": 16002.227, + "usedMemory": 7938.5547, + "programUsedMemory": 323 + } + } + ``` +- (4)獲取玩家信息接口: http://127.0.0.1:8080/muip/player_information (支持POST/GET) + - -必傳參數1:SessionId (在授權接口請求後獲得) + - -必傳參數2:Uid (玩家UID) + - - -返回示例: + ```json + { + "code": 0, + "message": "Success", + "data": { + "uid": 10001, + "name": "KEVIN", + "signature": "", + "headIconId": 208001, + "curPlaneId": 10001, + "curFloorId": 10001001, + "playerStatus": "Explore", + "stamina": 182, + "recoveryStamina": 4, + "assistAvatarList": Array[0], + "displayAvatarList": Array[0], + "finishedMainMissionIdList": Array[38], + "finishedSubMissionIdList": Array[273], + "acceptedMainMissionIdList": Array[67], + "acceptedSubMissionIdList": Array[169] + } + } + ```