+43
-3
@@ -2,11 +2,11 @@ package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/resp"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -14,9 +14,36 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type SubScenarioResp struct {
|
||||
ResponseData SubScenarioData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type SubScenarioData struct {
|
||||
SubscenarioID int `json:"subscenario_id"`
|
||||
ScenarioAdjustment int `json:"scenario_adjustment"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
type SubScenarioReq struct {
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
TimeStamp int `json:"timeStamp"`
|
||||
SubscenarioID int `json:"subscenario_id"`
|
||||
Mgd int `json:"mgd"`
|
||||
CommandNum string `json:"commandNum"`
|
||||
}
|
||||
|
||||
func SubScenarioStartupHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
startReq := SubScenarioReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
@@ -46,7 +73,20 @@ func SubScenarioStartupHandler(ctx *gin.Context) {
|
||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
|
||||
// fmt.Println(newAuthorizeStr)
|
||||
|
||||
xms := encrypt.RSA_Sign_SHA1([]byte(resp.ScenarioStartup), "privatekey.pem")
|
||||
startResp := SubScenarioResp{
|
||||
ResponseData: SubScenarioData{
|
||||
SubscenarioID: startReq.SubscenarioID,
|
||||
ScenarioAdjustment: 50,
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
},
|
||||
ReleaseInfo: []interface{}{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(startResp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
|
||||
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
|
||||
@@ -54,7 +94,7 @@ func SubScenarioStartupHandler(ctx *gin.Context) {
|
||||
ctx.Header("authorize", newAuthorizeStr)
|
||||
ctx.Header("X-Message-Sign", xms64)
|
||||
|
||||
ctx.String(http.StatusOK, resp.SubScenarioStartup)
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func SubScenarioRewardHandler(ctx *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user