+6
-6
@@ -10,32 +10,32 @@ var (
|
||||
iv = []byte("12345678abcdefgh")
|
||||
)
|
||||
|
||||
func Padding(plainText []byte, blockSize int) []byte {
|
||||
func padding(plainText []byte, blockSize int) []byte {
|
||||
n := blockSize - len(plainText)%blockSize
|
||||
temp := bytes.Repeat([]byte{byte(n)}, n)
|
||||
plainText = append(plainText, temp...)
|
||||
return plainText
|
||||
}
|
||||
|
||||
func UnPadding(cipherText []byte) []byte {
|
||||
func unPadding(cipherText []byte) []byte {
|
||||
end := cipherText[len(cipherText)-1]
|
||||
cipherText = cipherText[:len(cipherText)-int(end)]
|
||||
return cipherText
|
||||
}
|
||||
|
||||
func AES_CBC_Encrypt(plainText []byte, key []byte) []byte {
|
||||
func AESCBCEncrypt(plainText []byte, key []byte) []byte {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
plainText = Padding(plainText, block.BlockSize())
|
||||
plainText = padding(plainText, block.BlockSize())
|
||||
blockMode := cipher.NewCBCEncrypter(block, iv)
|
||||
cipherText := make([]byte, len(plainText))
|
||||
blockMode.CryptBlocks(cipherText, plainText)
|
||||
return cipherText
|
||||
}
|
||||
|
||||
func AES_CBC_Decrypt(cipherText []byte, key []byte) []byte {
|
||||
func AESCBCDecrypt(cipherText []byte, key []byte) []byte {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -43,6 +43,6 @@ func AES_CBC_Decrypt(cipherText []byte, key []byte) []byte {
|
||||
plainText := make([]byte, len(cipherText))
|
||||
blockMode := cipher.NewCBCDecrypter(block, iv)
|
||||
blockMode.CryptBlocks(plainText, cipherText)
|
||||
plainText = UnPadding(plainText)
|
||||
plainText = unPadding(plainText)
|
||||
return plainText
|
||||
}
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@ import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func RSA_Gen(bits int) {
|
||||
func RSAGen(bits int) {
|
||||
//get current path
|
||||
_, currentpath, _, _ := runtime.Caller(0)
|
||||
currentpath = filepath.Dir(currentpath)
|
||||
@@ -75,7 +75,7 @@ func RSA_Gen(bits int) {
|
||||
pem.Encode(publickeyfile, &publickeyblock)
|
||||
}
|
||||
|
||||
func RSA_Encrypt(plainText []byte, publickeypath string) []byte {
|
||||
func RSAEncrypt(plainText []byte, publickeypath string) []byte {
|
||||
//open publickeyfile
|
||||
publickeyfile, err := os.Open(publickeypath)
|
||||
if err != nil {
|
||||
@@ -110,7 +110,7 @@ func RSA_Encrypt(plainText []byte, publickeypath string) []byte {
|
||||
return cipherText
|
||||
}
|
||||
|
||||
func RSA_Decrypt(cipherText []byte) []byte {
|
||||
func RSADecrypt(cipherText []byte) []byte {
|
||||
//open privatekeyfile
|
||||
privatekeyfile, err := os.Open(config.PrivateKeyPath)
|
||||
if err != nil {
|
||||
@@ -138,7 +138,7 @@ func RSA_Decrypt(cipherText []byte) []byte {
|
||||
return plainText
|
||||
}
|
||||
|
||||
func RSA_Sign_SHA1(cipherText []byte) []byte {
|
||||
func RSASignSHA1(cipherText []byte) []byte {
|
||||
//open privatekeyfile
|
||||
privatekeyfile, err := os.Open(config.PrivateKeyPath)
|
||||
if err != nil {
|
||||
|
||||
+1
-11
@@ -1,13 +1,9 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -81,12 +77,6 @@ func AlbumSeriesAll(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(albumResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"html/template"
|
||||
"net/http"
|
||||
@@ -34,12 +31,6 @@ func AnnounceCheckState(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(announceResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+188
-20
@@ -1,12 +1,10 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/tools"
|
||||
"honoka-chan/utils"
|
||||
@@ -217,10 +215,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(liveListResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "unit":
|
||||
switch v.Action {
|
||||
case "unitAll":
|
||||
if v.Action == "unitAll" {
|
||||
// key = "unit_list_result"
|
||||
unitsData := []model.Active{}
|
||||
err = MainEng.Table("common_unit_m").Find(&unitsData)
|
||||
@@ -246,7 +245,7 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(unitListResp)
|
||||
CheckErr(err)
|
||||
case "deckInfo":
|
||||
} else if v.Action == "deckInfo" {
|
||||
// key = "unit_deck_result"
|
||||
userDeck := []model.UserDeckData{}
|
||||
err = UserEng.Table("user_deck_m").Where("user_id = ?", ctx.GetString("userid")).Asc("deck_id").Find(&userDeck)
|
||||
@@ -285,7 +284,7 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(unitDeckResp)
|
||||
CheckErr(err)
|
||||
case "supporterAll":
|
||||
} else if v.Action == "supporterAll" {
|
||||
// key = "unit_support_result"
|
||||
unitSupportResp := model.UnitSupportResp{
|
||||
Result: model.UnitSupportRes{
|
||||
@@ -297,7 +296,7 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(unitSupportResp)
|
||||
CheckErr(err)
|
||||
case "removableSkillInfo":
|
||||
} else if v.Action == "removableSkillInfo" {
|
||||
// key = "owning_equip_result"
|
||||
var skillEquipCount []model.SkillEquipCount
|
||||
err := UserEng.Table("skill_equip_m").Where("user_id = ?", ctx.GetString("userid")).Select("unit_removable_skill_id,COUNT(*) AS ct").
|
||||
@@ -353,7 +352,7 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(rmSkillResp)
|
||||
CheckErr(err)
|
||||
case "accessoryAll":
|
||||
} else if v.Action == "accessoryAll" {
|
||||
// key = "unit_accessory_result"
|
||||
accessoryList := []model.AccessoryList{}
|
||||
err := MainEng.Table("common_accessory_m").Find(&accessoryList)
|
||||
@@ -380,13 +379,13 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(unitAccResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
// case "accessoryTab":
|
||||
// case "accessoryMaterialAll":
|
||||
default:
|
||||
err = errors.New("invalid option")
|
||||
CheckErr(err)
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "costume":
|
||||
if v.Action == "costumeList" {
|
||||
// key = "costume_list_result"
|
||||
costumeListResp := model.CostumeListResp{
|
||||
Result: model.CostumeListRes{
|
||||
@@ -398,7 +397,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(costumeListResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "album":
|
||||
if v.Action == "albumAll" {
|
||||
// key = "album_unit_result"
|
||||
albumLists := []model.AlbumResult{}
|
||||
unitList := []AlbumRes{}
|
||||
@@ -446,7 +449,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(albumResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "scenario":
|
||||
if v.Action == "scenarioStatus" {
|
||||
// key = "scenario_status_result"
|
||||
var scenarioIds []int
|
||||
scenarioLists := []model.ScenarioStatusList{}
|
||||
@@ -468,7 +475,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(scenarioResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "subscenario":
|
||||
if v.Action == "subscenarioStatus" {
|
||||
// key = "subscenario_status_result"
|
||||
var subScenarioIds []int
|
||||
subScenarioLists := []model.SubscenarioStatusList{}
|
||||
@@ -491,7 +502,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(subScenarioResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "eventscenario":
|
||||
if v.Action == "status" {
|
||||
// key = "event_scenario_result"
|
||||
var eventIds []int
|
||||
eventsList := []model.EventScenarioList{}
|
||||
@@ -545,7 +560,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(eventScenarioResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "multiunit":
|
||||
if v.Action == "multiunitscenarioStatus" {
|
||||
// key = "multi_unit_scenario_result"
|
||||
var multiIds []int
|
||||
multiUnitsList := []model.MultiUnitScenarioStatusList{}
|
||||
@@ -584,7 +603,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(unitsResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "payment":
|
||||
if v.Action == "productList" {
|
||||
// key = "product_result"
|
||||
productResp := model.ProductListResp{
|
||||
Result: model.ProductListRes{
|
||||
@@ -608,7 +631,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(productResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "banner":
|
||||
if v.Action == "bannerList" {
|
||||
// key = "banner_result"
|
||||
bannerResp := model.BannerListResp{
|
||||
Result: model.BannerListRes{
|
||||
@@ -617,7 +644,7 @@ func Api(ctx *gin.Context) {
|
||||
{
|
||||
BannerType: 1,
|
||||
TargetID: 1743,
|
||||
AssetPath: "assets/image/secretbox/icon/s_ba_1743_1.png",
|
||||
AssetPath: "assets/image/secretbox/icon/s_ba_1718_1.png",
|
||||
FixedFlag: false,
|
||||
BackSide: false,
|
||||
BannerID: 101151,
|
||||
@@ -625,6 +652,39 @@ func Api(ctx *gin.Context) {
|
||||
EndDate: "2037-12-31 23:59:59",
|
||||
AddUnitStartDate: "2022-01-01 00:00:00",
|
||||
},
|
||||
{
|
||||
BannerType: 1,
|
||||
TargetID: 1741,
|
||||
AssetPath: "assets/image/secretbox/icon/s_ba_1719_1.png",
|
||||
FixedFlag: false,
|
||||
BackSide: false,
|
||||
BannerID: 101150,
|
||||
StartDate: "2013-04-15 00:00:00",
|
||||
EndDate: "2037-12-31 23:59:59",
|
||||
AddUnitStartDate: "2022-01-01 00:00:00",
|
||||
},
|
||||
{
|
||||
BannerType: 1,
|
||||
TargetID: 1740,
|
||||
AssetPath: "assets/image/secretbox/icon/s_ba_1720_1.png",
|
||||
FixedFlag: false,
|
||||
BackSide: false,
|
||||
BannerID: 101149,
|
||||
StartDate: "2013-04-15 00:00:00",
|
||||
EndDate: "2037-12-31 23:59:59",
|
||||
AddUnitStartDate: "2022-01-01 00:00:00",
|
||||
},
|
||||
{
|
||||
BannerType: 1,
|
||||
TargetID: 1739,
|
||||
AssetPath: "assets/image/secretbox/icon/s_ba_1721_1.png",
|
||||
FixedFlag: false,
|
||||
BackSide: false,
|
||||
BannerID: 101144,
|
||||
StartDate: "2013-04-15 00:00:00",
|
||||
EndDate: "2037-12-31 23:59:59",
|
||||
AddUnitStartDate: "2022-01-01 00:00:00",
|
||||
},
|
||||
{
|
||||
BannerType: 2,
|
||||
TargetID: 1,
|
||||
@@ -644,7 +704,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(bannerResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "notice":
|
||||
if v.Action == "noticeMarquee" {
|
||||
// key = "item_marquee_result"
|
||||
marqueeResp := model.NoticeMarqueeResp{
|
||||
Result: model.NoticeMarqueeRes{
|
||||
@@ -657,7 +721,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(marqueeResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "user":
|
||||
if v.Action == "getNavi" {
|
||||
// key = "user_intro_result"
|
||||
var uId, oId int
|
||||
_, err := UserEng.Table("user_preference_m").Where("user_id = ?", ctx.GetString("userid")).Cols("user_id,unit_owning_user_id").Get(&uId, &oId)
|
||||
@@ -675,7 +743,60 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(userIntroResp)
|
||||
CheckErr(err)
|
||||
} else if v.Action == "userInfo" {
|
||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||
CheckErr(err)
|
||||
|
||||
pref := tools.UserPref{}
|
||||
exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", userId).Get(&pref)
|
||||
CheckErr(err)
|
||||
if !exists {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
return
|
||||
}
|
||||
|
||||
userInfoResp := model.ApiUserInfoResp{
|
||||
Result: model.UserInfo{
|
||||
UserID: userId,
|
||||
Name: pref.UserName,
|
||||
Level: config.Conf.UserPrefs.Level,
|
||||
Exp: config.Conf.UserPrefs.ExpNumerator,
|
||||
PreviousExp: 0,
|
||||
NextExp: config.Conf.UserPrefs.ExpDenominator,
|
||||
GameCoin: config.Conf.UserPrefs.GameCoin,
|
||||
SnsCoin: config.Conf.UserPrefs.SnsCoin,
|
||||
FreeSnsCoin: config.Conf.UserPrefs.SnsCoin,
|
||||
PaidSnsCoin: 0,
|
||||
SocialPoint: 1438395,
|
||||
UnitMax: 5000,
|
||||
WaitingUnitMax: 1000,
|
||||
EnergyMax: config.Conf.UserPrefs.EnergyMax,
|
||||
EnergyFullTime: "2023-03-20 03:58:55",
|
||||
LicenseLiveEnergyRecoverlyTime: 60,
|
||||
EnergyFullNeedTime: 0,
|
||||
OverMaxEnergy: config.Conf.UserPrefs.OverMaxEnergy,
|
||||
TrainingEnergy: 100,
|
||||
TrainingEnergyMax: 100,
|
||||
FriendMax: 99,
|
||||
InviteCode: config.Conf.UserPrefs.InviteCode,
|
||||
InsertDate: "2015-08-10 18:58:30",
|
||||
UpdateDate: "2018-08-09 18:13:12",
|
||||
TutorialState: -1,
|
||||
DiamondCoin: 0,
|
||||
CrystalCoin: 0,
|
||||
LpRecoveryItem: []model.LpRecoveryItem{},
|
||||
},
|
||||
Status: 200,
|
||||
CommandNum: false,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
}
|
||||
res, err = json.Marshal(userInfoResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "navigation":
|
||||
if v.Action == "specialCutin" {
|
||||
// key = "special_cutin_result"
|
||||
cutinResp := model.SpecialCutinResp{
|
||||
Result: model.SpecialCutinRes{
|
||||
@@ -687,7 +808,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(cutinResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "award":
|
||||
if v.Action == "awardInfo" {
|
||||
// key = "award_result"
|
||||
var aIdList []int
|
||||
err := MainEng.Table("award_m").Cols("award_id").Find(&aIdList)
|
||||
@@ -719,7 +844,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(awardResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "background":
|
||||
if v.Action == "backgroundInfo" {
|
||||
// key = "background_result"
|
||||
var bIdList []int
|
||||
err := MainEng.Table("background_m").Cols("background_id").Find(&bIdList)
|
||||
@@ -751,7 +880,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(backgroundResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "stamp":
|
||||
if v.Action == "stampInfo" {
|
||||
// key = "stamp_result"
|
||||
stampResp := utils.ReadAllText("assets/sif/stamp.json")
|
||||
var mStampResp any
|
||||
@@ -759,7 +892,11 @@ func Api(ctx *gin.Context) {
|
||||
CheckErr(err)
|
||||
res, err = json.Marshal(mStampResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "exchange":
|
||||
if v.Action == "owningPoint" {
|
||||
// key = "exchange_point_result"
|
||||
var exchangeIds []int
|
||||
exPointsList := []model.ExchangePointList{}
|
||||
@@ -781,7 +918,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(exPointsResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "livese":
|
||||
if v.Action == "liveseInfo" {
|
||||
// key = "live_se_result"
|
||||
liveSeResp := model.LiveSeInfoResp{
|
||||
Result: model.LiveSeInfoRes{
|
||||
@@ -793,7 +934,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(liveSeResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "liveicon":
|
||||
if v.Action == "liveiconInfo" {
|
||||
// key = "live_icon_result"
|
||||
liveIconResp := model.LiveIconInfoResp{
|
||||
Result: model.LiveIconInfoRes{
|
||||
@@ -805,7 +950,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(liveIconResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "item":
|
||||
if v.Action == "list" {
|
||||
// key = "item_list_result"
|
||||
itemResp := utils.ReadAllText("assets/sif/item.json")
|
||||
var mItemResp any
|
||||
@@ -813,7 +962,11 @@ func Api(ctx *gin.Context) {
|
||||
CheckErr(err)
|
||||
res, err = json.Marshal(mItemResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "marathon":
|
||||
if v.Action == "marathonInfo" {
|
||||
// key = "marathon_result"
|
||||
marathonResp := model.MarathonInfoResp{
|
||||
Result: []any{},
|
||||
@@ -823,7 +976,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(marathonResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "challenge":
|
||||
if v.Action == "challengeInfo" {
|
||||
// key = "challenge_result"
|
||||
challengeResp := model.ChallengeInfoResp{
|
||||
Result: []any{},
|
||||
@@ -833,7 +990,11 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(challengeResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "museum":
|
||||
if v.Action == "info" {
|
||||
// key = "museum_result"
|
||||
museumRes := []MuseumRes{}
|
||||
var museumIds []int
|
||||
@@ -864,6 +1025,9 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(museumInfoResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "profile":
|
||||
if v.Action == "liveCnt" {
|
||||
// key = "profile_livecnt_result"
|
||||
@@ -1071,10 +1235,19 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
res, err = json.Marshal(profileResp)
|
||||
CheckErr(err)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
case "secretbox":
|
||||
if v.Action == "all" {
|
||||
res = []byte(utils.ReadAllText("111.json"))
|
||||
// fmt.Println(apiReq)
|
||||
} else {
|
||||
fmt.Println("Invalid action: ", v.Module, v.Action)
|
||||
}
|
||||
default:
|
||||
// fmt.Println(ErrorMsg)
|
||||
fmt.Println(v)
|
||||
// fmt.Println(v)
|
||||
err = errors.New("invalid option")
|
||||
CheckErr(err)
|
||||
}
|
||||
@@ -1094,13 +1267,8 @@ func Api(ctx *gin.Context) {
|
||||
}
|
||||
b, err = json.Marshal(rp)
|
||||
CheckErr(err)
|
||||
// fmt.Println(string(b))
|
||||
|
||||
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(b)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(b))
|
||||
ctx.String(http.StatusOK, string(b))
|
||||
}
|
||||
|
||||
+1
-11
@@ -1,14 +1,10 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/tools"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tidwall/gjson"
|
||||
@@ -29,12 +25,6 @@ func AwardSet(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(awardResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+1
-11
@@ -1,14 +1,10 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/tools"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tidwall/gjson"
|
||||
@@ -29,12 +25,6 @@ func BackgroundSet(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(backgroundResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+5
-38
@@ -1,16 +1,13 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"xorm.io/builder"
|
||||
@@ -52,13 +49,7 @@ func DownloadAdditional(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(addResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -92,13 +83,7 @@ func DownloadBatch(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(batchResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -147,13 +132,7 @@ func DownloadUpdate(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(updateResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -178,13 +157,7 @@ func DownloadUrl(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(urlResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -197,12 +170,6 @@ func DownloadEvent(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(eventResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -31,12 +28,6 @@ func EventList(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(eventsResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -25,12 +22,6 @@ func Gdpr(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(gdprResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/encrypt"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
@@ -33,3 +35,7 @@ func IsSigned(unitId int) bool {
|
||||
|
||||
return exists
|
||||
}
|
||||
|
||||
func GenXMS(resp []byte) string {
|
||||
return base64.StdEncoding.EncodeToString(encrypt.RSASignSHA1(resp))
|
||||
}
|
||||
+1
-10
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -153,12 +150,6 @@ func LBonusExecute(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(LbRes)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+5
-38
@@ -1,12 +1,9 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/utils"
|
||||
"math"
|
||||
@@ -21,13 +18,7 @@ import (
|
||||
func PartyList(ctx *gin.Context) {
|
||||
resp := utils.ReadAllText("assets/sif/partylist.json")
|
||||
|
||||
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([]byte(resp))))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS([]byte(resp)))
|
||||
ctx.String(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
@@ -416,13 +407,7 @@ func PlayLive(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(playResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -435,13 +420,7 @@ func GameOver(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(overResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -527,13 +506,7 @@ func PlayScore(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(playResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -714,12 +687,6 @@ func PlayReward(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(playResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+2
-11
@@ -1,11 +1,8 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -26,10 +23,7 @@ func AuthKey(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(authResp)
|
||||
CheckErr(err)
|
||||
|
||||
xMessageSign := base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp))
|
||||
|
||||
ctx.Header("X-Message-Sign", xMessageSign)
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.JSON(http.StatusOK, authResp)
|
||||
}
|
||||
|
||||
@@ -60,9 +54,6 @@ func Login(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(loginResp)
|
||||
CheckErr(err)
|
||||
|
||||
ctx.Header("user_id", "")
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.JSON(http.StatusOK, loginResp)
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -29,12 +26,6 @@ func MultiUnitStartUp(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(startResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -49,12 +46,6 @@ func MuseumInfo(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(museumResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+3
-24
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -25,13 +22,7 @@ func NoticeFriendVariety(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -48,13 +39,7 @@ func NoticeFriendGreeting(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -72,12 +57,6 @@ func NoticeUserGreeting(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -36,12 +33,6 @@ func ProductList(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(prodReesp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -28,12 +25,6 @@ func PersonalNotice(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(noticeResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ func Handshake(ctx *gin.Context) {
|
||||
|
||||
body64, err := base64.StdEncoding.DecodeString(string(body))
|
||||
CheckErr(err)
|
||||
decryptedBody := encrypt.RSA_Decrypt(body64)
|
||||
decryptedBody := encrypt.RSADecrypt(body64)
|
||||
// fmt.Println(decryptedBody)
|
||||
// fmt.Println(string(decryptedBody))
|
||||
|
||||
|
||||
+1
-11
@@ -1,14 +1,10 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/tools"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tidwall/gjson"
|
||||
@@ -29,12 +25,6 @@ func ProfileRegister(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(profileResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+2
-8
@@ -35,7 +35,7 @@ func ScenarioStartup(ctx *gin.Context) {
|
||||
|
||||
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)))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSASignSHA1(resp)))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
@@ -43,12 +43,6 @@ func ScenarioStartup(ctx *gin.Context) {
|
||||
func ScenarioReward(ctx *gin.Context) {
|
||||
resp := utils.ReadAllText("assets/sif/reward.json")
|
||||
|
||||
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([]byte(resp))))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS([]byte(resp)))
|
||||
ctx.String(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func SubScenarioStartup(ctx *gin.Context) {
|
||||
|
||||
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)))
|
||||
ctx.Header("X-Message-Sign", base64.StdEncoding.EncodeToString(encrypt.RSASignSHA1(resp)))
|
||||
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
@@ -43,12 +43,6 @@ func SubScenarioStartup(ctx *gin.Context) {
|
||||
func SubScenarioReward(ctx *gin.Context) {
|
||||
resp := utils.ReadAllText("assets/sif/subreward.json")
|
||||
|
||||
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([]byte(resp))))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS([]byte(resp)))
|
||||
ctx.String(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -26,12 +23,6 @@ func TosCheck(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(tosResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+5
-37
@@ -1,10 +1,8 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -22,13 +20,7 @@ func SetDisplayRank(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(dispResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -165,13 +157,7 @@ func SetDeck(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(dispResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -207,13 +193,7 @@ func SetDeckName(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(dispResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -271,13 +251,7 @@ func WearAccessory(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(wearResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -336,12 +310,6 @@ func RemoveSkillEquip(ctx *gin.Context) {
|
||||
CheckErr(err)
|
||||
fmt.Println(string(resp))
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+3
-24
@@ -1,10 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/tools"
|
||||
"net/http"
|
||||
@@ -23,13 +20,7 @@ func SetNotificationToken(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(notifResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -48,13 +39,7 @@ func ChangeNavi(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(naviResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -84,12 +69,6 @@ func ChangeName(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(nameResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,11 +1,8 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/tools"
|
||||
"net/http"
|
||||
@@ -71,12 +68,6 @@ func UserInfo(ctx *gin.Context) {
|
||||
resp, err := json.Marshal(userResp)
|
||||
CheckErr(err)
|
||||
|
||||
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)))
|
||||
|
||||
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||
ctx.String(http.StatusOK, string(resp))
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ 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)
|
||||
dummyToken := encrypt.RSADecrypt(tDummyToken)
|
||||
|
||||
// aesKey := dummyToken[0:16]
|
||||
// tAuthData, err := base64.StdEncoding.DecodeString(req.Get("auth_data").String())
|
||||
|
||||
@@ -65,6 +65,9 @@ func Common(ctx *gin.Context) {
|
||||
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||
ctx.Abort()
|
||||
}
|
||||
|
||||
ctx.Header("user_id", 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(), token, nonce, userId, time.Now().Unix()))
|
||||
}
|
||||
|
||||
ctx.Header("Content-Type", "application/json; charset=utf-8")
|
||||
|
||||
+2
-3
@@ -25,12 +25,12 @@ func Login(ctx *gin.Context) {
|
||||
req := gjson.Parse(ctx.GetString("request_data"))
|
||||
tKey, err := base64.StdEncoding.DecodeString(req.Get("login_key").String())
|
||||
CheckErr(err)
|
||||
loginKey := utils.Sub16(encrypt.AES_CBC_Decrypt(tKey, aesKey))
|
||||
loginKey := utils.Sub16(encrypt.AESCBCDecrypt(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))
|
||||
loginPasswd := utils.Sub16(encrypt.AESCBCDecrypt(tPasswd, aesKey))
|
||||
ctx.Set("login_passwd", string(loginPasswd))
|
||||
|
||||
nonce := ctx.GetInt("nonce")
|
||||
@@ -41,5 +41,4 @@ func Login(ctx *gin.Context) {
|
||||
ctx.Set("authorize_token", authorizeToken)
|
||||
|
||||
ctx.Next()
|
||||
|
||||
}
|
||||
|
||||
@@ -15,3 +15,11 @@ type ApiResp struct {
|
||||
ReleaseInfo []any `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
// ApiUserInfoResp ...
|
||||
type ApiUserInfoResp struct {
|
||||
Result UserInfo `json:"result"`
|
||||
Status int `json:"status"`
|
||||
CommandNum bool `json:"commandNum"`
|
||||
TimeStamp int64 `json:"timeStamp"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user