as: Download updates from official server for now
Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
@@ -5,5 +5,8 @@ data
|
||||
temp
|
||||
|
||||
assets/data.db
|
||||
assets/masterdata.db
|
||||
|
||||
static/llas-dev
|
||||
|
||||
.vscode
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"billing_balance_history_list": [],
|
||||
"billing_deposit_history_list": [],
|
||||
"billing_consume_history_list": []
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+82639
File diff suppressed because it is too large
Load Diff
+4972
File diff suppressed because it is too large
Load Diff
+13227
File diff suppressed because it is too large
Load Diff
+13227
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,150 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func CheckErr(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
// eng, err := xorm.NewEngine("sqlite", "assets/masterdata.db")
|
||||
// CheckErr(err)
|
||||
// err = eng.Ping()
|
||||
// CheckErr(err)
|
||||
|
||||
// cardIds := []int{}
|
||||
// err = eng.Table("m_card").Cols("id").OrderBy("id ASC").Find(&cardIds)
|
||||
// CheckErr(err)
|
||||
|
||||
// jsonStr := "["
|
||||
// for _, card := range cardIds {
|
||||
// cardInfo := model.AsCardInfo{
|
||||
// CardMasterID: card,
|
||||
// Level: 1,
|
||||
// Exp: 0,
|
||||
// LovePoint: 0,
|
||||
// IsFavorite: false,
|
||||
// IsAwakening: true,
|
||||
// IsAwakeningImage: true,
|
||||
// IsAllTrainingActivated: false,
|
||||
// TrainingActivatedCellCount: 0,
|
||||
// MaxFreePassiveSkill: 1,
|
||||
// Grade: 0,
|
||||
// TrainingLife: 0,
|
||||
// TrainingAttack: 0,
|
||||
// TrainingDexterity: 0,
|
||||
// ActiveSkillLevel: 1,
|
||||
// PassiveSkillALevel: 1,
|
||||
// PassiveSkillBLevel: 1,
|
||||
// PassiveSkillCLevel: 1,
|
||||
// AdditionalPassiveSkill1ID: 0,
|
||||
// AdditionalPassiveSkill2ID: 0,
|
||||
// AdditionalPassiveSkill3ID: 0,
|
||||
// AdditionalPassiveSkill4ID: 0,
|
||||
// AcquiredAt: int(time.Now().Unix()),
|
||||
// IsNew: false,
|
||||
// }
|
||||
// m, err := json.Marshal(cardInfo)
|
||||
// CheckErr(err)
|
||||
|
||||
// jsonStr += fmt.Sprintf("%d,%s,", card, string(m))
|
||||
// }
|
||||
// jsonStr = strings.TrimRight(jsonStr, ",")
|
||||
// jsonStr += "]"
|
||||
// fmt.Println(jsonStr)
|
||||
|
||||
// packageList := []string{}
|
||||
// urlList := []string{}
|
||||
|
||||
// err := json.Unmarshal([]byte(utils.ReadAllText("data/packages.json")), &packageList)
|
||||
// CheckErr(err)
|
||||
|
||||
// err = json.Unmarshal([]byte(utils.ReadAllText("data/urls.json")), &urlList)
|
||||
// CheckErr(err)
|
||||
|
||||
// if len(packageList) != len(urlList) {
|
||||
// fmt.Println("File size not match!")
|
||||
// return
|
||||
// }
|
||||
|
||||
// packageUrls := map[string]string{}
|
||||
// for k, p := range packageList {
|
||||
// packageUrls[p] = urlList[k]
|
||||
// }
|
||||
|
||||
// // fmt.Println(packageUrls)
|
||||
|
||||
// // packUrlBody := model.PackUrlBody{
|
||||
// // PackNames: []string{
|
||||
// // "cxh9rj",
|
||||
// // "ib3f4p",
|
||||
// // "iwjqao",
|
||||
// // },
|
||||
// // }
|
||||
|
||||
// // hash := "asdfgh"
|
||||
|
||||
// // asReq := []model.AsReq{}
|
||||
// // asReq = append(asReq, packUrlBody)
|
||||
// // asReq = append(asReq, hash)
|
||||
// // mm, err := json.Marshal(asReq)
|
||||
// // CheckErr(err)
|
||||
// // fmt.Println(string(mm))
|
||||
|
||||
// jsonStr := utils.ReadAllText("data/api1.json")
|
||||
// req := []model.AsReq{}
|
||||
// err = json.Unmarshal([]byte(jsonStr), &req)
|
||||
// CheckErr(err)
|
||||
// // fmt.Println(req)
|
||||
|
||||
// packBody, ok := req[0].(map[string]interface{})
|
||||
// if !ok {
|
||||
// panic("Assertion failed!")
|
||||
// }
|
||||
// // fmt.Println(packBody)
|
||||
|
||||
// packNames, ok := packBody["pack_names"].([]interface{})
|
||||
// if !ok {
|
||||
// panic("Assertion failed!")
|
||||
// }
|
||||
|
||||
// respUrls := []string{}
|
||||
// for _, pack := range packNames {
|
||||
// packName, ok := pack.(string)
|
||||
// if !ok {
|
||||
// panic("Assertion failed!")
|
||||
// }
|
||||
// fmt.Println(packageUrls[packName])
|
||||
// respUrls = append(respUrls, packageUrls[packName])
|
||||
// }
|
||||
|
||||
// urlResp := model.PackUrlRespBody{
|
||||
// UrlList: respUrls,
|
||||
// }
|
||||
|
||||
// resp := []model.AsResp{}
|
||||
// resp = append(resp, time.Now().UnixMilli()) // 时间戳
|
||||
// resp = append(resp, config.MasterVersion) // 版本号
|
||||
// resp = append(resp, 0) // 固定值
|
||||
// resp = append(resp, urlResp) // 数据体
|
||||
|
||||
// mm, err := json.Marshal(resp)
|
||||
// CheckErr(err)
|
||||
// // fmt.Println(string(mm))
|
||||
|
||||
// signBody := mm[1 : len(mm)-1]
|
||||
// fmt.Println(string(signBody))
|
||||
|
||||
// sessionKey := "12345678123456781234567812345678"
|
||||
// sign := encrypt.HMAC_SHA1_Encrypt(signBody, []byte(sessionKey))
|
||||
|
||||
// resp = append(resp, sign)
|
||||
// mm, err = json.Marshal(resp)
|
||||
// CheckErr(err)
|
||||
// fmt.Println(string(mm))
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Gin
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -76,3 +77,10 @@ func Common(ctx *gin.Context) {
|
||||
|
||||
ctx.Next()
|
||||
}
|
||||
|
||||
func CommonAs(ctx *gin.Context) {
|
||||
ep := strings.ReplaceAll(ctx.Request.URL.String(), "/ep3071", "")
|
||||
ctx.Set("ep", ep)
|
||||
|
||||
ctx.Next()
|
||||
}
|
||||
|
||||
+221
@@ -1,5 +1,6 @@
|
||||
package model
|
||||
|
||||
/* ==== SIF START ==== */
|
||||
// LoginRes ...
|
||||
type LoginRes struct {
|
||||
AuthorizeToken string `json:"authorize_token"`
|
||||
@@ -17,3 +18,223 @@ type LoginResp struct {
|
||||
ReleaseInfo []interface{} `json:"release_info"`
|
||||
StatusCode int `json:"status_code"`
|
||||
}
|
||||
|
||||
/* ==== SIF END ==== */
|
||||
|
||||
/* ==== AS START ==== */
|
||||
// AsLoginRes ...
|
||||
type AsLoginRes struct {
|
||||
SessionKey string `json:"session_key"`
|
||||
UserModel UserModel `json:"user_model"`
|
||||
IsPlatformServiceLinked bool `json:"is_platform_service_linked"`
|
||||
LastTimestamp int64 `json:"last_timestamp"`
|
||||
Cautions []interface{} `json:"cautions"`
|
||||
ShowHomeCaution bool `json:"show_home_caution"`
|
||||
LiveResume interface{} `json:"live_resume"`
|
||||
FromEea bool `json:"from_eea"`
|
||||
GdprConsentedInfo GdprConsentedInfo `json:"gdpr_consented_info"`
|
||||
UserID int `json:"user_id"`
|
||||
IsUnderAge int `json:"is_under_age"`
|
||||
AreaID int `json:"area_id"`
|
||||
AuthCount int `json:"auth_count"`
|
||||
MemberLovePanels []MemberLovePanels `json:"member_love_panels"`
|
||||
CheckMaintenance bool `json:"check_maintenance"`
|
||||
ReproInfo ReproInfo `json:"repro_info"`
|
||||
}
|
||||
|
||||
// UserModel ...
|
||||
type UserModel struct {
|
||||
UserStatus AsUserStatus `json:"user_status"`
|
||||
UserMemberByMemberID []interface{} `json:"user_member_by_member_id"`
|
||||
UserCardByCardID []interface{} `json:"user_card_by_card_id"`
|
||||
UserSuitBySuitID []interface{} `json:"user_suit_by_suit_id"`
|
||||
UserLiveDeckByID []interface{} `json:"user_live_deck_by_id"`
|
||||
UserLivePartyByID []interface{} `json:"user_live_party_by_id"`
|
||||
UserLessonDeckByID []interface{} `json:"user_lesson_deck_by_id"`
|
||||
UserLiveMvDeckByID []interface{} `json:"user_live_mv_deck_by_id"`
|
||||
UserLiveMvDeckCustomByID []interface{} `json:"user_live_mv_deck_custom_by_id"`
|
||||
UserLiveDifficultyByDifficultyID []interface{} `json:"user_live_difficulty_by_difficulty_id"`
|
||||
UserStoryMainByStoryMainID []interface{} `json:"user_story_main_by_story_main_id"`
|
||||
UserStoryMainSelectedByStoryMainCellID []interface{} `json:"user_story_main_selected_by_story_main_cell_id"`
|
||||
UserVoiceByVoiceID []interface{} `json:"user_voice_by_voice_id"`
|
||||
UserEmblemByEmblemID []interface{} `json:"user_emblem_by_emblem_id"`
|
||||
UserGachaTicketByTicketID []interface{} `json:"user_gacha_ticket_by_ticket_id"`
|
||||
UserGachaPointByPointID []interface{} `json:"user_gacha_point_by_point_id"`
|
||||
UserLessonEnhancingItemByItemID []interface{} `json:"user_lesson_enhancing_item_by_item_id"`
|
||||
UserTrainingMaterialByItemID []interface{} `json:"user_training_material_by_item_id"`
|
||||
UserGradeUpItemByItemID []interface{} `json:"user_grade_up_item_by_item_id"`
|
||||
UserCustomBackgroundByID []interface{} `json:"user_custom_background_by_id"`
|
||||
UserStorySideByID []interface{} `json:"user_story_side_by_id"`
|
||||
UserStoryMemberByID []interface{} `json:"user_story_member_by_id"`
|
||||
UserCommunicationMemberDetailBadgeByID []interface{} `json:"user_communication_member_detail_badge_by_id"`
|
||||
UserStoryEventHistoryByID []interface{} `json:"user_story_event_history_by_id"`
|
||||
UserRecoveryLpByID []interface{} `json:"user_recovery_lp_by_id"`
|
||||
UserRecoveryApByID []interface{} `json:"user_recovery_ap_by_id"`
|
||||
UserMissionByMissionID []interface{} `json:"user_mission_by_mission_id"`
|
||||
UserDailyMissionByMissionID []interface{} `json:"user_daily_mission_by_mission_id"`
|
||||
UserWeeklyMissionByMissionID []interface{} `json:"user_weekly_mission_by_mission_id"`
|
||||
UserInfoTriggerBasicByTriggerID []interface{} `json:"user_info_trigger_basic_by_trigger_id"`
|
||||
UserInfoTriggerCardGradeUpByTriggerID []interface{} `json:"user_info_trigger_card_grade_up_by_trigger_id"`
|
||||
UserInfoTriggerMemberGuildSupportItemExpiredByTriggerID []interface{} `json:"user_info_trigger_member_guild_support_item_expired_by_trigger_id"`
|
||||
UserInfoTriggerMemberLoveLevelUpByTriggerID []interface{} `json:"user_info_trigger_member_love_level_up_by_trigger_id"`
|
||||
UserAccessoryByUserAccessoryID []interface{} `json:"user_accessory_by_user_accessory_id"`
|
||||
UserAccessoryLevelUpItemByID []interface{} `json:"user_accessory_level_up_item_by_id"`
|
||||
UserAccessoryRarityUpItemByID []interface{} `json:"user_accessory_rarity_up_item_by_id"`
|
||||
UserUnlockScenesByEnum []interface{} `json:"user_unlock_scenes_by_enum"`
|
||||
UserSceneTipsByEnum []interface{} `json:"user_scene_tips_by_enum"`
|
||||
UserRuleDescriptionByID []interface{} `json:"user_rule_description_by_id"`
|
||||
UserExchangeEventPointByID []interface{} `json:"user_exchange_event_point_by_id"`
|
||||
UserSchoolIdolFestivalIDRewardMissionByID []interface{} `json:"user_school_idol_festival_id_reward_mission_by_id"`
|
||||
UserGpsPresentReceivedByID []interface{} `json:"user_gps_present_received_by_id"`
|
||||
UserEventMarathonByEventMasterID []interface{} `json:"user_event_marathon_by_event_master_id"`
|
||||
UserEventMiningByEventMasterID []interface{} `json:"user_event_mining_by_event_master_id"`
|
||||
UserEventCoopByEventMasterID []interface{} `json:"user_event_coop_by_event_master_id"`
|
||||
UserLiveSkipTicketByID []interface{} `json:"user_live_skip_ticket_by_id"`
|
||||
UserStoryEventUnlockItemByID []interface{} `json:"user_story_event_unlock_item_by_id"`
|
||||
UserEventMarathonBoosterByID []interface{} `json:"user_event_marathon_booster_by_id"`
|
||||
UserReferenceBookByID []interface{} `json:"user_reference_book_by_id"`
|
||||
UserReviewRequestProcessFlowByID []interface{} `json:"user_review_request_process_flow_by_id"`
|
||||
UserRankExpByID []interface{} `json:"user_rank_exp_by_id"`
|
||||
UserShareByID []interface{} `json:"user_share_by_id"`
|
||||
UserTowerByTowerID []interface{} `json:"user_tower_by_tower_id"`
|
||||
UserRecoveryTowerCardUsedCountItemByRecoveryTowerCardUsedCountItemMasterID []interface{} `json:"user_recovery_tower_card_used_count_item_by_recovery_tower_card_used_count_item_master_id"`
|
||||
UserStoryLinkageByID []interface{} `json:"user_story_linkage_by_id"`
|
||||
UserSubscriptionStatusByID []interface{} `json:"user_subscription_status_by_id"`
|
||||
UserStoryMainPartDigestMovieByID []interface{} `json:"user_story_main_part_digest_movie_by_id"`
|
||||
UserMemberGuildByID []interface{} `json:"user_member_guild_by_id"`
|
||||
UserMemberGuildSupportItemByID []interface{} `json:"user_member_guild_support_item_by_id"`
|
||||
UserDailyTheaterByDailyTheaterID []interface{} `json:"user_daily_theater_by_daily_theater_id"`
|
||||
UserPlayListByID []interface{} `json:"user_play_list_by_id"`
|
||||
}
|
||||
|
||||
// Name ...
|
||||
type Name struct {
|
||||
DotUnderText string `json:"dot_under_text"`
|
||||
}
|
||||
|
||||
// Nickname ...
|
||||
type Nickname struct {
|
||||
DotUnderText string `json:"dot_under_text"`
|
||||
}
|
||||
|
||||
// Message ...
|
||||
type Message struct {
|
||||
DotUnderText string `json:"dot_under_text"`
|
||||
}
|
||||
|
||||
// AsUserStatus ...
|
||||
type AsUserStatus struct {
|
||||
Name Name `json:"name"`
|
||||
Nickname Nickname `json:"nickname"`
|
||||
LastLoginAt int `json:"last_login_at"`
|
||||
Rank int `json:"rank"`
|
||||
Exp int `json:"exp"`
|
||||
Message Message `json:"message"`
|
||||
RecommendCardMasterID int `json:"recommend_card_master_id"`
|
||||
MaxFriendNum int `json:"max_friend_num"`
|
||||
LivePointFullAt int `json:"live_point_full_at"`
|
||||
LivePointBroken int `json:"live_point_broken"`
|
||||
LivePointSubscriptionRecoveryDailyCount int `json:"live_point_subscription_recovery_daily_count"`
|
||||
LivePointSubscriptionRecoveryDailyResetAt int `json:"live_point_subscription_recovery_daily_reset_at"`
|
||||
ActivityPointCount int `json:"activity_point_count"`
|
||||
ActivityPointResetAt int `json:"activity_point_reset_at"`
|
||||
ActivityPointPaymentRecoveryDailyCount int `json:"activity_point_payment_recovery_daily_count"`
|
||||
ActivityPointPaymentRecoveryDailyResetAt int `json:"activity_point_payment_recovery_daily_reset_at"`
|
||||
GameMoney int `json:"game_money"`
|
||||
CardExp int `json:"card_exp"`
|
||||
FreeSnsCoin int `json:"free_sns_coin"`
|
||||
AppleSnsCoin int `json:"apple_sns_coin"`
|
||||
GoogleSnsCoin int `json:"google_sns_coin"`
|
||||
Cash int `json:"cash"`
|
||||
SubscriptionCoin int `json:"subscription_coin"`
|
||||
BirthDate interface{} `json:"birth_date"`
|
||||
BirthMonth int `json:"birth_month"`
|
||||
BirthDay int `json:"birth_day"`
|
||||
LatestLiveDeckID int `json:"latest_live_deck_id"`
|
||||
MainLessonDeckID int `json:"main_lesson_deck_id"`
|
||||
FavoriteMemberID int `json:"favorite_member_id"`
|
||||
LastLiveDifficultyID int `json:"last_live_difficulty_id"`
|
||||
LpMagnification int `json:"lp_magnification"`
|
||||
EmblemID int `json:"emblem_id"`
|
||||
DeviceToken string `json:"device_token"`
|
||||
TutorialPhase int `json:"tutorial_phase"`
|
||||
TutorialEndAt int `json:"tutorial_end_at"`
|
||||
LoginDays int `json:"login_days"`
|
||||
NaviTapCount int `json:"navi_tap_count"`
|
||||
NaviTapRecoverAt int `json:"navi_tap_recover_at"`
|
||||
IsAutoMode bool `json:"is_auto_mode"`
|
||||
MaxScoreLiveDifficultyMasterID int `json:"max_score_live_difficulty_master_id"`
|
||||
LiveMaxScore int `json:"live_max_score"`
|
||||
MaxComboLiveDifficultyMasterID int `json:"max_combo_live_difficulty_master_id"`
|
||||
LiveMaxCombo int `json:"live_max_combo"`
|
||||
LessonResumeStatus int `json:"lesson_resume_status"`
|
||||
AccessoryBoxAdditional int `json:"accessory_box_additional"`
|
||||
TermsOfUseVersion int `json:"terms_of_use_version"`
|
||||
BootstrapSifidCheckAt int `json:"bootstrap_sifid_check_at"`
|
||||
GdprVersion int `json:"gdpr_version"`
|
||||
MemberGuildMemberMasterID int `json:"member_guild_member_master_id"`
|
||||
MemberGuildLastUpdatedAt int `json:"member_guild_last_updated_at"`
|
||||
}
|
||||
|
||||
// GdprConsentedInfo ...
|
||||
type GdprConsentedInfo struct {
|
||||
HasConsentedAdPurposeOfUse bool `json:"has_consented_ad_purpose_of_use"`
|
||||
HasConsentedCrashReport bool `json:"has_consented_crash_report"`
|
||||
}
|
||||
|
||||
// MemberLovePanels ...
|
||||
type MemberLovePanels struct {
|
||||
MemberID int `json:"member_id"`
|
||||
MemberLovePanelCellIds []int `json:"member_love_panel_cell_ids"`
|
||||
}
|
||||
|
||||
// ReproInfo ...
|
||||
type ReproInfo struct {
|
||||
GroupNo int `json:"group_no"`
|
||||
}
|
||||
|
||||
// AsCardInfo ...
|
||||
type AsCardInfo struct {
|
||||
CardMasterID int `json:"card_master_id"`
|
||||
Level int `json:"level"`
|
||||
Exp int `json:"exp"`
|
||||
LovePoint int `json:"love_point"`
|
||||
IsFavorite bool `json:"is_favorite"`
|
||||
IsAwakening bool `json:"is_awakening"`
|
||||
IsAwakeningImage bool `json:"is_awakening_image"`
|
||||
IsAllTrainingActivated bool `json:"is_all_training_activated"`
|
||||
TrainingActivatedCellCount int `json:"training_activated_cell_count"`
|
||||
MaxFreePassiveSkill int `json:"max_free_passive_skill"`
|
||||
Grade int `json:"grade"`
|
||||
TrainingLife int `json:"training_life"`
|
||||
TrainingAttack int `json:"training_attack"`
|
||||
TrainingDexterity int `json:"training_dexterity"`
|
||||
ActiveSkillLevel int `json:"active_skill_level"`
|
||||
PassiveSkillALevel int `json:"passive_skill_a_level"`
|
||||
PassiveSkillBLevel int `json:"passive_skill_b_level"`
|
||||
PassiveSkillCLevel int `json:"passive_skill_c_level"`
|
||||
AdditionalPassiveSkill1ID int `json:"additional_passive_skill_1_id"`
|
||||
AdditionalPassiveSkill2ID int `json:"additional_passive_skill_2_id"`
|
||||
AdditionalPassiveSkill3ID int `json:"additional_passive_skill_3_id"`
|
||||
AdditionalPassiveSkill4ID int `json:"additional_passive_skill_4_id"`
|
||||
AcquiredAt int `json:"acquired_at"`
|
||||
IsNew bool `json:"is_new"`
|
||||
}
|
||||
|
||||
// AsReq ...
|
||||
type AsReq interface{}
|
||||
|
||||
// AsResp ...
|
||||
type AsResp interface{}
|
||||
|
||||
// PackUrlReqBody ...
|
||||
type PackUrlReqBody struct {
|
||||
PackNames []string `json:"pack_names"`
|
||||
}
|
||||
|
||||
// PackUrlRespBody ...
|
||||
type PackUrlRespBody struct {
|
||||
UrlList []string `json:"url_list"`
|
||||
}
|
||||
|
||||
/* ==== AS END ==== */
|
||||
|
||||
+102
-62
@@ -2,11 +2,13 @@ package router
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/handler"
|
||||
"honoka-chan/middleware"
|
||||
"honoka-chan/model"
|
||||
"honoka-chan/utils"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -153,8 +155,8 @@ func SifRouter(r *gin.Engine) {
|
||||
}
|
||||
|
||||
func AsRouter(r *gin.Engine) {
|
||||
|
||||
s := r.Group("ep3071")
|
||||
r.Static("/llas-dev/static", "static/llas-dev/static")
|
||||
s := r.Group("ep3071").Use(middleware.CommonAs)
|
||||
{
|
||||
s.POST("/login/login", func(ctx *gin.Context) {
|
||||
body, err := io.ReadAll(ctx.Request.Body)
|
||||
@@ -172,99 +174,137 @@ func AsRouter(r *gin.Engine) {
|
||||
}
|
||||
return true
|
||||
})
|
||||
fmt.Println("Request data:", req.String())
|
||||
fmt.Println("Mask:", mask)
|
||||
// fmt.Println("Request data:", req.String())
|
||||
// fmt.Println("Mask:", mask)
|
||||
|
||||
mask64, err := base64.StdEncoding.DecodeString(mask)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
randomBytes := encrypt.RSA_DecryptOAEP(mask64, "privatekey.pem")
|
||||
fmt.Println("Random Bytes:", randomBytes)
|
||||
// fmt.Println("Random Bytes:", randomBytes)
|
||||
|
||||
newKey := utils.SliceXor(randomBytes, []byte(sessionKey))
|
||||
newKey64 := base64.StdEncoding.EncodeToString(newKey)
|
||||
|
||||
loginBody := strings.ReplaceAll(utils.ReadAllText("data/login_body.txt"), "SESSION_KEY", newKey64)
|
||||
signBody := fmt.Sprintf("%d,\"%s\",0,%s", time.Now().UnixMilli(), config.MasterVersion, loginBody)
|
||||
|
||||
ep := strings.ReplaceAll(ctx.Request.URL.String(), "/ep3071", "")
|
||||
fmt.Println(ep)
|
||||
|
||||
sign := encrypt.HMAC_SHA1_Encrypt([]byte(ep+" "+signBody), []byte(config.StartUpKey))
|
||||
fmt.Println(sign)
|
||||
|
||||
res := fmt.Sprintf("[%s,\"%s\"]", signBody, sign)
|
||||
// fmt.Println(res)
|
||||
loginBody := strings.ReplaceAll(utils.ReadAllText("assets/login.json"), "SESSION_KEY", newKey64)
|
||||
resp := SignResp(ctx.GetString("ep"), loginBody, config.StartUpKey)
|
||||
|
||||
ctx.Header("Content-Type", "application/json")
|
||||
ctx.String(http.StatusOK, res)
|
||||
ctx.String(http.StatusOK, resp)
|
||||
})
|
||||
s.POST("/bootstrap/fetchBootstrap", func(ctx *gin.Context) {
|
||||
body, err := io.ReadAll(ctx.Request.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer ctx.Request.Body.Close()
|
||||
fmt.Println(string(body))
|
||||
|
||||
ep := strings.ReplaceAll(ctx.Request.URL.String(), "/ep3071", "")
|
||||
fmt.Println(ep)
|
||||
|
||||
bootstrapBody := utils.ReadAllText("data/bootstrap_body.txt")
|
||||
signBody := fmt.Sprintf("%d,\"%s\",0,%s", time.Now().UnixMilli(), config.MasterVersion, bootstrapBody)
|
||||
sign := encrypt.HMAC_SHA1_Encrypt([]byte(ep+" "+signBody), []byte(sessionKey))
|
||||
fmt.Println(sign)
|
||||
|
||||
res := fmt.Sprintf("[%s,\"%s\"]", signBody, sign)
|
||||
// fmt.Println(res)
|
||||
resp := SignResp(ctx.GetString("ep"), utils.ReadAllText("assets/bootstrap.json"), sessionKey)
|
||||
|
||||
ctx.Header("Content-Type", "application/json")
|
||||
ctx.String(http.StatusOK, res)
|
||||
ctx.String(http.StatusOK, resp)
|
||||
})
|
||||
s.POST("/billing/fetchBillingHistory", func(ctx *gin.Context) {
|
||||
body, err := io.ReadAll(ctx.Request.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer ctx.Request.Body.Close()
|
||||
fmt.Println(string(body))
|
||||
|
||||
ep := strings.ReplaceAll(ctx.Request.URL.String(), "/ep3071", "")
|
||||
fmt.Println(ep)
|
||||
|
||||
bootstrapBody := utils.ReadAllText("data/bill_body.txt")
|
||||
signBody := fmt.Sprintf("%d,\"%s\",0,%s", time.Now().UnixMilli(), config.MasterVersion, bootstrapBody)
|
||||
sign := encrypt.HMAC_SHA1_Encrypt([]byte(ep+" "+signBody), []byte(sessionKey))
|
||||
fmt.Println(sign)
|
||||
|
||||
res := fmt.Sprintf("[%s,\"%s\"]", signBody, sign)
|
||||
// fmt.Println(res)
|
||||
resp := SignResp(ctx.GetString("ep"), utils.ReadAllText("assets/billing.json"), sessionKey)
|
||||
|
||||
ctx.Header("Content-Type", "application/json")
|
||||
ctx.String(http.StatusOK, res)
|
||||
ctx.String(http.StatusOK, resp)
|
||||
})
|
||||
s.POST("/notice/fetchNotice", func(ctx *gin.Context) {
|
||||
resp := SignResp(ctx.GetString("ep"), utils.ReadAllText("assets/notice.json"), sessionKey)
|
||||
|
||||
ctx.Header("Content-Type", "application/json")
|
||||
ctx.String(http.StatusOK, resp)
|
||||
})
|
||||
s.POST("/asset/getPackUrl", func(ctx *gin.Context) {
|
||||
body, err := io.ReadAll(ctx.Request.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer ctx.Request.Body.Close()
|
||||
fmt.Println(string(body))
|
||||
// fmt.Println(string(body))
|
||||
|
||||
req := []model.AsReq{}
|
||||
err = json.Unmarshal(body, &req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// fmt.Println(req)
|
||||
|
||||
packBody, ok := req[0].(map[string]interface{})
|
||||
if !ok {
|
||||
panic("Assertion failed!")
|
||||
}
|
||||
// fmt.Println(packBody)
|
||||
|
||||
packNames, ok := packBody["pack_names"].([]interface{})
|
||||
if !ok {
|
||||
panic("Assertion failed!")
|
||||
}
|
||||
|
||||
// 生成更新包 map
|
||||
packageList := []string{}
|
||||
urlList := []string{}
|
||||
|
||||
err = json.Unmarshal([]byte(utils.ReadAllText("assets/packages.json")), &packageList)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(utils.ReadAllText("assets/urls.json")), &urlList)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(packageList) != len(urlList) {
|
||||
fmt.Println("File size not match!")
|
||||
return
|
||||
}
|
||||
|
||||
packageUrls := map[string]string{}
|
||||
for k, p := range packageList {
|
||||
packageUrls[p] = urlList[k]
|
||||
}
|
||||
|
||||
// Response
|
||||
respUrls := []string{}
|
||||
for _, pack := range packNames {
|
||||
packName, ok := pack.(string)
|
||||
if !ok {
|
||||
panic("Assertion failed!")
|
||||
}
|
||||
// fmt.Println(packageUrls[packName])
|
||||
respUrls = append(respUrls, packageUrls[packName])
|
||||
}
|
||||
|
||||
urlResp := model.PackUrlRespBody{
|
||||
UrlList: respUrls,
|
||||
}
|
||||
|
||||
resp := []model.AsResp{}
|
||||
resp = append(resp, time.Now().UnixMilli()) // 时间戳
|
||||
resp = append(resp, config.MasterVersion) // 版本号
|
||||
resp = append(resp, 0) // 固定值
|
||||
resp = append(resp, urlResp) // 数据体
|
||||
|
||||
mm, err := json.Marshal(resp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// fmt.Println(string(mm))
|
||||
|
||||
signBody := mm[1 : len(mm)-1]
|
||||
// fmt.Println(string(signBody))
|
||||
|
||||
ep := strings.ReplaceAll(ctx.Request.URL.String(), "/ep3071", "")
|
||||
fmt.Println(ep)
|
||||
// fmt.Println(ep)
|
||||
|
||||
bootstrapBody := utils.ReadAllText("data/notice_body.txt")
|
||||
signBody := fmt.Sprintf("%d,\"%s\",0,%s", time.Now().UnixMilli(), config.MasterVersion, bootstrapBody)
|
||||
sign := encrypt.HMAC_SHA1_Encrypt([]byte(ep+" "+signBody), []byte(sessionKey))
|
||||
fmt.Println(sign)
|
||||
sign := encrypt.HMAC_SHA1_Encrypt([]byte(ep+" "+string(signBody)), []byte(sessionKey))
|
||||
|
||||
res := fmt.Sprintf("[%s,\"%s\"]", signBody, sign)
|
||||
// fmt.Println(res)
|
||||
resp = append(resp, sign)
|
||||
mm, err = json.Marshal(resp)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// fmt.Println(string(mm))
|
||||
|
||||
ctx.Header("Content-Type", "application/json")
|
||||
ctx.String(http.StatusOK, res)
|
||||
ctx.String(http.StatusOK, string(mm))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/encrypt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func SignResp(ep, body, key string) (resp string) {
|
||||
signBody := fmt.Sprintf("%d,\"%s\",0,%s", time.Now().UnixMilli(), config.MasterVersion, body)
|
||||
sign := encrypt.HMAC_SHA1_Encrypt([]byte(ep+" "+signBody), []byte(key))
|
||||
// fmt.Println(sign)
|
||||
|
||||
resp = fmt.Sprintf("[%s,\"%s\"]", signBody, sign)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user