+9
-45
@@ -4,11 +4,8 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -17,39 +14,8 @@ import (
|
||||
)
|
||||
|
||||
func AlbumSeriesAllHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
var albumIds []int
|
||||
err = MainEng.Table("album_series_m").Select("album_series_id").Find(&albumIds)
|
||||
err := MainEng.Table("album_series_m").Select("album_series_id").Find(&albumIds)
|
||||
CheckErr(err)
|
||||
// fmt.Println(albumIds)
|
||||
|
||||
@@ -122,22 +88,20 @@ func AlbumSeriesAllHandler(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
resp := model.AlbumSeriesResp{
|
||||
albumResp := model.AlbumSeriesResp{
|
||||
ResponseData: albumSeriesAllRes,
|
||||
ReleaseInfo: []interface{}{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
respb, err := json.Marshal(resp)
|
||||
resp, err := json.Marshal(albumResp)
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(respb))
|
||||
|
||||
xms := encrypt.RSA_Sign_SHA1(respb, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
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.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(respb))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+10
-52
@@ -4,10 +4,8 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"honoka-chan/model"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -15,16 +13,6 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type AnnounceResp struct {
|
||||
ResponseData AnnounceData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
type AnnounceData struct {
|
||||
HasUnreadAnnounce bool `json:"has_unread_announce"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
func AnnounceIndexHandler(ctx *gin.Context) {
|
||||
ctx.HTML(http.StatusOK, "announce.tmpl", gin.H{
|
||||
"title": "Love Live! 学园偶像祭 非官方服务器",
|
||||
@@ -33,39 +21,8 @@ func AnnounceIndexHandler(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
func AnnounceCheckStateHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
announceResp := AnnounceResp{
|
||||
ResponseData: AnnounceData{
|
||||
announceResp := model.AnnounceResp{
|
||||
ResponseData: model.AnnounceRes{
|
||||
HasUnreadAnnounce: false,
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
},
|
||||
@@ -74,12 +31,13 @@ func AnnounceCheckStateHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(announceResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+43
-145
@@ -5,13 +5,12 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/tools"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -19,15 +18,11 @@ import (
|
||||
)
|
||||
|
||||
func ApiHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
// fmt.Println(ctx.PostForm("request_data"))
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
CheckErr(err)
|
||||
|
||||
var formdata []model.SifApi
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &formdata)
|
||||
err = json.Unmarshal([]byte(ctx.PostForm("request_data")), &formdata)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
@@ -35,7 +30,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
var results []interface{}
|
||||
for _, v := range formdata {
|
||||
var res []byte
|
||||
var key string
|
||||
var err error
|
||||
// fmt.Println(v)
|
||||
// fmt.Println(v.Module, v.Action)
|
||||
@@ -43,10 +37,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
switch v.Module {
|
||||
case "login":
|
||||
if v.Action == "topInfo" {
|
||||
// fmt.Println("topInfo")
|
||||
key = "login_topinfo_result"
|
||||
// key = "login_topinfo_result"
|
||||
topInfoResp := model.TopInfoResp{
|
||||
// _ = model.TopInfoResp{
|
||||
Result: model.TopInfoResult{
|
||||
FriendActionCnt: 0,
|
||||
FriendGreetCnt: 0,
|
||||
@@ -82,10 +74,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(topInfoResp)
|
||||
CheckErr(err)
|
||||
} else if v.Action == "topInfoOnce" {
|
||||
// fmt.Println("topInfoOnce")
|
||||
key = "login_topinfo_once_result"
|
||||
// key = "login_topinfo_once_result"
|
||||
topInfoOnceResp := model.TopInfoOnceResp{
|
||||
// _ = model.TopInfoOnceResp{
|
||||
Result: model.TopInfoOnceResult{
|
||||
NewAchievementCnt: 0,
|
||||
UnaccomplishedAchievementCnt: 0,
|
||||
@@ -118,8 +108,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
}
|
||||
case "live":
|
||||
if v.Action == "liveStatus" {
|
||||
// fmt.Println("liveStatus")
|
||||
key = "live_status_result"
|
||||
// key = "live_status_result"
|
||||
var liveDifficultyId int
|
||||
normalLives := []model.NormalLiveStatusList{}
|
||||
sql := `SELECT live_difficulty_id FROM normal_live_m ORDER BY live_difficulty_id ASC`
|
||||
@@ -162,7 +151,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
LiveStatusResp := model.LiveStatusResp{
|
||||
// _ = model.LiveStatusResp{
|
||||
Result: model.LiveStatusResult{
|
||||
NormalLiveStatusList: normalLives,
|
||||
SpecialLiveStatusList: specialLives,
|
||||
@@ -178,8 +166,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(LiveStatusResp)
|
||||
CheckErr(err)
|
||||
} else if v.Action == "schedule" {
|
||||
// fmt.Println("schedule")
|
||||
key = "live_list_result"
|
||||
// key = "live_list_result"
|
||||
var liveDifficultyId int
|
||||
specialLives := []model.SpecialLiveStatusList{}
|
||||
sql := `SELECT live_difficulty_id FROM special_live_m ORDER BY live_difficulty_id ASC`
|
||||
@@ -211,7 +198,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
liveListResp := model.LiveScheduleResp{
|
||||
// _ = model.LiveScheduleResp{
|
||||
Result: model.LiveScheduleResult{
|
||||
EventList: []interface{}{},
|
||||
LiveList: livesList,
|
||||
@@ -231,8 +217,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
case "unit":
|
||||
switch v.Action {
|
||||
case "unitAll":
|
||||
// fmt.Println("unitAll")
|
||||
key = "unit_list_result"
|
||||
// key = "unit_list_result"
|
||||
unitsData := []model.Active{}
|
||||
err = MainEng.Table("common_unit_m").Select("*").Find(&unitsData)
|
||||
if err != nil {
|
||||
@@ -248,7 +233,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
unitsData = append(unitsData, userUnits...)
|
||||
|
||||
unitListResp := model.UnitAllResp{
|
||||
// _ = model.UnitAllResp{
|
||||
Result: model.UnitAllResult{
|
||||
Active: unitsData,
|
||||
Waiting: []model.Waiting{},
|
||||
@@ -260,10 +244,9 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(unitListResp)
|
||||
CheckErr(err)
|
||||
case "deckInfo":
|
||||
// fmt.Println("deckInfo")
|
||||
key = "unit_deck_result"
|
||||
// key = "unit_deck_result"
|
||||
userDeck := []tools.UserDeckData{}
|
||||
err = UserEng.Table("user_deck_m").Where("user_id = ?", userId[0]).Asc("deck_id").Find(&userDeck)
|
||||
err = UserEng.Table("user_deck_m").Where("user_id = ?", userId).Asc("deck_id").Find(&userDeck)
|
||||
CheckErr(err)
|
||||
|
||||
unitDeckInfo := []model.UnitDeckInfo{}
|
||||
@@ -292,7 +275,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
unitDeckResp := model.UnitDeckInfoResp{
|
||||
// _ = model.UnitDeckInfoResp{
|
||||
Result: unitDeckInfo,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
@@ -301,10 +283,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(unitDeckResp)
|
||||
CheckErr(err)
|
||||
case "supporterAll":
|
||||
// fmt.Println("supporterAll")
|
||||
key = "unit_support_result"
|
||||
// key = "unit_support_result"
|
||||
unitSupportResp := model.UnitSupportResp{
|
||||
// _ = model.UnitSupportResp{
|
||||
Result: model.UnitSupportResult{
|
||||
UnitSupportList: []model.UnitSupportList{},
|
||||
}, // 练习道具
|
||||
@@ -315,10 +295,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(unitSupportResp)
|
||||
CheckErr(err)
|
||||
case "removableSkillInfo":
|
||||
// fmt.Println("removableSkillInfo")
|
||||
key = "owning_equip_result"
|
||||
// key = "owning_equip_result"
|
||||
rmSkillResp := model.RemovableSkillResp{
|
||||
// _ = model.RemovableSkillResp{
|
||||
Result: model.RemovableSkillResult{
|
||||
OwningInfo: []model.OwningInfo{},
|
||||
EquipmentInfo: []interface{}{},
|
||||
@@ -330,10 +308,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(rmSkillResp)
|
||||
CheckErr(err)
|
||||
case "accessoryAll":
|
||||
// fmt.Println("accessoryAll")
|
||||
key = "unit_accessory_result"
|
||||
// key = "unit_accessory_result"
|
||||
unitAccResp := model.UnitAccessoryAllResp{
|
||||
// _ = model.UnitAccessoryAllResp{
|
||||
Result: model.UnitAccessoryAllResult{
|
||||
AccessoryList: []interface{}{},
|
||||
WearingInfo: []interface{}{},
|
||||
@@ -347,10 +323,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
CheckErr(err)
|
||||
}
|
||||
case "costume":
|
||||
// fmt.Println("costumeList")
|
||||
key = "costume_list_result"
|
||||
// key = "costume_list_result"
|
||||
costumeListResp := model.CostumeListResp{
|
||||
// _ = model.CostumeListResp{
|
||||
Result: model.CostumeListResult{
|
||||
CostumeList: []model.CostumeList{},
|
||||
},
|
||||
@@ -361,8 +335,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(costumeListResp)
|
||||
CheckErr(err)
|
||||
case "album":
|
||||
// fmt.Println("albumAll")
|
||||
key = "album_unit_result"
|
||||
// key = "album_unit_result"
|
||||
albumLists := []model.AlbumResult{}
|
||||
sql := `SELECT unit_id,rarity FROM unit_m ORDER BY unit_id ASC`
|
||||
rows, err := MainEng.DB().Query(sql)
|
||||
@@ -417,7 +390,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
albumResp := model.AlbumResp{
|
||||
// _ = model.AlbumResp{
|
||||
Result: albumLists,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
@@ -426,8 +398,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(albumResp)
|
||||
CheckErr(err)
|
||||
case "scenario":
|
||||
// fmt.Println("scenarioStatus")
|
||||
key = "scenario_status_result"
|
||||
// key = "scenario_status_result"
|
||||
sql := `SELECT scenario_id FROM scenario_m ORDER BY scenario_id ASC`
|
||||
rows, err := MainEng.DB().Query(sql)
|
||||
CheckErr(err)
|
||||
@@ -443,7 +414,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
scenarioResp := model.ScenarioStatusResp{
|
||||
// _ = model.ScenarioStatusResp{
|
||||
Result: model.ScenarioStatusResult{
|
||||
ScenarioStatusList: scenarioLists,
|
||||
},
|
||||
@@ -454,8 +424,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(scenarioResp)
|
||||
CheckErr(err)
|
||||
case "subscenario":
|
||||
// fmt.Println("subscenarioStatus")
|
||||
key = "subscenario_status_result"
|
||||
// key = "subscenario_status_result"
|
||||
sql := `SELECT subscenario_id FROM subscenario_m ORDER BY subscenario_id ASC`
|
||||
rows, err := MainEng.DB().Query(sql)
|
||||
CheckErr(err)
|
||||
@@ -471,7 +440,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
subScenarioResp := model.SubscenarioStatusResp{
|
||||
// _ = model.SubscenarioStatusResp{
|
||||
Result: model.SubscenarioStatusResult{
|
||||
SubscenarioStatusList: subScenarioLists,
|
||||
UnlockedSubscenarioIds: []interface{}{},
|
||||
@@ -483,8 +451,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(subScenarioResp)
|
||||
CheckErr(err)
|
||||
case "eventscenario":
|
||||
// fmt.Println("status")
|
||||
key = "event_scenario_result"
|
||||
// key = "event_scenario_result"
|
||||
eventsList := []model.EventScenarioList{}
|
||||
sql := `SELECT event_id FROM event_scenario_m GROUP BY event_id ORDER BY event_id DESC`
|
||||
rows, err := MainEng.DB().Query(sql)
|
||||
@@ -541,7 +508,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
eventsList = append(eventsList, eventList)
|
||||
}
|
||||
eventScenarioResp := model.EventScenarioStatusResp{
|
||||
// _ = model.EventScenarioStatusResp{
|
||||
Result: model.EventScenarioStatusResult{
|
||||
EventScenarioList: eventsList, //
|
||||
},
|
||||
@@ -552,8 +518,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(eventScenarioResp)
|
||||
CheckErr(err)
|
||||
case "multiunit":
|
||||
// fmt.Println("multiunitscenarioStatus")
|
||||
key = "multi_unit_scenario_result"
|
||||
// key = "multi_unit_scenario_result"
|
||||
sql := `SELECT multi_unit_id FROM multi_unit_scenario_m GROUP BY multi_unit_id ORDER BY multi_unit_id ASC`
|
||||
rows, err := MainEng.DB().Query(sql)
|
||||
CheckErr(err)
|
||||
@@ -590,7 +555,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
unitsResp := model.MultiUnitScenarioStatusResp{
|
||||
// _ = model.MultiUnitScenarioStatusResp{
|
||||
Result: model.MultiUnitScenarioStatusResult{
|
||||
MultiUnitScenarioStatusList: multiUnitsList,
|
||||
UnlockedMultiUnitScenarioIds: []interface{}{},
|
||||
@@ -602,10 +566,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(unitsResp)
|
||||
CheckErr(err)
|
||||
case "payment":
|
||||
// fmt.Println("productList")
|
||||
key = "product_result"
|
||||
// key = "product_result"
|
||||
productResp := model.ProductListResp{
|
||||
// _ = model.ProductListResp{
|
||||
Result: model.ProductListResult{
|
||||
RestrictionInfo: model.RestrictionInfo{
|
||||
Restricted: false,
|
||||
@@ -628,10 +590,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(productResp)
|
||||
CheckErr(err)
|
||||
case "banner":
|
||||
// fmt.Println("bannerList")
|
||||
key = "banner_result"
|
||||
// key = "banner_result"
|
||||
bannerResp := model.BannerListResp{
|
||||
// _ = model.BannerListResp{
|
||||
Result: model.BannerListResult{
|
||||
TimeLimit: "2037-12-31 23:59:59",
|
||||
BannerList: []model.BannerList{
|
||||
@@ -666,10 +626,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(bannerResp)
|
||||
CheckErr(err)
|
||||
case "notice":
|
||||
// fmt.Println("noticeMarquee")
|
||||
key = "item_marquee_result"
|
||||
// key = "item_marquee_result"
|
||||
marqueeResp := model.NoticeMarqueeResp{
|
||||
// _ = model.NoticeMarqueeResp{
|
||||
Result: model.NoticeMarqueeResult{
|
||||
ItemCount: 0,
|
||||
MarqueeList: []interface{}{},
|
||||
@@ -681,10 +639,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(marqueeResp)
|
||||
CheckErr(err)
|
||||
case "user":
|
||||
// fmt.Println("getNavi")
|
||||
key = "user_intro_result"
|
||||
// key = "user_intro_result"
|
||||
userIntroResp := model.UserNaviResp{
|
||||
// _ = model.UserNaviResp{
|
||||
Result: model.UserNaviResult{
|
||||
User: model.User{
|
||||
UserID: 9999999,
|
||||
@@ -698,10 +654,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(userIntroResp)
|
||||
CheckErr(err)
|
||||
case "navigation":
|
||||
// fmt.Println("specialCutin")
|
||||
key = "special_cutin_result"
|
||||
// key = "special_cutin_result"
|
||||
cutinResp := model.SpecialCutinResp{
|
||||
// _ = model.SpecialCutinResp{
|
||||
Result: model.SpecialCutinResult{
|
||||
SpecialCutinList: []interface{}{},
|
||||
},
|
||||
@@ -712,8 +666,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(cutinResp)
|
||||
CheckErr(err)
|
||||
case "award":
|
||||
// fmt.Println("awardInfo")
|
||||
key = "award_result"
|
||||
// key = "award_result"
|
||||
sql := `SELECT award_id FROM award_m ORDER BY award_id ASC`
|
||||
rows, err := MainEng.DB().Query(sql)
|
||||
CheckErr(err)
|
||||
@@ -734,7 +687,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
awardResp := model.AwardInfoResp{
|
||||
// _ = model.AwardInfoResp{
|
||||
Result: model.AwardInfoResult{
|
||||
AwardInfo: awardsList,
|
||||
},
|
||||
@@ -745,8 +697,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(awardResp)
|
||||
CheckErr(err)
|
||||
case "background":
|
||||
// fmt.Println("backgroundInfo")
|
||||
key = "background_result"
|
||||
// key = "background_result"
|
||||
sql := `SELECT background_id FROM background_m ORDER BY background_id ASC`
|
||||
rows, err := MainEng.DB().Query(sql)
|
||||
CheckErr(err)
|
||||
@@ -767,7 +718,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
backgroundResp := model.BackgroundInfoResp{
|
||||
// _ = model.BackgroundInfoResp{
|
||||
Result: model.BackgroundInfoResult{
|
||||
BackgroundInfo: backgroundsList,
|
||||
},
|
||||
@@ -778,8 +728,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(backgroundResp)
|
||||
CheckErr(err)
|
||||
case "stamp":
|
||||
// fmt.Println("stampInfo")
|
||||
key = "stamp_result"
|
||||
// key = "stamp_result"
|
||||
stampResp := utils.ReadAllText("assets/stamp.json")
|
||||
var mStampResp interface{}
|
||||
err = json.Unmarshal([]byte(stampResp), &mStampResp)
|
||||
@@ -787,8 +736,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(mStampResp)
|
||||
CheckErr(err)
|
||||
case "exchange":
|
||||
// fmt.Println("owningPoint")
|
||||
key = "exchange_point_result"
|
||||
// key = "exchange_point_result"
|
||||
sql := `SELECT exchange_point_id FROM exchange_point_m ORDER BY exchange_point_id ASC`
|
||||
rows, err := MainEng.DB().Query(sql)
|
||||
CheckErr(err)
|
||||
@@ -804,7 +752,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
})
|
||||
}
|
||||
exPointsResp := model.ExchangePointResp{
|
||||
// _ = model.ExchangePointResp{
|
||||
Result: model.ExchangePointResult{
|
||||
ExchangePointList: exPointsList,
|
||||
},
|
||||
@@ -815,10 +762,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(exPointsResp)
|
||||
CheckErr(err)
|
||||
case "livese":
|
||||
// fmt.Println("liveseInfo")
|
||||
key = "live_se_result"
|
||||
// key = "live_se_result"
|
||||
liveSeResp := model.LiveSeInfoResp{
|
||||
// _ = model.LiveSeInfoResp{
|
||||
Result: model.LiveSeInfoResult{
|
||||
LiveSeList: []int{1, 2, 3},
|
||||
},
|
||||
@@ -829,10 +774,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(liveSeResp)
|
||||
CheckErr(err)
|
||||
case "liveicon":
|
||||
// fmt.Println("liveiconInfo")
|
||||
key = "live_icon_result"
|
||||
// key = "live_icon_result"
|
||||
liveIconResp := model.LiveIconInfoResp{
|
||||
// _ = model.LiveIconInfoResp{
|
||||
Result: model.LiveIconInfoResult{
|
||||
LiveNotesIconList: []int{1, 2, 3},
|
||||
},
|
||||
@@ -843,20 +786,16 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(liveIconResp)
|
||||
CheckErr(err)
|
||||
case "item":
|
||||
// fmt.Println("list")
|
||||
key = "item_list_result"
|
||||
// key = "item_list_result"
|
||||
itemResp := utils.ReadAllText("assets/item.json")
|
||||
// _ = utils.ReadAllText("assets/item.json")
|
||||
var mItemResp interface{}
|
||||
err = json.Unmarshal([]byte(itemResp), &mItemResp)
|
||||
CheckErr(err)
|
||||
res, err = json.Marshal(mItemResp)
|
||||
CheckErr(err)
|
||||
case "marathon":
|
||||
// fmt.Println("marathonInfo")
|
||||
key = "marathon_result"
|
||||
// key = "marathon_result"
|
||||
marathonResp := model.MarathonInfoResp{
|
||||
// _ = model.MarathonInfoResp{
|
||||
Result: []interface{}{},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
@@ -865,10 +804,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(marathonResp)
|
||||
CheckErr(err)
|
||||
case "challenge":
|
||||
// fmt.Println("challengeInfo")
|
||||
key = "challenge_result"
|
||||
// key = "challenge_result"
|
||||
challengeResp := model.ChallengeInfoResp{
|
||||
// _ = model.ChallengeInfoResp{
|
||||
Result: []interface{}{},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
@@ -877,8 +814,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(challengeResp)
|
||||
CheckErr(err)
|
||||
case "museum":
|
||||
// fmt.Println("info")
|
||||
key = "museum_result"
|
||||
// key = "museum_result"
|
||||
sql := `SELECT museum_contents_id,smile_buff,pure_buff,cool_buff FROM museum_contents_m ORDER BY museum_contents_id ASC`
|
||||
rows, err := MainEng.DB().Query(sql)
|
||||
CheckErr(err)
|
||||
@@ -914,10 +850,8 @@ func ApiHandler(ctx *gin.Context) {
|
||||
CheckErr(err)
|
||||
case "profile":
|
||||
if v.Action == "liveCnt" {
|
||||
// fmt.Println("liveCnt")
|
||||
key = "profile_livecnt_result"
|
||||
// key = "profile_livecnt_result"
|
||||
difficultyResp := tools.DifficultyResp{
|
||||
// _ = DifficultyResp{
|
||||
Result: []tools.DifficultyResult{
|
||||
{
|
||||
Difficulty: 1,
|
||||
@@ -947,14 +881,12 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(difficultyResp)
|
||||
CheckErr(err)
|
||||
} else if v.Action == "cardRanking" {
|
||||
// fmt.Println("cardRanking")
|
||||
key = "profile_card_ranking_result"
|
||||
// key = "profile_card_ranking_result"
|
||||
var result []interface{}
|
||||
love := utils.ReadAllText("assets/love.json")
|
||||
err := json.Unmarshal([]byte(love), &result)
|
||||
CheckErr(err)
|
||||
loveResp := tools.LoveResp{
|
||||
// _ = LoveResp{
|
||||
Result: result,
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
@@ -963,8 +895,7 @@ func ApiHandler(ctx *gin.Context) {
|
||||
res, err = json.Marshal(loveResp)
|
||||
CheckErr(err)
|
||||
} else if v.Action == "profileInfo" {
|
||||
// fmt.Println("profileInfo")
|
||||
key = "profile_info_result"
|
||||
// key = "profile_info_result"
|
||||
profileResp := tools.ProfileResp{
|
||||
Result: tools.ProfileResult{
|
||||
UserInfo: tools.UserInfo{
|
||||
@@ -1066,14 +997,6 @@ func ApiHandler(ctx *gin.Context) {
|
||||
CheckErr(err)
|
||||
}
|
||||
|
||||
// fmt.Println(key)
|
||||
_ = key
|
||||
|
||||
// if key != "login_topinfo_result" && key != "login_topinfo_once_result" {
|
||||
// res, err = database.LevelDb.Get([]byte(key))
|
||||
// CheckErr(err)
|
||||
// }
|
||||
|
||||
var result interface{}
|
||||
err = json.Unmarshal([]byte(res), &result)
|
||||
CheckErr(err)
|
||||
@@ -1089,38 +1012,13 @@ func ApiHandler(ctx *gin.Context) {
|
||||
}
|
||||
b, err = json.Marshal(rp)
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(b))
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
nonce := ctx.GetInt("nonce")
|
||||
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)
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(b, "privatekey.pem")))
|
||||
|
||||
xms := encrypt.RSA_Sign_SHA1(b, "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, string(b))
|
||||
}
|
||||
|
||||
+35
-186
@@ -4,10 +4,8 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -17,37 +15,6 @@ import (
|
||||
)
|
||||
|
||||
func DownloadAdditionalHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
downloadReq := model.AdditionalReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
||||
panic(err)
|
||||
@@ -78,48 +45,18 @@ func DownloadAdditionalHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(addResp)
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(resp))
|
||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
|
||||
ctx.Header("user_id", userId[0])
|
||||
ctx.Header("authorize", newAuthorizeStr)
|
||||
ctx.Header("X-Message-Sign", xms64)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func DownloadBatchHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
downloadReq := model.BatchReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
||||
panic(err)
|
||||
@@ -158,48 +95,18 @@ func DownloadBatchHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(batchResp)
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(resp))
|
||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
|
||||
ctx.Header("user_id", userId[0])
|
||||
ctx.Header("authorize", newAuthorizeStr)
|
||||
ctx.Header("X-Message-Sign", xms64)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func DownloadUpdateHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
downloadReq := model.UpdateReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
||||
panic(err)
|
||||
@@ -228,50 +135,20 @@ func DownloadUpdateHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(updateResp)
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(resp))
|
||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
|
||||
ctx.Header("user_id", userId[0])
|
||||
ctx.Header("authorize", newAuthorizeStr)
|
||||
ctx.Header("X-Message-Sign", xms64)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func DownloadUrlHandler(ctx *gin.Context) {
|
||||
// Extract SQL: SELECT CAST(pkg_type AS TEXT) || '_' || CAST(pkg_id AS TEXT) || '_' || CAST(pkg_order AS TEXT) || '.zip' AS zip_name FROM download_db ORDER BY pkg_type ASC,pkg_id ASC, pkg_order ASC;
|
||||
// Extract Cmd: cat list.txt | while read line; do; unzip -o $line; done
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
downloadReq := model.UrlReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &downloadReq); err != nil {
|
||||
panic(err)
|
||||
@@ -289,48 +166,18 @@ func DownloadUrlHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(urlResp)
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(resp))
|
||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
|
||||
ctx.Header("user_id", userId[0])
|
||||
ctx.Header("authorize", newAuthorizeStr)
|
||||
ctx.Header("X-Message-Sign", xms64)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func DownloadEventHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
eventResp := model.EventResp{
|
||||
ResponseData: []interface{}{},
|
||||
ReleaseInfo: []interface{}{},
|
||||
@@ -338,11 +185,13 @@ func DownloadEventHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(eventResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
|
||||
ctx.Header("user_id", userId[0])
|
||||
ctx.Header("authorize", newAuthorizeStr)
|
||||
ctx.Header("X-Message-Sign", xms64)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+12
-60
@@ -4,73 +4,24 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type EventsResp struct {
|
||||
ResponseData EventsData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type TargetList struct {
|
||||
Position int `json:"position"`
|
||||
IsDisplayable bool `json:"is_displayable"`
|
||||
}
|
||||
|
||||
type EventsData struct {
|
||||
TargetList []TargetList `json:"target_list"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
func EventListHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
targets := []TargetList{}
|
||||
targets := []model.TargetList{}
|
||||
for i := 0; i < 6; i++ {
|
||||
targets = append(targets, TargetList{
|
||||
targets = append(targets, model.TargetList{
|
||||
Position: i + 1,
|
||||
IsDisplayable: false,
|
||||
})
|
||||
}
|
||||
eventsResp := EventsResp{
|
||||
ResponseData: EventsData{
|
||||
eventsResp := model.EventsResp{
|
||||
ResponseData: model.EventsRes{
|
||||
TargetList: targets,
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
},
|
||||
@@ -79,12 +30,13 @@ func EventListHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(eventsResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+10
-54
@@ -4,62 +4,17 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type GdprResp struct {
|
||||
ResponseData GdprData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type GdprData struct {
|
||||
EnableGdpr bool `json:"enable_gdpr"`
|
||||
IsEea bool `json:"is_eea"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
func GdprHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
gdprResp := GdprResp{
|
||||
ResponseData: GdprData{
|
||||
gdprResp := model.GdprResp{
|
||||
ResponseData: model.GdprRes{
|
||||
EnableGdpr: true,
|
||||
IsEea: false,
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
@@ -69,12 +24,13 @@ func GdprHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(gdprResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
nonce = 0
|
||||
// nonce = 0
|
||||
PackageVersion = "97.4.6"
|
||||
CdnUrl string
|
||||
ErrorMsg = `{"code":20001,"message":""}`
|
||||
|
||||
+9
-42
@@ -4,11 +4,8 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -16,37 +13,6 @@ import (
|
||||
)
|
||||
|
||||
func LBonusExecuteHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
weeks := map[string]int{
|
||||
"Monday": 1,
|
||||
"Tuesday": 2,
|
||||
@@ -127,7 +93,7 @@ func LBonusExecuteHandler(ctx *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
res := model.LbResp{
|
||||
LbRes := model.LbResp{
|
||||
ResponseData: model.LbRes{
|
||||
Sheets: []interface{}{},
|
||||
CalendarInfo: model.CalendarInfo{
|
||||
@@ -184,14 +150,15 @@ func LBonusExecuteHandler(ctx *gin.Context) {
|
||||
StatusCode: 200,
|
||||
}
|
||||
|
||||
resp, err := json.Marshal(res)
|
||||
resp, err := json.Marshal(LbRes)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+33
-187
@@ -4,7 +4,6 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
@@ -24,91 +23,30 @@ type GameOverResp struct {
|
||||
}
|
||||
|
||||
func PartyListHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
resp := utils.ReadAllText("assets/partylist.json")
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
nonce := ctx.GetInt("nonce")
|
||||
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)
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")))
|
||||
|
||||
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()
|
||||
|
||||
playReq := model.PlayReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &playReq)
|
||||
CheckErr(err)
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
tDifficultyId := playReq.LiveDifficultyID
|
||||
difficultyId, err := strconv.Atoi(tDifficultyId)
|
||||
CheckErr(err)
|
||||
deckId := playReq.UnitDeckID
|
||||
|
||||
// Save Deck Id for /live/reward
|
||||
key := "live_deck_" + userId[0]
|
||||
key := "live_deck_" + ctx.GetString("userid")
|
||||
err = database.LevelDb.Put([]byte(key), []byte(strconv.Itoa(deckId)))
|
||||
CheckErr(err)
|
||||
|
||||
@@ -206,48 +144,17 @@ func PlayLiveHandler(ctx *gin.Context) {
|
||||
mm, err := json.Marshal(res)
|
||||
CheckErr(err)
|
||||
|
||||
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")))
|
||||
|
||||
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, string(mm))
|
||||
}
|
||||
|
||||
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, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
overResp := GameOverResp{
|
||||
ResponseData: []interface{}{},
|
||||
ReleaseInfo: []interface{}{},
|
||||
@@ -255,52 +162,22 @@ func GameOverHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(overResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func PlayScoreHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
playScoreReq := model.PlayScoreReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &playScoreReq)
|
||||
CheckErr(err)
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
tDifficultyId := playScoreReq.LiveDifficultyID
|
||||
difficultyId, err := strconv.Atoi(tDifficultyId)
|
||||
CheckErr(err)
|
||||
@@ -384,52 +261,21 @@ func PlayScoreHandler(ctx *gin.Context) {
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(mm))
|
||||
|
||||
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")))
|
||||
|
||||
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, string(mm))
|
||||
}
|
||||
|
||||
func PlayRewardHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
playRewardReq := model.PlayRewardReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &playRewardReq)
|
||||
CheckErr(err)
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
difficultyId := playRewardReq.LiveDifficultyID
|
||||
|
||||
// Song type: normal / special
|
||||
@@ -439,13 +285,13 @@ func PlayRewardHandler(ctx *gin.Context) {
|
||||
err = MainEng.DB().QueryRow(sql, difficultyId, difficultyId).Scan(&c_rank_score, &b_rank_score, &a_rank_score, &s_rank_score, &c_rank_combo, &b_rank_combo, &a_rank_combo, &s_rank_combo, &ac_flag, &swing_flag)
|
||||
CheckErr(err)
|
||||
|
||||
key := "live_deck_" + userId[0]
|
||||
key := "live_deck_" + ctx.GetString("userid")
|
||||
deckId, err := database.LevelDb.Get([]byte(key))
|
||||
CheckErr(err)
|
||||
unitsList := []model.PlayRewardUnitList{}
|
||||
err = UserEng.Table("deck_unit_m").Select("*").
|
||||
Join("LEFT", "user_deck_m", "deck_unit_m.user_deck_id = user_deck_m.id").
|
||||
Where("user_id = ? AND deck_id = ?", userId[0], string(deckId)).Find(&unitsList)
|
||||
Where("user_id = ? AND deck_id = ?", ctx.GetString("userid"), string(deckId)).Find(&unitsList)
|
||||
CheckErr(err)
|
||||
|
||||
totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute
|
||||
@@ -609,12 +455,12 @@ func PlayRewardHandler(ctx *gin.Context) {
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(mm))
|
||||
|
||||
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")))
|
||||
|
||||
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, string(mm))
|
||||
}
|
||||
|
||||
+29
-117
@@ -7,151 +7,63 @@ import (
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func AuthKeyHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authReq := model.AuthKeyReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &authReq)
|
||||
CheckErr(err)
|
||||
|
||||
dummyToken64, err := base64.StdEncoding.DecodeString(authReq.DummyToken)
|
||||
CheckErr(err)
|
||||
dummyTokenDecrypted := encrypt.RSA_Decrypt(dummyToken64, "privatekey.pem")
|
||||
|
||||
// aesKey := dummyTokenDecrypted[0:16]
|
||||
// data64, err := base64.StdEncoding.DecodeString(authReq.AuthData)
|
||||
// CheckErr(err)
|
||||
// dataDecrypted := utils.Sub16(encrypt.AES_CBC_Decrypt(data64, aesKey))
|
||||
// fmt.Println(string(dataDecrypted))
|
||||
|
||||
mRandStr := utils.RandomStr(32)
|
||||
serverToken := base64.RawStdEncoding.EncodeToString([]byte(mRandStr))
|
||||
|
||||
authorizeToken := utils.RandomBase64Token(32)
|
||||
|
||||
nonce++
|
||||
|
||||
clientToken := base64.RawStdEncoding.EncodeToString(dummyTokenDecrypted)
|
||||
authData := map[string]interface{}{
|
||||
"client_token": clientToken,
|
||||
"server_token": serverToken,
|
||||
func AuthKey(ctx *gin.Context) {
|
||||
authResp := model.AuthKeyResp{
|
||||
ResponseData: model.AuthKeyRes{
|
||||
AuthorizeToken: ctx.GetString("authorize_token"),
|
||||
DummyToken: ctx.GetString("dummy_token"),
|
||||
},
|
||||
ReleaseInfo: []interface{}{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
authJson, err := json.Marshal(authData)
|
||||
CheckErr(err)
|
||||
database.LevelDb.Put([]byte(authorizeToken), authJson)
|
||||
CheckErr(err)
|
||||
|
||||
authResp := model.AuthKeyResp{}
|
||||
authResp.ResponseData.DummyToken = serverToken
|
||||
authResp.ResponseData.AuthorizeToken = authorizeToken
|
||||
authResp.StatusCode = 200
|
||||
resp, err := json.Marshal(authResp)
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(resp))
|
||||
|
||||
respTime := time.Now().Unix()
|
||||
authorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&nonce=%d&requestTimeStamp=%d", respTime, nonce, reqTime)
|
||||
// fmt.Println(authorizeStr)
|
||||
xMessageSign := base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem"))
|
||||
|
||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
ctx.Header("X-Message-Sign", xMessageSign)
|
||||
|
||||
ctx.Header("user_id", "")
|
||||
ctx.Header("authorize", authorizeStr)
|
||||
ctx.Header("X-Message-Sign", xms64)
|
||||
ctx.JSON(http.StatusOK, authResp)
|
||||
}
|
||||
|
||||
func LoginHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
authData, err := database.LevelDb.Get([]byte(authToken))
|
||||
CheckErr(err)
|
||||
// fmt.Println(authData)
|
||||
|
||||
clientToken := gjson.Get(string(authData), "client_token").String()
|
||||
serverToken := gjson.Get(string(authData), "server_token").String()
|
||||
clientToken64, err := base64.RawStdEncoding.DecodeString(clientToken)
|
||||
CheckErr(err)
|
||||
serverToken64, err := base64.RawStdEncoding.DecodeString(serverToken)
|
||||
CheckErr(err)
|
||||
|
||||
xmcKey := utils.SliceXor([]byte(clientToken64), []byte(serverToken64))
|
||||
aesKey := xmcKey[0:16]
|
||||
|
||||
loginReq := model.LoginReq{}
|
||||
err = json.Unmarshal([]byte(ctx.PostForm("request_data")), &loginReq)
|
||||
CheckErr(err)
|
||||
key64, err := base64.StdEncoding.DecodeString(loginReq.LoginKey)
|
||||
CheckErr(err)
|
||||
// pass64, err := base64.StdEncoding.DecodeString(loginReq.LoginPasswd)
|
||||
// CheckErr(err)
|
||||
keyDescrypted := utils.Sub16(encrypt.AES_CBC_Decrypt(key64, aesKey))
|
||||
// fmt.Println(string(keyDescrypted))
|
||||
// passDescrypted := utils.Sub16(encrypt.AES_CBC_Decrypt(pass64, aesKey))
|
||||
// fmt.Println(string(passDescrypted))
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
nonce++
|
||||
|
||||
stmt, err := UserEng.DB().Prepare("SELECT userid FROM user_key WHERE key = ?")
|
||||
CheckErr(err)
|
||||
defer stmt.Close()
|
||||
|
||||
func Login(ctx *gin.Context) {
|
||||
loginKey := ctx.GetString("login_key")
|
||||
var userId int
|
||||
err = stmt.QueryRow(string(keyDescrypted)).Scan(&userId)
|
||||
exists, err := UserEng.Table("user_key").Where("key = ?", loginKey).Cols("userid").Get(&userId)
|
||||
CheckErr(err)
|
||||
|
||||
if userId == 0 {
|
||||
if !exists || userId == 0 {
|
||||
userId = 9999999
|
||||
}
|
||||
sUserId := strconv.Itoa(userId)
|
||||
authorizeToken := utils.RandomBase64Token(32)
|
||||
ctx.Set("userid", userId)
|
||||
|
||||
err = database.LevelDb.Put([]byte(sUserId), []byte(authorizeToken))
|
||||
err = database.LevelDb.Put([]byte(strconv.Itoa(userId)), []byte(ctx.GetString("authorize_token")))
|
||||
CheckErr(err)
|
||||
|
||||
loginResp := model.LoginResp{}
|
||||
loginResp.ResponseData.AuthorizeToken = authorizeToken
|
||||
loginResp.ResponseData.UserId = userId
|
||||
loginResp.ResponseData.ServerTimestamp = time.Now().Unix()
|
||||
loginResp.ResponseData.AdultFlag = 2
|
||||
loginResp.StatusCode = 200
|
||||
loginResp := model.LoginResp{
|
||||
ResponseData: model.LoginRes{
|
||||
AuthorizeToken: ctx.GetString("authorize_token"),
|
||||
UserId: userId,
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
AdultFlag: 2,
|
||||
},
|
||||
ReleaseInfo: []interface{}{},
|
||||
StatusCode: 200,
|
||||
}
|
||||
resp, err := json.Marshal(loginResp)
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(resp))
|
||||
|
||||
respTime := time.Now().Unix()
|
||||
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%d&requestTimeStamp=%d", respTime, authorizeToken, nonce, userId, reqTime)
|
||||
// fmt.Println(newAuthorizeStr)
|
||||
|
||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
|
||||
ctx.Header("user_id", "")
|
||||
ctx.Header("authorize", newAuthorizeStr)
|
||||
ctx.Header("X-Message-Sign", xms64)
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("authorize_token"), ctx.GetInt("nonce"), ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.JSON(http.StatusOK, loginResp)
|
||||
}
|
||||
|
||||
+6
-40
@@ -4,10 +4,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -36,41 +33,10 @@ type MultiUnitStartUpReq struct {
|
||||
}
|
||||
|
||||
func MultiUnitStartUpHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
startReq := MultiUnitStartUpReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||
CheckErr(err)
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
startResp := MultiUnitStartUpResp{
|
||||
ResponseData: MultiUnitStartUpData{
|
||||
MultiUnitScenarioID: startReq.MultiUnitScenarioID,
|
||||
@@ -82,13 +48,13 @@ func MultiUnitStartUpHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(startResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+28
-157
@@ -4,87 +4,17 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type NoticeFriendVarietyResp struct {
|
||||
ResponseData NoticeFriendVarietyData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type NoticeFriendVarietyData struct {
|
||||
ItemCount int `json:"item_count"`
|
||||
NoticeList []interface{} `json:"notice_list"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
type NoticeFriendGreetingResp struct {
|
||||
ResponseData NoticeFriendGreetingData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type NoticeFriendGreetingData struct {
|
||||
NextId int `json:"next_id"`
|
||||
NoticeList []interface{} `json:"notice_list"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
type NoticeUserGreetingResp struct {
|
||||
ResponseData NoticeUserGreetingData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type NoticeUserGreetingData struct {
|
||||
ItemCount int `json:"item_count"`
|
||||
HasNext bool `json:"has_next"`
|
||||
NoticeList []interface{} `json:"notice_list"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
func NoticeFriendVarietyHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
noticeResp := NoticeFriendVarietyResp{
|
||||
ResponseData: NoticeFriendVarietyData{
|
||||
noticeResp := model.NoticeFriendVarietyResp{
|
||||
ResponseData: model.NoticeFriendVarietyRes{
|
||||
ItemCount: 1,
|
||||
NoticeList: []interface{}{},
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
@@ -94,50 +24,20 @@ func NoticeFriendVarietyHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func NoticeFriendGreetingHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
noticeResp := NoticeFriendGreetingResp{
|
||||
ResponseData: NoticeFriendGreetingData{
|
||||
noticeResp := model.NoticeFriendGreetingResp{
|
||||
ResponseData: model.NoticeFriendGreetingRes{
|
||||
NextId: 0,
|
||||
NoticeList: []interface{}{},
|
||||
ServerTimestamp: time.Now().Unix(),
|
||||
@@ -147,50 +47,20 @@ func NoticeFriendGreetingHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func NoticeUserGreetingHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
noticeResp := NoticeUserGreetingResp{
|
||||
ResponseData: NoticeUserGreetingData{
|
||||
noticeResp := model.NoticeUserGreetingResp{
|
||||
ResponseData: model.NoticeUserGreetingRes{
|
||||
ItemCount: 0,
|
||||
HasNext: false,
|
||||
NoticeList: []interface{}{},
|
||||
@@ -201,12 +71,13 @@ func NoticeUserGreetingHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+7
-40
@@ -4,10 +4,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -39,37 +36,6 @@ type ProductData struct {
|
||||
}
|
||||
|
||||
func ProductListHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
prodReesp := ProductResp{
|
||||
ResponseData: ProductData{
|
||||
RestrictionInfo: RestrictionInfo{
|
||||
@@ -92,12 +58,13 @@ func ProductListHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(prodReesp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+10
-57
@@ -4,65 +4,17 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type PersonalNoticeResp struct {
|
||||
ResponseData PersonalNoticeData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type PersonalNoticeData struct {
|
||||
HasNotice bool `json:"has_notice"`
|
||||
NoticeID int `json:"notice_id"`
|
||||
Type int `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Contents string `json:"contents"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
func PersonalNoticeHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
noticeResp := PersonalNoticeResp{
|
||||
ResponseData: PersonalNoticeData{
|
||||
noticeResp := model.PersonalNoticeResp{
|
||||
ResponseData: model.PersonalNoticeRes{
|
||||
HasNotice: false,
|
||||
NoticeID: 0,
|
||||
Type: 0,
|
||||
@@ -75,12 +27,13 @@ func PersonalNoticeHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+13
-75
@@ -4,8 +4,6 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
@@ -36,41 +34,10 @@ type ScenarioReq struct {
|
||||
}
|
||||
|
||||
func ScenarioStartupHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
startReq := ScenarioReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||
CheckErr(err)
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
startResp := ScenarioResp{
|
||||
ResponseData: ScenarioData{
|
||||
ScenarioID: startReq.ScenarioID,
|
||||
@@ -82,57 +49,28 @@ func ScenarioStartupHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(startResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func ScenarioRewardHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
resp := utils.ReadAllText("assets/reward.json")
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
nonce := ctx.GetInt("nonce")
|
||||
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.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
+11
-75
@@ -4,8 +4,6 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
@@ -36,41 +34,10 @@ type SubScenarioReq struct {
|
||||
}
|
||||
|
||||
func SubScenarioStartupHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
startReq := SubScenarioReq{}
|
||||
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &startReq)
|
||||
CheckErr(err)
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
startResp := SubScenarioResp{
|
||||
ResponseData: SubScenarioData{
|
||||
SubscenarioID: startReq.SubscenarioID,
|
||||
@@ -82,57 +49,26 @@ func SubScenarioStartupHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(startResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func SubScenarioRewardHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
resp := utils.ReadAllText("assets/subreward.json")
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
nonce := ctx.GetInt("nonce")
|
||||
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.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
+10
-53
@@ -4,62 +4,17 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type TosResp struct {
|
||||
ResponseData TosData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type TosData struct {
|
||||
TosID int `json:"tos_id"`
|
||||
TosType int `json:"tos_type"`
|
||||
IsAgreed bool `json:"is_agreed"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
func TosCheckHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
tosResp := TosResp{
|
||||
ResponseData: TosData{
|
||||
tosResp := model.TosResp{
|
||||
ResponseData: model.TosRes{
|
||||
TosID: 1,
|
||||
TosType: 1,
|
||||
IsAgreed: true,
|
||||
@@ -70,11 +25,13 @@ func TosCheckHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(tosResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")
|
||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||
|
||||
ctx.Header("user_id", userId[0])
|
||||
ctx.Header("authorize", newAuthorizeStr)
|
||||
ctx.Header("X-Message-Sign", xms64)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+23
-79
@@ -73,37 +73,8 @@ func SetDisplayRankHandler(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
func SetDeckHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
uId, _ := strconv.Atoi(userId[0])
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
CheckErr(err)
|
||||
|
||||
deckReq := model.UnitDeckReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq); err != nil {
|
||||
@@ -114,14 +85,14 @@ func SetDeckHandler(ctx *gin.Context) {
|
||||
// UserEng.ShowSQL(true)
|
||||
session := UserEng.NewSession()
|
||||
defer session.Close()
|
||||
if err = session.Begin(); err != nil {
|
||||
if err := session.Begin(); err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 原有队伍信息
|
||||
var userDeckId []int
|
||||
err = session.Table("user_deck_m").Cols("id").Where("user_id = ?", uId).Find(&userDeckId)
|
||||
err = session.Table("user_deck_m").Cols("id").Where("user_id = ?", userId).Find(&userDeckId)
|
||||
if err != nil {
|
||||
session.Rollback()
|
||||
panic(err)
|
||||
@@ -148,7 +119,7 @@ func SetDeckHandler(ctx *gin.Context) {
|
||||
DeckID: deck.UnitDeckID,
|
||||
MainFlag: deck.MainFlag,
|
||||
DeckName: deck.DeckName,
|
||||
UserID: uId,
|
||||
UserID: userId,
|
||||
InsertDate: time.Now().Unix(),
|
||||
}
|
||||
_, err = session.Table("user_deck_m").Insert(&userDeck)
|
||||
@@ -233,55 +204,27 @@ func SetDeckHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(dispResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func SetDeckNameHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
uId, _ := strconv.Atoi(userId[0])
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
CheckErr(err)
|
||||
|
||||
deckReq := model.DeckNameReq{}
|
||||
if err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &deckReq); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
exists, err := UserEng.Table("user_deck_m").Where("user_id = ? AND deck_id = ?", uId, deckReq.UnitDeckID).Exist()
|
||||
exists, err := UserEng.Table("user_deck_m").Where("user_id = ? AND deck_id = ?", userId, deckReq.UnitDeckID).Exist()
|
||||
CheckErr(err)
|
||||
if !exists {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
@@ -291,7 +234,7 @@ func SetDeckNameHandler(ctx *gin.Context) {
|
||||
DeckName: deckReq.DeckName,
|
||||
}
|
||||
_, err = UserEng.Table("user_deck_m").Update(&userDeck, &tools.UserDeckData{
|
||||
UserID: uId,
|
||||
UserID: userId,
|
||||
DeckID: deckReq.UnitDeckID,
|
||||
})
|
||||
CheckErr(err)
|
||||
@@ -303,12 +246,13 @@ func SetDeckNameHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(dispResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+14
-77
@@ -4,10 +4,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -21,37 +18,6 @@ type NotificationResp struct {
|
||||
}
|
||||
|
||||
func SetNotificationTokenHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
notifResp := NotificationResp{
|
||||
ResponseData: []interface{}{},
|
||||
ReleaseInfo: []interface{}{},
|
||||
@@ -59,48 +25,18 @@ func SetNotificationTokenHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(notifResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
func ChangeNaviHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
notifResp := NotificationResp{
|
||||
ResponseData: []interface{}{},
|
||||
ReleaseInfo: []interface{}{},
|
||||
@@ -108,12 +44,13 @@ func ChangeNaviHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(notifResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+17
-98
@@ -4,105 +4,23 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type UserInfoResp struct {
|
||||
ResponseData UserInfoData `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type LpRecoveryItem struct {
|
||||
ItemID int `json:"item_id"`
|
||||
Amount int `json:"amount"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
UserID int `json:"user_id"`
|
||||
Name string `json:"name"`
|
||||
Level int `json:"level"`
|
||||
Exp int `json:"exp"`
|
||||
PreviousExp int `json:"previous_exp"`
|
||||
NextExp int `json:"next_exp"`
|
||||
GameCoin int `json:"game_coin"`
|
||||
SnsCoin int `json:"sns_coin"`
|
||||
FreeSnsCoin int `json:"free_sns_coin"`
|
||||
PaidSnsCoin int `json:"paid_sns_coin"`
|
||||
SocialPoint int `json:"social_point"`
|
||||
UnitMax int `json:"unit_max"`
|
||||
WaitingUnitMax int `json:"waiting_unit_max"`
|
||||
EnergyMax int `json:"energy_max"`
|
||||
EnergyFullTime string `json:"energy_full_time"`
|
||||
LicenseLiveEnergyRecoverlyTime int `json:"license_live_energy_recoverly_time"`
|
||||
EnergyFullNeedTime int `json:"energy_full_need_time"`
|
||||
OverMaxEnergy int `json:"over_max_energy"`
|
||||
TrainingEnergy int `json:"training_energy"`
|
||||
TrainingEnergyMax int `json:"training_energy_max"`
|
||||
FriendMax int `json:"friend_max"`
|
||||
InviteCode string `json:"invite_code"`
|
||||
InsertDate string `json:"insert_date"`
|
||||
UpdateDate string `json:"update_date"`
|
||||
TutorialState int `json:"tutorial_state"`
|
||||
DiamondCoin int `json:"diamond_coin"`
|
||||
CrystalCoin int `json:"crystal_coin"`
|
||||
LpRecoveryItem []LpRecoveryItem `json:"lp_recovery_item"`
|
||||
}
|
||||
|
||||
type Birth struct {
|
||||
BirthMonth int `json:"birth_month"`
|
||||
BirthDay int `json:"birth_day"`
|
||||
}
|
||||
|
||||
type UserInfoData struct {
|
||||
User User `json:"user"`
|
||||
Birth Birth `json:"birth"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
func UserInfoHandler(ctx *gin.Context) {
|
||||
reqTime := time.Now().Unix()
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
CheckErr(err)
|
||||
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
authToken, err := utils.GetAuthorizeToken(authorizeStr)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) == 0 {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(authToken, userId[0]) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
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)
|
||||
|
||||
userResp := UserInfoResp{
|
||||
ResponseData: UserInfoData{
|
||||
User: User{
|
||||
UserID: 9999999,
|
||||
userResp := model.UserInfoResp{
|
||||
ResponseData: model.UserInfoRes{
|
||||
User: model.UserInfo{
|
||||
UserID: userId,
|
||||
Name: "\u68a6\u8def @\u65c5\u7acb\u3061\u306e\u65e5\u306b",
|
||||
Level: 1028,
|
||||
Exp: 28824396,
|
||||
@@ -129,9 +47,9 @@ func UserInfoHandler(ctx *gin.Context) {
|
||||
TutorialState: -1,
|
||||
DiamondCoin: 0,
|
||||
CrystalCoin: 0,
|
||||
LpRecoveryItem: []LpRecoveryItem{},
|
||||
LpRecoveryItem: []model.LpRecoveryItem{},
|
||||
},
|
||||
Birth: Birth{
|
||||
Birth: model.Birth{
|
||||
BirthMonth: 10,
|
||||
BirthDay: 18,
|
||||
},
|
||||
@@ -142,12 +60,13 @@ func UserInfoHandler(ctx *gin.Context) {
|
||||
}
|
||||
resp, err := json.Marshal(userResp)
|
||||
CheckErr(err)
|
||||
xms := encrypt.RSA_Sign_SHA1(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)
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
|
||||
ctx.Header("user_id", ctx.GetString("userid"))
|
||||
ctx.Header("authorize", fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", time.Now().Unix(), ctx.GetString("token"), nonce, ctx.GetString("userid"), ctx.GetInt64("req_time")))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp, "privatekey.pem")))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -46,10 +46,10 @@ func main() {
|
||||
// Private APIs
|
||||
|
||||
// Server APIs
|
||||
m := r.Group("main.php").Use(middleware.CommonMid)
|
||||
m := r.Group("main.php").Use(middleware.Common)
|
||||
{
|
||||
m.POST("/login/authkey", handler.AuthKeyHandler)
|
||||
m.POST("/login/login", handler.LoginHandler)
|
||||
m.POST("/login/authkey", middleware.AuthKey, handler.AuthKey)
|
||||
m.POST("/login/login", middleware.Login, handler.Login)
|
||||
m.POST("/user/userInfo", handler.UserInfoHandler)
|
||||
m.POST("/gdpr/get", handler.GdprHandler)
|
||||
m.POST("/personalnotice/get", handler.PersonalNoticeHandler)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func AuthKey(ctx *gin.Context) {
|
||||
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||
tDummyToken, err := base64.StdEncoding.DecodeString(req.Get("dummy_token").String())
|
||||
CheckErr(err)
|
||||
dummyToken := encrypt.RSA_Decrypt(tDummyToken, "privatekey.pem")
|
||||
|
||||
// aesKey := dummyToken[0:16]
|
||||
// tAuthData, err := base64.StdEncoding.DecodeString(req.Get("auth_data").String())
|
||||
// CheckErr(err)
|
||||
// authData := utils.Sub16(encrypt.AES_CBC_Decrypt(tAuthData, aesKey))
|
||||
// fmt.Println(string(authData))
|
||||
|
||||
clientToken := base64.StdEncoding.EncodeToString(dummyToken)
|
||||
serverToken := base64.StdEncoding.EncodeToString([]byte(utils.RandomStr(32)))
|
||||
authorizeToken := base64.StdEncoding.EncodeToString([]byte(utils.RandomStr(32)))
|
||||
|
||||
ctx.Set("dummy_token", serverToken)
|
||||
ctx.Set("authorize_token", authorizeToken)
|
||||
|
||||
authJson, err := json.Marshal(map[string]interface{}{
|
||||
"client_token": clientToken,
|
||||
"server_token": serverToken,
|
||||
})
|
||||
CheckErr(err)
|
||||
err = database.LevelDb.Put([]byte(authorizeToken), authJson)
|
||||
CheckErr(err)
|
||||
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
ctx.Set("nonce", nonce)
|
||||
|
||||
authorize := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&nonce=%d&requestTimeStamp=%d", time.Now().Unix(), nonce, ctx.GetInt64("req_time"))
|
||||
|
||||
ctx.Header("user_id", "")
|
||||
ctx.Header("authorize", authorize)
|
||||
|
||||
ctx.Next()
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"honoka-chan/database"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrorMsg = `{"code":20001,"message":""}`
|
||||
)
|
||||
|
||||
func CheckErr(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func Common(ctx *gin.Context) {
|
||||
ctx.Set("req_time", time.Now().Unix())
|
||||
|
||||
authorize := ctx.Request.Header.Get("Authorize")
|
||||
if authorize == "" {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
ctx.Abort()
|
||||
}
|
||||
ctx.Set("authorize", authorize)
|
||||
|
||||
params, err := url.ParseQuery(authorize)
|
||||
CheckErr(err)
|
||||
|
||||
nonce, err := strconv.Atoi(params.Get("nonce"))
|
||||
CheckErr(err)
|
||||
nonce++
|
||||
ctx.Set("nonce", nonce)
|
||||
|
||||
token := params.Get("token")
|
||||
ctx.Set("token", token)
|
||||
|
||||
if ctx.Request.URL.String() == "/main.php/login/authkey" ||
|
||||
ctx.Request.URL.String() == "/main.php/login/login" {
|
||||
// 特殊请求
|
||||
fmt.Println("========")
|
||||
} else {
|
||||
userId := ctx.Request.Header.Get("User-ID")
|
||||
if userId == "" {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
ctx.Abort()
|
||||
}
|
||||
ctx.Set("userid", userId)
|
||||
|
||||
rToken, err := database.LevelDb.Get([]byte(userId))
|
||||
CheckErr(err)
|
||||
if token != string(rToken) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
ctx.Abort()
|
||||
}
|
||||
|
||||
if !database.MatchTokenUid(token, userId) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
ctx.Abort()
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Header("Content-Type", "application/json; charset=utf-8")
|
||||
ctx.Header("X-Powered-By", "KLab Native APP Platform")
|
||||
ctx.Header("server_version", "20120129")
|
||||
ctx.Header("Server-Version", "97.4.6")
|
||||
ctx.Header("version_up", "0")
|
||||
ctx.Header("status_code", "200")
|
||||
|
||||
ctx.Next()
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func Login(ctx *gin.Context) {
|
||||
authData, err := database.LevelDb.Get([]byte(ctx.GetString("token")))
|
||||
CheckErr(err)
|
||||
|
||||
clientToken, err := base64.StdEncoding.DecodeString(gjson.Get(string(authData), "client_token").String())
|
||||
CheckErr(err)
|
||||
serverToken, err := base64.StdEncoding.DecodeString(gjson.Get(string(authData), "server_token").String())
|
||||
CheckErr(err)
|
||||
|
||||
xmcKey := utils.SliceXor(clientToken, serverToken)
|
||||
aesKey := xmcKey[0:16]
|
||||
|
||||
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||
tKey, err := base64.StdEncoding.DecodeString(req.Get("login_key").String())
|
||||
CheckErr(err)
|
||||
loginKey := utils.Sub16(encrypt.AES_CBC_Decrypt(tKey, aesKey))
|
||||
ctx.Set("login_key", string(loginKey))
|
||||
|
||||
tPasswd, err := base64.StdEncoding.DecodeString(req.Get("login_passwd").String())
|
||||
CheckErr(err)
|
||||
loginPasswd := utils.Sub16(encrypt.AES_CBC_Decrypt(tPasswd, aesKey))
|
||||
ctx.Set("login_passwd", string(loginPasswd))
|
||||
|
||||
nonce := ctx.GetInt("nonce")
|
||||
nonce++
|
||||
ctx.Set("nonce", nonce)
|
||||
|
||||
authorizeToken := base64.StdEncoding.EncodeToString([]byte(utils.RandomStr(32)))
|
||||
ctx.Set("authorize_token", authorizeToken)
|
||||
|
||||
ctx.Next()
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/handler"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func CommonMid(ctx *gin.Context) {
|
||||
authorizeStr := ctx.Request.Header["Authorize"]
|
||||
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
|
||||
if len(userId) > 0 {
|
||||
authStr, _ := utils.GetAuthorizeToken(authorizeStr)
|
||||
res, _ := database.LevelDb.Get([]byte(userId[0]))
|
||||
if authStr != string(res) {
|
||||
ctx.String(http.StatusForbidden, handler.ErrorMsg)
|
||||
ctx.Abort()
|
||||
return
|
||||
}
|
||||
}
|
||||
ctx.Header("Content-Type", "application/json; charset=utf-8")
|
||||
ctx.Header("X-Powered-By", config.Conf.Server.PoweredBy)
|
||||
ctx.Header("server_version", config.Conf.Server.VersionDate)
|
||||
ctx.Header("version_up", config.Conf.Server.VersionUp)
|
||||
ctx.Header("status_code", "200")
|
||||
|
||||
ctx.Next()
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package model
|
||||
|
||||
// AnnounceResp ...
|
||||
type AnnounceResp struct {
|
||||
ResponseData AnnounceRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// AnnounceRes ...
|
||||
type AnnounceRes struct {
|
||||
HasUnreadAnnounce bool `json:"has_unread_announce"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
type SifApi struct {
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
Timestamp int64 `json:"timeStamp"`
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package model
|
||||
|
||||
type SifApi struct {
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
Timestamp int64 `json:"timeStamp"`
|
||||
}
|
||||
|
||||
type AuthKeyReq struct {
|
||||
DummyToken string `json:"dummy_token"`
|
||||
AuthData string `json:"auth_data"`
|
||||
}
|
||||
|
||||
type AuthKeyResp struct {
|
||||
ResponseData struct {
|
||||
AuthorizeToken string `json:"authorize_token"`
|
||||
DummyToken string `json:"dummy_token"`
|
||||
} `json:"response_data"`
|
||||
ReleaseInfo [0]interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
type LoginReq struct {
|
||||
LoginKey string `json:"login_key"`
|
||||
LoginPasswd string `json:"login_passwd"`
|
||||
DevToken string `json:"devtoken"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
ResponseData struct {
|
||||
AuthorizeToken string `json:"authorize_token"`
|
||||
UserId int `json:"user_id"`
|
||||
ReviewVersion string `json:"review_version"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
IdfaEnabled bool `json:"idfa_enabled"`
|
||||
SkipLoginNews bool `json:"skip_login_news"`
|
||||
AdultFlag int `json:"adult_flag"`
|
||||
} `json:"response_data"`
|
||||
ReleaseInfo [0]interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package model
|
||||
|
||||
// AuthKeyRes ...
|
||||
type AuthKeyRes struct {
|
||||
AuthorizeToken string `json:"authorize_token"`
|
||||
DummyToken string `json:"dummy_token"`
|
||||
}
|
||||
|
||||
// AuthKeyResp ...
|
||||
type AuthKeyResp struct {
|
||||
ResponseData AuthKeyRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package model
|
||||
|
||||
// EventsResp ...
|
||||
type EventsResp struct {
|
||||
ResponseData EventsRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// EventsRes ...
|
||||
type EventsRes struct {
|
||||
TargetList []TargetList `json:"target_list"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
// TargetList ...
|
||||
type TargetList struct {
|
||||
Position int `json:"position"`
|
||||
IsDisplayable bool `json:"is_displayable"`
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
// GdprResp ...
|
||||
type GdprResp struct {
|
||||
ResponseData GdprRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// GdprRes ...
|
||||
type GdprRes struct {
|
||||
EnableGdpr bool `json:"enable_gdpr"`
|
||||
IsEea bool `json:"is_eea"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
+13
-66
@@ -1,72 +1,19 @@
|
||||
package model
|
||||
|
||||
type TopInfoLicenseInfo struct {
|
||||
LicenseList []interface{} `json:"license_list"`
|
||||
LicensedInfo []interface{} `json:"licensed_info"`
|
||||
ExpiredInfo []interface{} `json:"expired_info"`
|
||||
BadgeFlag bool `json:"badge_flag"`
|
||||
}
|
||||
|
||||
type TopInfoResult struct {
|
||||
FriendActionCnt int `json:"friend_action_cnt"`
|
||||
FriendGreetCnt int `json:"friend_greet_cnt"`
|
||||
FriendVarietyCnt int `json:"friend_variety_cnt"`
|
||||
FriendNewCnt int `json:"friend_new_cnt"`
|
||||
PresentCnt int `json:"present_cnt"`
|
||||
SecretBoxBadgeFlag bool `json:"secret_box_badge_flag"`
|
||||
ServerDatetime string `json:"server_datetime"`
|
||||
// LoginRes ...
|
||||
type LoginRes struct {
|
||||
AuthorizeToken string `json:"authorize_token"`
|
||||
UserId int `json:"user_id"`
|
||||
ReviewVersion string `json:"review_version"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
NoticeFriendDatetime string `json:"notice_friend_datetime"`
|
||||
NoticeMailDatetime string `json:"notice_mail_datetime"`
|
||||
FriendsApprovalWaitCnt int `json:"friends_approval_wait_cnt"`
|
||||
FriendsRequestCnt int `json:"friends_request_cnt"`
|
||||
IsTodayBirthday bool `json:"is_today_birthday"`
|
||||
LicenseInfo TopInfoLicenseInfo `json:"license_info"`
|
||||
UsingBuffInfo []interface{} `json:"using_buff_info"`
|
||||
IsKlabIDTaskFlag bool `json:"is_klab_id_task_flag"`
|
||||
KlabIDTaskCanSync bool `json:"klab_id_task_can_sync"`
|
||||
HasUnreadAnnounce bool `json:"has_unread_announce"`
|
||||
ExchangeBadgeCnt []int `json:"exchange_badge_cnt"`
|
||||
AdFlag bool `json:"ad_flag"`
|
||||
HasAdReward bool `json:"has_ad_reward"`
|
||||
IdfaEnabled bool `json:"idfa_enabled"`
|
||||
SkipLoginNews bool `json:"skip_login_news"`
|
||||
AdultFlag int `json:"adult_flag"`
|
||||
}
|
||||
|
||||
type TopInfoResp struct {
|
||||
Result TopInfoResult `json:"result"`
|
||||
Status int `json:"status"`
|
||||
CommandNum bool `json:"commandNum"`
|
||||
TimeStamp int64 `json:"timeStamp"`
|
||||
}
|
||||
|
||||
type TopInfoOnceNotification struct {
|
||||
Push bool `json:"push"`
|
||||
Lp bool `json:"lp"`
|
||||
UpdateInfo bool `json:"update_info"`
|
||||
Campaign bool `json:"campaign"`
|
||||
Live bool `json:"live"`
|
||||
Lbonus bool `json:"lbonus"`
|
||||
Event bool `json:"event"`
|
||||
Secretbox bool `json:"secretbox"`
|
||||
Birthday bool `json:"birthday"`
|
||||
}
|
||||
|
||||
type TopInfoOnceResult struct {
|
||||
NewAchievementCnt int `json:"new_achievement_cnt"`
|
||||
UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"`
|
||||
LiveDailyRewardExist bool `json:"live_daily_reward_exist"`
|
||||
TrainingEnergy int `json:"training_energy"`
|
||||
TrainingEnergyMax int `json:"training_energy_max"`
|
||||
Notification TopInfoOnceNotification `json:"notification"`
|
||||
OpenArena bool `json:"open_arena"`
|
||||
CostumeStatus bool `json:"costume_status"`
|
||||
OpenAccessory bool `json:"open_accessory"`
|
||||
ArenaSiSkillUniqueCheck bool `json:"arena_si_skill_unique_check"`
|
||||
OpenV98 bool `json:"open_v98"`
|
||||
}
|
||||
|
||||
type TopInfoOnceResp struct {
|
||||
Result TopInfoOnceResult `json:"result"`
|
||||
Status int `json:"status"`
|
||||
CommandNum bool `json:"commandNum"`
|
||||
TimeStamp int64 `json:"timeStamp"`
|
||||
// LoginResp ...
|
||||
type LoginResp struct {
|
||||
ResponseData LoginRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package model
|
||||
|
||||
// NoticeFriendVarietyResp ...
|
||||
type NoticeFriendVarietyResp struct {
|
||||
ResponseData NoticeFriendVarietyRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// NoticeFriendVarietyRes ...
|
||||
type NoticeFriendVarietyRes struct {
|
||||
ItemCount int `json:"item_count"`
|
||||
NoticeList []interface{} `json:"notice_list"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
// NoticeFriendGreetingResp ...
|
||||
type NoticeFriendGreetingResp struct {
|
||||
ResponseData NoticeFriendGreetingRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// NoticeFriendGreetingRes ...
|
||||
type NoticeFriendGreetingRes struct {
|
||||
NextId int `json:"next_id"`
|
||||
NoticeList []interface{} `json:"notice_list"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
// NoticeUserGreetingResp ...
|
||||
type NoticeUserGreetingResp struct {
|
||||
ResponseData NoticeUserGreetingRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// NoticeUserGreetingRes ...
|
||||
type NoticeUserGreetingRes struct {
|
||||
ItemCount int `json:"item_count"`
|
||||
HasNext bool `json:"has_next"`
|
||||
NoticeList []interface{} `json:"notice_list"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
// PersonalNoticeResp ...
|
||||
type PersonalNoticeResp struct {
|
||||
ResponseData PersonalNoticeRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// PersonalNoticeRes ...
|
||||
type PersonalNoticeRes struct {
|
||||
HasNotice bool `json:"has_notice"`
|
||||
NoticeID int `json:"notice_id"`
|
||||
Type int `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Contents string `json:"contents"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package model
|
||||
|
||||
type TopInfoLicenseInfo struct {
|
||||
LicenseList []interface{} `json:"license_list"`
|
||||
LicensedInfo []interface{} `json:"licensed_info"`
|
||||
ExpiredInfo []interface{} `json:"expired_info"`
|
||||
BadgeFlag bool `json:"badge_flag"`
|
||||
}
|
||||
|
||||
type TopInfoResult struct {
|
||||
FriendActionCnt int `json:"friend_action_cnt"`
|
||||
FriendGreetCnt int `json:"friend_greet_cnt"`
|
||||
FriendVarietyCnt int `json:"friend_variety_cnt"`
|
||||
FriendNewCnt int `json:"friend_new_cnt"`
|
||||
PresentCnt int `json:"present_cnt"`
|
||||
SecretBoxBadgeFlag bool `json:"secret_box_badge_flag"`
|
||||
ServerDatetime string `json:"server_datetime"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
NoticeFriendDatetime string `json:"notice_friend_datetime"`
|
||||
NoticeMailDatetime string `json:"notice_mail_datetime"`
|
||||
FriendsApprovalWaitCnt int `json:"friends_approval_wait_cnt"`
|
||||
FriendsRequestCnt int `json:"friends_request_cnt"`
|
||||
IsTodayBirthday bool `json:"is_today_birthday"`
|
||||
LicenseInfo TopInfoLicenseInfo `json:"license_info"`
|
||||
UsingBuffInfo []interface{} `json:"using_buff_info"`
|
||||
IsKlabIDTaskFlag bool `json:"is_klab_id_task_flag"`
|
||||
KlabIDTaskCanSync bool `json:"klab_id_task_can_sync"`
|
||||
HasUnreadAnnounce bool `json:"has_unread_announce"`
|
||||
ExchangeBadgeCnt []int `json:"exchange_badge_cnt"`
|
||||
AdFlag bool `json:"ad_flag"`
|
||||
HasAdReward bool `json:"has_ad_reward"`
|
||||
}
|
||||
|
||||
type TopInfoResp struct {
|
||||
Result TopInfoResult `json:"result"`
|
||||
Status int `json:"status"`
|
||||
CommandNum bool `json:"commandNum"`
|
||||
TimeStamp int64 `json:"timeStamp"`
|
||||
}
|
||||
|
||||
type TopInfoOnceNotification struct {
|
||||
Push bool `json:"push"`
|
||||
Lp bool `json:"lp"`
|
||||
UpdateInfo bool `json:"update_info"`
|
||||
Campaign bool `json:"campaign"`
|
||||
Live bool `json:"live"`
|
||||
Lbonus bool `json:"lbonus"`
|
||||
Event bool `json:"event"`
|
||||
Secretbox bool `json:"secretbox"`
|
||||
Birthday bool `json:"birthday"`
|
||||
}
|
||||
|
||||
type TopInfoOnceResult struct {
|
||||
NewAchievementCnt int `json:"new_achievement_cnt"`
|
||||
UnaccomplishedAchievementCnt int `json:"unaccomplished_achievement_cnt"`
|
||||
LiveDailyRewardExist bool `json:"live_daily_reward_exist"`
|
||||
TrainingEnergy int `json:"training_energy"`
|
||||
TrainingEnergyMax int `json:"training_energy_max"`
|
||||
Notification TopInfoOnceNotification `json:"notification"`
|
||||
OpenArena bool `json:"open_arena"`
|
||||
CostumeStatus bool `json:"costume_status"`
|
||||
OpenAccessory bool `json:"open_accessory"`
|
||||
ArenaSiSkillUniqueCheck bool `json:"arena_si_skill_unique_check"`
|
||||
OpenV98 bool `json:"open_v98"`
|
||||
}
|
||||
|
||||
type TopInfoOnceResp struct {
|
||||
Result TopInfoOnceResult `json:"result"`
|
||||
Status int `json:"status"`
|
||||
CommandNum bool `json:"commandNum"`
|
||||
TimeStamp int64 `json:"timeStamp"`
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
// TosResp ...
|
||||
type TosResp struct {
|
||||
ResponseData TosRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// TosResp ...
|
||||
type TosRes struct {
|
||||
TosID int `json:"tos_id"`
|
||||
TosType int `json:"tos_type"`
|
||||
IsAgreed bool `json:"is_agreed"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package model
|
||||
|
||||
// UserInfoResp ...
|
||||
type UserInfoResp struct {
|
||||
ResponseData UserInfoRes `json:"response_data"`
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// UserInfoRes ...
|
||||
type UserInfoRes struct {
|
||||
User UserInfo `json:"user"`
|
||||
Birth Birth `json:"birth"`
|
||||
ServerTimestamp int64 `json:"server_timestamp"`
|
||||
}
|
||||
|
||||
// LpRecoveryItem ...
|
||||
type LpRecoveryItem struct {
|
||||
ItemID int `json:"item_id"`
|
||||
Amount int `json:"amount"`
|
||||
}
|
||||
|
||||
// UserInfo ...
|
||||
type UserInfo struct {
|
||||
UserID int `json:"user_id"`
|
||||
Name string `json:"name"`
|
||||
Level int `json:"level"`
|
||||
Exp int `json:"exp"`
|
||||
PreviousExp int `json:"previous_exp"`
|
||||
NextExp int `json:"next_exp"`
|
||||
GameCoin int `json:"game_coin"`
|
||||
SnsCoin int `json:"sns_coin"`
|
||||
FreeSnsCoin int `json:"free_sns_coin"`
|
||||
PaidSnsCoin int `json:"paid_sns_coin"`
|
||||
SocialPoint int `json:"social_point"`
|
||||
UnitMax int `json:"unit_max"`
|
||||
WaitingUnitMax int `json:"waiting_unit_max"`
|
||||
EnergyMax int `json:"energy_max"`
|
||||
EnergyFullTime string `json:"energy_full_time"`
|
||||
LicenseLiveEnergyRecoverlyTime int `json:"license_live_energy_recoverly_time"`
|
||||
EnergyFullNeedTime int `json:"energy_full_need_time"`
|
||||
OverMaxEnergy int `json:"over_max_energy"`
|
||||
TrainingEnergy int `json:"training_energy"`
|
||||
TrainingEnergyMax int `json:"training_energy_max"`
|
||||
FriendMax int `json:"friend_max"`
|
||||
InviteCode string `json:"invite_code"`
|
||||
InsertDate string `json:"insert_date"`
|
||||
UpdateDate string `json:"update_date"`
|
||||
TutorialState int `json:"tutorial_state"`
|
||||
DiamondCoin int `json:"diamond_coin"`
|
||||
CrystalCoin int `json:"crystal_coin"`
|
||||
LpRecoveryItem []LpRecoveryItem `json:"lp_recovery_item"`
|
||||
}
|
||||
|
||||
// Birth ...
|
||||
type Birth struct {
|
||||
BirthMonth int `json:"birth_month"`
|
||||
BirthDay int `json:"birth_day"`
|
||||
}
|
||||
Reference in New Issue
Block a user