Add more apis

Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
2023-03-30 04:07:34 +08:00
parent 2e4d362ec1
commit 1bb2245c5d
8 changed files with 11282 additions and 631 deletions
+10908 -626
View File
File diff suppressed because it is too large Load Diff
+110
View File
@@ -0,0 +1,110 @@
{
"response_data": {
"clear_scenario": {
"scenario_id": 3244
},
"before_user_info": {
"level": 1028,
"exp": 28853572,
"previous_exp": 27734700,
"next_exp": 28941885,
"game_coin": 112462154,
"sns_coin": 11,
"free_sns_coin": 11,
"paid_sns_coin": 0,
"social_point": 1442340,
"unit_max": 904,
"waiting_unit_max": 700,
"current_energy": 222,
"energy_max": 417,
"training_energy": 8,
"training_energy_max": 10,
"energy_full_time": "2023-03-30 23:05:52",
"license_live_energy_recoverly_time": 60,
"friend_max": 99,
"tutorial_state": -1,
"over_max_energy": 0,
"unlock_random_live_muse": 1,
"unlock_random_live_aqours": 1
},
"after_user_info": {
"level": 1028,
"exp": 28853572,
"previous_exp": 27734700,
"next_exp": 28941885,
"game_coin": 112482154,
"sns_coin": 12,
"free_sns_coin": 12,
"paid_sns_coin": 0,
"social_point": 1442340,
"unit_max": 904,
"waiting_unit_max": 700,
"current_energy": 222,
"energy_max": 417,
"training_energy": 8,
"training_energy_max": 10,
"energy_full_time": "2023-03-30 23:05:52",
"license_live_energy_recoverly_time": 60,
"friend_max": 99,
"tutorial_state": -1,
"over_max_energy": 0,
"unlock_random_live_muse": 1,
"unlock_random_live_aqours": 1
},
"next_level_info": [
{
"level": 1028,
"from_exp": 28853572
}
],
"base_reward_info": {
"game_coin_reward_box_flag": false,
"game_coin": 20000
},
"item_reward_info": [
{
"add_type": 3001,
"reward_item_id": 4,
"item_category_id": 0,
"amount": 1,
"comment": "\u652f\u7ebf\u5267\u60c5\u5b8c\u6210\uff01",
"reward_box_flag": false
}
],
"class_system": {
"rank_info": {
"before_class_rank_id": 10,
"after_class_rank_id": 10,
"rank_up_date": "2020-02-12 11:57:15"
},
"complete_flag": false,
"is_opened": true,
"is_visible": true
},
"museum_info": {
"parameter": {
"smile": 228,
"pure": 300,
"cool": 372
},
"contents_id_list": [
1597,
1598,
1599,
1600,
1601,
1694,
1695,
1696,
1697,
1699,
1700,
1701
]
},
"server_timestamp": 1680118815,
"present_cnt": 2125
},
"release_info": [],
"status_code": 200
}
+110
View File
@@ -0,0 +1,110 @@
{
"response_data": {
"clear_subscenario": {
"subscenario_id": 3244
},
"before_user_info": {
"level": 1028,
"exp": 28853572,
"previous_exp": 27734700,
"next_exp": 28941885,
"game_coin": 112462154,
"sns_coin": 11,
"free_sns_coin": 11,
"paid_sns_coin": 0,
"social_point": 1442340,
"unit_max": 904,
"waiting_unit_max": 700,
"current_energy": 222,
"energy_max": 417,
"training_energy": 8,
"training_energy_max": 10,
"energy_full_time": "2023-03-30 23:05:52",
"license_live_energy_recoverly_time": 60,
"friend_max": 99,
"tutorial_state": -1,
"over_max_energy": 0,
"unlock_random_live_muse": 1,
"unlock_random_live_aqours": 1
},
"after_user_info": {
"level": 1028,
"exp": 28853572,
"previous_exp": 27734700,
"next_exp": 28941885,
"game_coin": 112482154,
"sns_coin": 12,
"free_sns_coin": 12,
"paid_sns_coin": 0,
"social_point": 1442340,
"unit_max": 904,
"waiting_unit_max": 700,
"current_energy": 222,
"energy_max": 417,
"training_energy": 8,
"training_energy_max": 10,
"energy_full_time": "2023-03-30 23:05:52",
"license_live_energy_recoverly_time": 60,
"friend_max": 99,
"tutorial_state": -1,
"over_max_energy": 0,
"unlock_random_live_muse": 1,
"unlock_random_live_aqours": 1
},
"next_level_info": [
{
"level": 1028,
"from_exp": 28853572
}
],
"base_reward_info": {
"game_coin_reward_box_flag": false,
"game_coin": 20000
},
"item_reward_info": [
{
"add_type": 3001,
"reward_item_id": 4,
"item_category_id": 0,
"amount": 1,
"comment": "\u652f\u7ebf\u5267\u60c5\u5b8c\u6210\uff01",
"reward_box_flag": false
}
],
"class_system": {
"rank_info": {
"before_class_rank_id": 10,
"after_class_rank_id": 10,
"rank_up_date": "2020-02-12 11:57:15"
},
"complete_flag": false,
"is_opened": true,
"is_visible": true
},
"museum_info": {
"parameter": {
"smile": 228,
"pure": 300,
"cool": 372
},
"contents_id_list": [
1597,
1598,
1599,
1600,
1601,
1694,
1695,
1696,
1697,
1699,
1700,
1701
]
},
"server_timestamp": 1680118815,
"present_cnt": 2125
},
"release_info": [],
"status_code": 200
}
+1 -2
View File
@@ -3,7 +3,6 @@ package handler
import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
@@ -144,7 +143,7 @@ func ApiHandler(ctx *gin.Context) {
}
default:
// fmt.Println("Fuck you!")
err = errors.New("invalid option")
// err = errors.New("invalid option")
}
res, err = database.LevelDb.Get([]byte(key))
+44
View File
@@ -56,3 +56,47 @@ func ScenarioStartupHandler(ctx *gin.Context) {
ctx.String(http.StatusOK, resp.ScenarioStartup)
}
func ScenarioRewardHandler(ctx *gin.Context) {
reqTime := time.Now().Unix()
authorizeStr := ctx.Request.Header["Authorize"]
authToken, err := utils.GetAuthorizeToken(authorizeStr)
if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
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)
resp := utils.ReadAllText("assets/reward.json")
xms := encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
ctx.Header("user_id", userId[0])
ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", xms64)
ctx.String(http.StatusOK, resp)
}
+102
View File
@@ -0,0 +1,102 @@
package handler
import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/resp"
"honoka-chan/utils"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func SubScenarioStartupHandler(ctx *gin.Context) {
reqTime := time.Now().Unix()
authorizeStr := ctx.Request.Header["Authorize"]
authToken, err := utils.GetAuthorizeToken(authorizeStr)
if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
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")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
ctx.Header("user_id", userId[0])
ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", xms64)
ctx.String(http.StatusOK, resp.SubScenarioStartup)
}
func SubScenarioRewardHandler(ctx *gin.Context) {
reqTime := time.Now().Unix()
authorizeStr := ctx.Request.Header["Authorize"]
authToken, err := utils.GetAuthorizeToken(authorizeStr)
if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
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)
resp := utils.ReadAllText("assets/subreward.json")
xms := encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
ctx.Header("user_id", userId[0])
ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", xms64)
ctx.String(http.StatusOK, resp)
}
+3
View File
@@ -42,6 +42,7 @@ func main() {
r.POST("/main.php/api", handler.ApiHandler)
r.POST("/main.php/announce/checkState", handler.AnnounceCheckStateHandler)
r.POST("/main.php/scenario/startup", handler.ScenarioStartupHandler)
r.POST("/main.php/scenario/reward", handler.ScenarioRewardHandler)
r.POST("/main.php/user/setNotificationToken", handler.SetNotificationTokenHandler)
r.POST("/main.php/user/changeNavi", handler.SetNotificationTokenHandler)
r.POST("/main.php/event/eventList", handler.EventListHandler)
@@ -51,6 +52,8 @@ func main() {
r.POST("/main.php/live/gameover", handler.GameOverHandler)
r.POST("/main.php/unit/setDisplayRank", handler.SetDisplayRankHandler)
r.POST("/main.php/unit/favorite", handler.SetDisplayRankHandler)
r.POST("/main.php/subscenario/startup", handler.SubScenarioStartupHandler)
r.POST("/main.php/subscenario/reward", handler.SubScenarioStartupHandler)
r.Run(":8080") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
+4 -3
View File
@@ -1,7 +1,8 @@
package resp
var (
AnnounceState = `{"response_data":{"has_unread_announce":false,"server_timestamp":1679360075},"release_info":[],"status_code":200}`
NotificationToken = `{"response_data":[],"release_info":[],"status_code":200}`
ScenarioStartup = `{"response_data":{"scenario_id":1,"scenario_adjustment":50,"server_timestamp":1678785161},"release_info":[],"status_code":200}`
AnnounceState = `{"response_data":{"has_unread_announce":false,"server_timestamp":1679360075},"release_info":[],"status_code":200}`
NotificationToken = `{"response_data":[],"release_info":[],"status_code":200}`
ScenarioStartup = `{"response_data":{"scenario_id":1,"scenario_adjustment":50,"server_timestamp":1678785161},"release_info":[],"status_code":200}`
SubScenarioStartup = `{"response_data":{"subscenario_id":3337,"scenario_adjustment":50,"server_timestamp":1680118081},"release_info":[],"status_code":200}`
)