2023-03-28

Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
2023-03-29 00:32:42 +08:00
parent 966606afc2
commit c6eaae9ae1
7 changed files with 4821 additions and 2 deletions
+2 -2
View File
@@ -42,8 +42,8 @@
"new_achievement_cnt": 5, "new_achievement_cnt": 5,
"unaccomplished_achievement_cnt": 15, "unaccomplished_achievement_cnt": 15,
"live_daily_reward_exist": false, "live_daily_reward_exist": false,
"training_energy": 10, "training_energy": 999,
"training_energy_max": 10, "training_energy_max": 999,
"notification": { "notification": {
"push": true, "push": true,
"lp": true, "lp": true,
+5
View File
@@ -0,0 +1,5 @@
{
"response_data": [],
"release_info": [],
"status_code": 200
}
+215
View File
@@ -0,0 +1,215 @@
{
"response_data": {
"party_list": [
{
"user_info": {
"user_id": 5762285,
"name": "\u840c\u840c\u5ba1\u795e\u8005",
"level": 21
},
"center_unit_info": {
"unit_owning_user_id": 1000880096808,
"unit_id": 855,
"exp": 4394,
"next_exp": 4560,
"level": 11,
"level_limit_id": 2,
"max_level": 100,
"rank": 2,
"max_rank": 2,
"love": 20,
"max_love": 1000,
"unit_skill_level": 1,
"max_hp": 4,
"favorite_flag": false,
"display_rank": 2,
"unit_skill_exp": 0,
"unit_removable_skill_capacity": 4,
"attribute": 1,
"smile": 3540,
"cute": 2410,
"cool": 2870,
"is_love_max": false,
"is_level_max": false,
"is_rank_max": true,
"is_signed": false,
"is_skill_level_max": false,
"setting_award_id": 17,
"removable_skill_ids": []
},
"setting_award_id": 17,
"available_social_point": 10,
"friend_status": 1
},
{
"user_info": {
"user_id": 5400659,
"name": "\u9ed1\u6850-",
"level": 37
},
"center_unit_info": {
"unit_owning_user_id": 1001193273786,
"unit_id": 13,
"exp": 0,
"next_exp": 6,
"level": 1,
"level_limit_id": 0,
"max_level": 30,
"rank": 1,
"max_rank": 2,
"love": 25,
"max_love": 25,
"unit_skill_level": 1,
"max_hp": 2,
"favorite_flag": false,
"display_rank": 1,
"unit_skill_exp": 0,
"unit_removable_skill_capacity": 0,
"attribute": 1,
"smile": 1520,
"cute": 550,
"cool": 308,
"is_love_max": false,
"is_level_max": false,
"is_rank_max": false,
"is_signed": false,
"is_skill_level_max": true,
"setting_award_id": 17,
"removable_skill_ids": []
},
"setting_award_id": 17,
"available_social_point": 10,
"friend_status": 1
},
{
"user_info": {
"user_id": 7663163,
"name": "\u82b1\u82b1\u82b1\u6912",
"level": 30
},
"center_unit_info": {
"unit_owning_user_id": 1002061904425,
"unit_id": 1131,
"exp": 8400,
"next_exp": 8659,
"level": 18,
"level_limit_id": 1,
"max_level": 100,
"rank": 2,
"max_rank": 2,
"love": 1000,
"max_love": 1000,
"unit_skill_level": 1,
"max_hp": 5,
"favorite_flag": true,
"display_rank": 2,
"unit_skill_exp": 0,
"unit_removable_skill_capacity": 4,
"attribute": 3,
"smile": 3195,
"cute": 2925,
"cool": 4085,
"is_love_max": true,
"is_level_max": false,
"is_rank_max": true,
"is_signed": false,
"is_skill_level_max": false,
"setting_award_id": 17,
"removable_skill_ids": []
},
"setting_award_id": 17,
"available_social_point": 5,
"friend_status": 0
},
{
"user_info": {
"user_id": 7663313,
"name": "\u67f3\u4e95\u4e0e\u5b50",
"level": 34
},
"center_unit_info": {
"unit_owning_user_id": 1002062097329,
"unit_id": 1372,
"exp": 79700,
"next_exp": 0,
"level": 100,
"level_limit_id": 1,
"max_level": 100,
"rank": 2,
"max_rank": 2,
"love": 1000,
"max_love": 1000,
"unit_skill_level": 1,
"max_hp": 6,
"favorite_flag": true,
"display_rank": 2,
"unit_skill_exp": 0,
"unit_removable_skill_capacity": 4,
"attribute": 1,
"smile": 5370,
"cute": 4080,
"cool": 4500,
"is_love_max": true,
"is_level_max": true,
"is_rank_max": true,
"is_signed": false,
"is_skill_level_max": false,
"setting_award_id": 17,
"removable_skill_ids": [
3,
2,
1
]
},
"setting_award_id": 17,
"available_social_point": 5,
"friend_status": 0
},
{
"user_info": {
"user_id": 7663527,
"name": "\u6211\u63a8\u5c06\u519b",
"level": 15
},
"center_unit_info": {
"unit_owning_user_id": 1002062228744,
"unit_id": 1912,
"exp": 0,
"next_exp": 201,
"level": 1,
"level_limit_id": 1,
"max_level": 100,
"rank": 2,
"max_rank": 2,
"love": 444,
"max_love": 1000,
"unit_skill_level": 1,
"max_hp": 5,
"favorite_flag": false,
"display_rank": 2,
"unit_skill_exp": 0,
"unit_removable_skill_capacity": 4,
"attribute": 1,
"smile": 3870,
"cute": 3090,
"cool": 2470,
"is_love_max": false,
"is_level_max": false,
"is_rank_max": true,
"is_signed": false,
"is_skill_level_max": false,
"setting_award_id": 1,
"removable_skill_ids": []
},
"setting_award_id": 1,
"available_social_point": 5,
"friend_status": 0
}
],
"training_energy": 999,
"training_energy_max": 999,
"server_timestamp": 1679802984
},
"release_info": [],
"status_code": 200
}
+4388
View File
File diff suppressed because it is too large Load Diff
+143
View File
@@ -0,0 +1,143 @@
package handler
import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/utils"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func PartyListHandler(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/partylist.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)
}
func PlayLiveHandler(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/playsong.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)
}
func GameOverHandler(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/gameover.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
@@ -46,6 +46,9 @@ func main() {
r.POST("/main.php/user/changeNavi", handler.SetNotificationTokenHandler) r.POST("/main.php/user/changeNavi", handler.SetNotificationTokenHandler)
r.POST("/main.php/event/eventList", handler.EventListHandler) r.POST("/main.php/event/eventList", handler.EventListHandler)
r.POST("/main.php/payment/productList", handler.ProductListHandler) r.POST("/main.php/payment/productList", handler.ProductListHandler)
r.POST("/main.php/live/partyList", handler.PartyListHandler)
r.POST("/main.php/live/play", handler.PlayLiveHandler)
r.POST("/main.php/live/gameover", handler.GameOverHandler)
r.Run(":8080") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") r.Run(":8080") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
} }
+65
View File
@@ -88,3 +88,68 @@ type LiveScheduleResp struct {
CommandNum bool `json:"commandNum"` CommandNum bool `json:"commandNum"`
TimeStamp int64 `json:"timeStamp"` TimeStamp int64 `json:"timeStamp"`
} }
// Play
type RankInfo struct {
Rank int `json:"rank"`
RankMin int `json:"rank_min"`
RankMax int `json:"rank_max"`
}
type NotesList struct {
TimingSec float64 `json:"timing_sec"`
NotesAttribute int `json:"notes_attribute"`
NotesLevel int `json:"notes_level"`
Effect int `json:"effect"`
EffectValue int `json:"effect_value"`
Position int `json:"position"`
}
type LiveInfo struct {
LiveDifficultyID int `json:"live_difficulty_id"`
IsRandom bool `json:"is_random"`
AcFlag int `json:"ac_flag"`
SwingFlag int `json:"swing_flag"`
NotesList []NotesList `json:"notes_list"`
}
type PlayCostume struct {
UnitID int `json:"unit_id"`
IsRankMax bool `json:"is_rank_max"`
IsSigned bool `json:"is_signed"`
}
type UnitList struct {
Smile int `json:"smile"`
Cute int `json:"cute"`
Cool int `json:"cool"`
Costume PlayCostume `json:"costume,omitempty"`
}
type DeckInfo struct {
UnitDeckID int `json:"unit_deck_id"`
TotalSmile int `json:"total_smile"`
TotalCute int `json:"total_cute"`
TotalCool int `json:"total_cool"`
TotalHp int `json:"total_hp"`
PreparedHpDamage int `json:"prepared_hp_damage"`
UnitList []UnitList `json:"unit_list"`
}
type PlayLiveList struct {
LiveInfo LiveInfo `json:"live_info"`
DeckInfo DeckInfo `json:"deck_info"`
}
type PlayResponseData struct {
RankInfo []RankInfo `json:"rank_info"`
EnergyFullTime string `json:"energy_full_time"`
OverMaxEnergy int `json:"over_max_energy"`
AvailableLiveResume bool `json:"available_live_resume"`
LiveList []PlayLiveList `json:"live_list"`
IsMarathonEvent bool `json:"is_marathon_event"`
MarathonEventID interface{} `json:"marathon_event_id"`
NoSkill bool `json:"no_skill"`
CanActivateEffect bool `json:"can_activate_effect"`
ServerTimestamp int `json:"server_timestamp"`
}