2023-03-27

Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
2023-03-26 22:21:33 +08:00
parent c4da6c74f8
commit 966606afc2
19 changed files with 804 additions and 77 deletions
+33
View File
@@ -0,0 +1,33 @@
{
"response_data": {
"target_list": [
{
"position": 1,
"is_displayable": false
},
{
"position": 2,
"is_displayable": false
},
{
"position": 3,
"is_displayable": false
},
{
"position": 4,
"is_displayable": false
},
{
"position": 5,
"is_displayable": false
},
{
"position": 6,
"is_displayable": false
}
],
"server_timestamp": 1679238229
},
"release_info": [],
"status_code": 200
}
+20
View File
@@ -0,0 +1,20 @@
{
"response_data": {
"restriction_info": {
"restricted": false
},
"under_age_info": {
"birth_set": true,
"has_limit": false,
"limit_amount": null,
"month_used": 0
},
"sns_product_list": [],
"product_list": [],
"subscription_list": [],
"show_point_shop": true,
"server_timestamp": 1679238244
},
"release_info": [],
"status_code": 200
}
+28
View File
@@ -2,7 +2,9 @@ package database
import ( import (
"context" "context"
"errors"
"honoka-chan/config" "honoka-chan/config"
"strconv"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
) )
@@ -24,3 +26,29 @@ func init() {
panic(err) panic(err)
} }
} }
func GetUid(key string) (int, error) {
uid, err := RedisCli.HGet(RedisCtx, "login_key_uid", key).Result()
if err != nil {
return 0, err
}
userId, err := strconv.Atoi(uid)
if err != nil {
return 0, err
}
if userId == 0 {
return 0, errors.New("userId is 0")
}
return userId, nil
}
func MatchTokenUid(token, uid string) bool {
res, err := RedisCli.HGet(RedisCtx, "token_uid", token).Result()
if err != nil {
panic(err)
}
return res == uid
}
+43 -3
View File
@@ -1,9 +1,15 @@
package handler package handler
import ( import (
"encoding/base64"
"fmt"
"honoka-chan/config" "honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/resp" "honoka-chan/resp"
"honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@@ -13,9 +19,43 @@ func AnnounceIndexHandler(ctx *gin.Context) {
} }
func AnnounceCheckStateHandler(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, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
xms := encrypt.RSA_Sign_SHA1([]byte(resp.AnnounceState), "privatekey.pem")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("Server-Version", config.Conf.Server.VersionNumber) ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
ctx.Header("user_id", "3241988") ctx.Header("user_id", userId[0])
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1679360075&version=1.1&token=4JM3w3i6FDXr4lHN4K2Q5ys7Fn56QMT5ytIzPLCZ0ItuouoraRlfCYPlnzqsFsE1v9Phd66Cw4bmjcKoxE52gd&nonce=12&requestTimeStamp=1679360075") ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", "CGfQ1rVjIRXxdq1zPyfp8aHDyekfCJ6PwzZ+a6JZkXJdyzGZXnFK6ZZ9lup5KLYLXKzSOmbzeOUbTV6lYdE5G+hoP+oVSpnKDGt1NKdoy5IeJihfXVbNjM5AC8NF7d8oMGk/zTVsVqHHENCX4bbMMIQuFP+K+iw2SiRRD1dbZPw=") ctx.Header("X-Message-Sign", xms64)
ctx.String(http.StatusOK, resp.AnnounceState) ctx.String(http.StatusOK, resp.AnnounceState)
} }
+42 -4
View File
@@ -1,17 +1,23 @@
package handler package handler
import ( import (
"encoding/base64"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"honoka-chan/config"
"honoka-chan/database" "honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/model" "honoka-chan/model"
"honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func ApiHandler(ctx *gin.Context) { func ApiHandler(ctx *gin.Context) {
reqTime := time.Now().Unix()
// fmt.Println(ctx.PostForm("request_data")) // fmt.Println(ctx.PostForm("request_data"))
var formdata []model.SifApi var formdata []model.SifApi
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &formdata) err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &formdata)
@@ -166,9 +172,41 @@ func ApiHandler(ctx *gin.Context) {
} }
// fmt.Println(string(b)) // fmt.Println(string(b))
ctx.Header("Server-Version", "97.4.6") authorizeStr := ctx.Request.Header["Authorize"]
ctx.Header("user_id", "3241988") authToken, err := utils.GetAuthorizeToken(authorizeStr)
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1678640521&version=1.1&token=bS5G6TKTsw0aGxVQz8JWJTx8Tf73H0bF9Bq1PEw3UaxoEoUG8GcrrzaEbjOwEQJTrThgHpBlbwnMRl9ITGw1&nonce=9&requestTimeStamp=1678640521") if err != nil {
ctx.Header("X-Message-Sign", "bNuSClKqt20FoGduZJI4pB1Y8xUwrrarvfsq0soqU5U97x7kGLESNoXSQVZcFfa1Eo4kgntEktokmDHzCbxpsYFvrD1mhbn++UOmcwXXCQRdxbbfhTt7MVfXbcqXAuFKAfkE37n9dkn1U0RnNt5U4m3mbRhLYT5B16ZcPGIPn/E=") ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
xms := encrypt.RSA_Sign_SHA1(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)) ctx.String(http.StatusOK, string(b))
} }
+83 -8
View File
@@ -1,22 +1,97 @@
package handler package handler
import ( import (
"encoding/base64"
"fmt"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/utils" "honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func DownloadBatchHandler(ctx *gin.Context) { func DownloadBatchHandler(ctx *gin.Context) {
ctx.Header("user_id", "3241988") reqTime := time.Now().Unix()
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1679236701&version=1.1&token=cHPoOHP5dAs2dh30EkOW8FndO07xlpKHrDRdVOtT7Whlo1opiEMXSwk1JJdAFd4cSeKQvGVRwH2Z7sFh1gnz3gd&nonce=7&requestTimeStamp=1679236698")
ctx.Header("X-Message-Sign", "wlfzdWAcqk2B1wgZvJH+YOC64Zc2TcsKZAftPDwM0FLbzPaQnI2/qtdlzviays2redRCzQjePmJEKhDq8AQjUN0D+sX7lwNtlf5HnmCX7SICglYCPflMg+lsl36yppBNkTT8ZbIKu5znlWJVUIXMIS8k/uUwmfBqeOLna7IJNnI=") authorizeStr := ctx.Request.Header["Authorize"]
ctx.String(http.StatusOK, utils.ReadAllText("assets/batch.json")) authToken, err := utils.GetAuthorizeToken(authorizeStr)
if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
resp := utils.ReadAllText("assets/batch.json")
xms := encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("user_id", userId[0])
ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", xms64)
ctx.String(http.StatusOK, resp)
} }
func DownloadEventHandler(ctx *gin.Context) { func DownloadEventHandler(ctx *gin.Context) {
ctx.Header("user_id", "3241988") reqTime := time.Now().Unix()
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1679236701&version=1.1&token=cHPoOHP5dAs2dh30EkOW8FndO07xlpKHrDRdVOtT7Whlo1opiEMXSwk1JJdAFd4cSeKQvGVRwH2Z7sFh1gnz3gd&nonce=8&requestTimeStamp=1679236698")
ctx.Header("X-Message-Sign", "rFJdTYrGPvG9V/IESgiAZu4qod4VgVTe5/oj8/5fA2mzXhJkKAD7nE8IOI9MQmjwECFYRc4KLPjtqsxuosloIjxTk6pHiAPtGvzkajqBivbbaBIB2OdIZQarqMRURN5M0TGLOC0vzO9xP5fYKJzMHSskJsmMdunPWLkUz3eqoZU=") authorizeStr := ctx.Request.Header["Authorize"]
ctx.String(http.StatusOK, utils.ReadAllText("assets/event.json")) authToken, err := utils.GetAuthorizeToken(authorizeStr)
if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
resp := utils.ReadAllText("assets/event.json")
xms := encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("user_id", userId[0])
ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", xms64)
ctx.String(http.StatusOK, resp)
} }
+57
View File
@@ -0,0 +1,57 @@
package handler
import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/utils"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func 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, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
resp := utils.ReadAllText("assets/eventlist.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)
}
+46 -5
View File
@@ -1,16 +1,57 @@
package handler package handler
import ( import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/utils" "honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func GdprHandler(ctx *gin.Context) { func GdprHandler(ctx *gin.Context) {
ctx.Header("Server-Version", "97.4.6") reqTime := time.Now().Unix()
ctx.Header("user_id", "3241988")
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1679236700&version=1.1&token=cHPoOHP5dAs2dh30EkOW8FndO07xlpKHrDRdVOtT7Whlo1opiEMXSwk1JJdAFd4cSeKQvGVRwH2Z7sFh1gnz3gd&nonce=4&requestTimeStamp=1679236697") authorizeStr := ctx.Request.Header["Authorize"]
ctx.Header("X-Message-Sign", "El2L/coKTfbHF8shto7SjxnukwicN1BtIMhvD21uKy+9ISwH0G2fI4aCemKn77o54H2zv+mVN4osDK0N0Zi86lGyx0rFXMlQ75D7XKX5KbWAhHcgn+W8t6tk2R0PVUyEeo1gtHgjNauT1asNK+PDJ7h3WWINPFgfVSnldCUnYLk=") authToken, err := utils.GetAuthorizeToken(authorizeStr)
ctx.String(http.StatusOK, utils.ReadAllText("assets/gdpr.json")) if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
resp := utils.ReadAllText("assets/gdpr.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)
} }
+46 -5
View File
@@ -1,16 +1,57 @@
package handler package handler
import ( import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/utils" "honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func LBonusExecuteHandler(ctx *gin.Context) { func LBonusExecuteHandler(ctx *gin.Context) {
ctx.Header("Server-Version", "97.4.6") reqTime := time.Now().Unix()
ctx.Header("user_id", "3241988")
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1679236701&version=1.1&token=cHPoOHP5dAs2dh30EkOW8FndO07xlpKHrDRdVOtT7Whlo1opiEMXSwk1JJdAFd4cSeKQvGVRwH2Z7sFh1gnz3gd&nonce=9&requestTimeStamp=1679236698") authorizeStr := ctx.Request.Header["Authorize"]
ctx.Header("X-Message-Sign", "pV5H3WfRtj2zpDYuYwt9BuB8jMUJiXrGXQbsemJA+8sX7/c9s4mnbMFTKDD3cxK1mSeCLNhJVtR1M6QKZVgbCjyQGSVPR1EG1cTumR9T5LFF6ighJWV7EEYxbeYgJjAEcjVHOgB3d2hy7SK7u4oCatEgXhbJMQYGV5lH2gdwEpw=") authToken, err := utils.GetAuthorizeToken(authorizeStr)
ctx.String(http.StatusOK, utils.ReadAllText("assets/lbonus.json")) if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
resp := utils.ReadAllText("assets/lbonus.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)
} }
+25 -23
View File
@@ -9,8 +9,6 @@ import (
"honoka-chan/model" "honoka-chan/model"
"honoka-chan/utils" "honoka-chan/utils"
"net/http" "net/http"
"net/url"
"strconv"
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@@ -18,17 +16,19 @@ import (
func AuthKeyHandler(ctx *gin.Context) { func AuthKeyHandler(ctx *gin.Context) {
reqTime := time.Now().Unix() reqTime := time.Now().Unix()
authReq := model.AuthKeyReq{} authReq := model.AuthKeyReq{}
err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &authReq) err := json.Unmarshal([]byte(ctx.PostForm("request_data")), &authReq)
if err != nil { if err != nil {
panic(err) panic(err)
} }
dummyToken64, err := base64.StdEncoding.DecodeString(authReq.DummyToken) dummyToken64, err := base64.StdEncoding.DecodeString(authReq.DummyToken)
if err != nil { if err != nil {
panic(err) panic(err)
} }
dummyTokenDecrypted := encrypt.RSA_Decrypt(dummyToken64, "privatekey.pem") dummyTokenDecrypted := encrypt.RSA_Decrypt(dummyToken64, "privatekey.pem")
clientToken := base64.RawStdEncoding.EncodeToString(dummyTokenDecrypted)
aesKey := dummyTokenDecrypted[0:16] aesKey := dummyTokenDecrypted[0:16]
data64, err := base64.StdEncoding.DecodeString(authReq.AuthData) data64, err := base64.StdEncoding.DecodeString(authReq.AuthData)
if err != nil { if err != nil {
@@ -44,10 +44,10 @@ func AuthKeyHandler(ctx *gin.Context) {
nonce++ nonce++
clientToken := base64.RawStdEncoding.EncodeToString(dummyTokenDecrypted)
authData := map[string]interface{}{ authData := map[string]interface{}{
"client_token": clientToken, "client_token": clientToken,
"server_token": serverToken, "server_token": serverToken,
"nonce": nonce,
} }
_, err = database.RedisCli.HSet(database.RedisCtx, authorizeToken, authData).Result() _, err = database.RedisCli.HSet(database.RedisCtx, authorizeToken, authData).Result()
if err != nil { if err != nil {
@@ -79,29 +79,21 @@ func AuthKeyHandler(ctx *gin.Context) {
func LoginHandler(ctx *gin.Context) { func LoginHandler(ctx *gin.Context) {
reqTime := time.Now().Unix() reqTime := time.Now().Unix()
authorizeStr := ctx.Request.Header["Authorize"] authorizeStr := ctx.Request.Header["Authorize"]
if len(authorizeStr) == 0 { authToken, err := utils.GetAuthorizeToken(authorizeStr)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
fmt.Println(authorizeStr[0])
urlParams, err := url.ParseQuery(authorizeStr[0])
if err != nil { if err != nil {
panic(err)
}
fmt.Println(urlParams)
authToken := urlParams["token"]
if len(authToken) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!") ctx.String(http.StatusForbidden, "Fuck you!")
return return
} }
authData, err := database.RedisCli.HGetAll(database.RedisCtx, authToken[0]).Result()
authData, err := database.RedisCli.HGetAll(database.RedisCtx, authToken).Result()
if err != nil { if err != nil {
panic(err) panic(err)
} }
fmt.Println(authData) fmt.Println(authData)
clientToken, serverToken, clientNonce := authData["client_token"], authData["server_token"], authData["nonce"]
fmt.Println(clientToken) clientToken, serverToken := authData["client_token"], authData["server_token"]
clientToken64, err := base64.RawStdEncoding.DecodeString(clientToken) clientToken64, err := base64.RawStdEncoding.DecodeString(clientToken)
if err != nil { if err != nil {
panic(err) panic(err)
@@ -110,9 +102,10 @@ func LoginHandler(ctx *gin.Context) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
xmcKey := utils.SliceXor([]byte(clientToken64), []byte(serverToken64)) xmcKey := utils.SliceXor([]byte(clientToken64), []byte(serverToken64))
fmt.Println(xmcKey)
aesKey := xmcKey[0:16] aesKey := xmcKey[0:16]
loginReq := model.LoginReq{} loginReq := model.LoginReq{}
err = json.Unmarshal([]byte(ctx.PostForm("request_data")), &loginReq) err = json.Unmarshal([]byte(ctx.PostForm("request_data")), &loginReq)
if err != nil { if err != nil {
@@ -131,16 +124,25 @@ func LoginHandler(ctx *gin.Context) {
passDescrypted := utils.Sub16(encrypt.AES_CBC_Decrypt(pass64, aesKey)) passDescrypted := utils.Sub16(encrypt.AES_CBC_Decrypt(pass64, aesKey))
fmt.Println(string(passDescrypted)) fmt.Println(string(passDescrypted))
nonce, _ = strconv.Atoi(clientNonce) nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++ nonce++
authorizeToken := utils.RandomBase64Token(32) userId, err := database.GetUid(string(keyDescrypted))
uid, err := database.RedisCli.HGet(database.RedisCtx, "login_key_uid", string(keyDescrypted)).Result()
if err != nil { if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!") ctx.String(http.StatusForbidden, "Fuck you!")
return return
} }
userId, _ := strconv.Atoi(uid) authorizeToken := utils.RandomBase64Token(32)
_, err = database.RedisCli.HSet(database.RedisCtx, "token_uid", authorizeToken, userId).Result()
if err != nil {
panic(err)
}
loginResp := model.LoginResp{} loginResp := model.LoginResp{}
loginResp.ResponseData.AuthorizeToken = authorizeToken loginResp.ResponseData.AuthorizeToken = authorizeToken
+57
View File
@@ -0,0 +1,57 @@
package handler
import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/utils"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func 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, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
resp := utils.ReadAllText("assets/products.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)
}
+46 -5
View File
@@ -1,16 +1,57 @@
package handler package handler
import ( import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/utils" "honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func PersonalNoticeHandler(ctx *gin.Context) { func PersonalNoticeHandler(ctx *gin.Context) {
ctx.Header("Server-Version", "97.4.6") reqTime := time.Now().Unix()
ctx.Header("user_id", "3241988")
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1679236701&version=1.1&token=cHPoOHP5dAs2dh30EkOW8FndO07xlpKHrDRdVOtT7Whlo1opiEMXSwk1JJdAFd4cSeKQvGVRwH2Z7sFh1gnz3gd&nonce=5&requestTimeStamp=1679236697") authorizeStr := ctx.Request.Header["Authorize"]
ctx.Header("X-Message-Sign", "mTvY9EUM4LAomFxHQPINslVF8KBJ/nWZvCmVzYYyFln+M23/T05cuT/E6FUt9ExwmGMFy6TqtbZwcoomFWaEm38uJH2nQy/3RDjS0L26AsyFOHDIUOK11a4qHxv309sRjb04KhckTmzJERTooCnRturTYcNYet0g01vz2Geu4Ew=") authToken, err := utils.GetAuthorizeToken(authorizeStr)
ctx.String(http.StatusOK, utils.ReadAllText("assets/personalnotice.json")) if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
resp := utils.ReadAllText("assets/personalnotice.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)
} }
+47 -11
View File
@@ -1,22 +1,58 @@
package handler package handler
import ( import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/resp"
"honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func ScenarioStartupHandler(ctx *gin.Context) { func ScenarioStartupHandler(ctx *gin.Context) {
ctx.Header("Content-Type", "application/json") reqTime := time.Now().Unix()
ctx.Header("X-Powered-By", "KLab Native APP Platform")
ctx.Header("server_version", "20120129")
ctx.Header("Server-Version", "97.4.6")
ctx.Header("user_id", "3241988")
ctx.Header("version_up", "0")
ctx.Header("status_code", "200")
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1678786443&version=1.1&token=2gjbstqCHAlIv600Pk0AJN5uvfPYgLvfSKB418sMIoclOy1M9UP7LUC1CG14tPicVzOq2MBOXLvpmNRwyWIi9Qf&nonce=17&requestTimeStamp=1678786443")
ctx.Header("X-Message-Sign", "L+cK2fiaDxkRwJCmT6lpMu9RM/emmUye32RtS8C36I7OpBhGiZLbiPN30dPXITWDIUjUyPsVCqvLVzEy484Q+NHvQfDEUuS5SnKOtoNxW9Zk6kjyckjJKFIbsdH61cbb4pfzmSptcaByZ6ieNIpbHTzsvpu54JFOXb84g859Pxs=")
res := `{"response_data":{"scenario_id":1,"scenario_adjustment":50,"server_timestamp":1678785161},"release_info":[],"status_code":200}` authorizeStr := ctx.Request.Header["Authorize"]
ctx.String(http.StatusOK, res) authToken, err := utils.GetAuthorizeToken(authorizeStr)
if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
xms := encrypt.RSA_Sign_SHA1([]byte(resp.ScenarioStartup), "privatekey.pem")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
ctx.Header("user_id", userId[0])
ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", xms64)
ctx.String(http.StatusOK, resp.ScenarioStartup)
} }
+44 -4
View File
@@ -1,15 +1,55 @@
package handler package handler
import ( import (
"encoding/base64"
"fmt"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/utils" "honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func TosCheckHandler(ctx *gin.Context) { func TosCheckHandler(ctx *gin.Context) {
ctx.Header("user_id", "3241988") reqTime := time.Now().Unix()
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1679236701&version=1.1&token=cHPoOHP5dAs2dh30EkOW8FndO07xlpKHrDRdVOtT7Whlo1opiEMXSwk1JJdAFd4cSeKQvGVRwH2Z7sFh1gnz3gd&nonce=6&requestTimeStamp=1679236698")
ctx.Header("X-Message-Sign", "3OYeXseR08OvVJfG9cEU6CbEXwbjAhL93vTEL6G4i3FqCY5wpELp0XR8FVZeHo7wsO9UI3+5JJZylnlWvaPgaXej2oefsk5cWHO2rKvrPxaqWRfz5YeGZBvXQejY81KgRRZBWZaQBlHEacH+aILl608xwQGQ98wGtyyMYfOf4Ss=") authorizeStr := ctx.Request.Header["Authorize"]
ctx.String(http.StatusOK, utils.ReadAllText("assets/toscheck.json")) authToken, err := utils.GetAuthorizeToken(authorizeStr)
if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
resp := utils.ReadAllText("assets/toscheck.json")
xms := encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("user_id", userId[0])
ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", xms64)
ctx.String(http.StatusOK, resp)
} }
+87 -4
View File
@@ -1,16 +1,99 @@
package handler package handler
import ( import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/resp" "honoka-chan/resp"
"honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func SetNotificationTokenHandler(ctx *gin.Context) { func SetNotificationTokenHandler(ctx *gin.Context) {
ctx.Header("Server-Version", "97.4.6") reqTime := time.Now().Unix()
ctx.Header("user_id", "3241988")
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1678891478&version=1.1&token=cTMEyAfIDErcKUyCgBM6ZuJv8UBRgSzG4z4MfqYhR7xSHBYhIA9ofaVKtSefeiP2LTKIfbnCfE5dppYw8Af&nonce=18&requestTimeStamp=1678891478") authorizeStr := ctx.Request.Header["Authorize"]
ctx.Header("X-Message-Sign", "bNZj/YjRADDccb5vcF/NHI9Kin3bkM3ECBQdxttXvCBqzoSBX6yWuEn9Fsjx+Yp3g2D9CcONZzqJlAvXbatGHJkbClSXuomLXVOcNmQYgidjyUvC7CceoSvCbL8U4Ge12tyGd8V2EMHVZfxqPKdHsJSGaOFbUpmo7wAhKVfuEjg=") authToken, err := utils.GetAuthorizeToken(authorizeStr)
if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
xms := encrypt.RSA_Sign_SHA1([]byte(resp.NotificationToken), "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.NotificationToken)
}
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, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
xms := encrypt.RSA_Sign_SHA1([]byte(resp.NotificationToken), "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.NotificationToken) ctx.String(http.StatusOK, resp.NotificationToken)
} }
+46 -5
View File
@@ -1,16 +1,57 @@
package handler package handler
import ( import (
"encoding/base64"
"fmt"
"honoka-chan/config"
"honoka-chan/database"
"honoka-chan/encrypt"
"honoka-chan/utils" "honoka-chan/utils"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
func UserInfoHandler(ctx *gin.Context) { func UserInfoHandler(ctx *gin.Context) {
ctx.Header("Server-Version", "97.4.6") reqTime := time.Now().Unix()
ctx.Header("user_id", "3241988")
ctx.Header("authorize", "consumerKey=lovelive_test&timeStamp=1679236700&version=1.1&token=cHPoOHP5dAs2dh30EkOW8FndO07xlpKHrDRdVOtT7Whlo1opiEMXSwk1JJdAFd4cSeKQvGVRwH2Z7sFh1gnz3gd&nonce=3&requestTimeStamp=1679236697") authorizeStr := ctx.Request.Header["Authorize"]
ctx.Header("X-Message-Sign", "mGcmcvrm22pt5zJw1CJxe/6Y9R4aZPb6znja4jxioWHlinjWU5nEq61qyslW0bX6uVWTifz17eSDdidlJHccusbQaKXOyoFfbQC1hpArv97b3RJGrnDK7iShPOTz3+mwYiUhtXrJ3oohRGH1siEG0G3H4pSK3JHnAbPlF84cR4w=") authToken, err := utils.GetAuthorizeToken(authorizeStr)
ctx.String(http.StatusOK, utils.ReadAllText("assets/userinfo.json")) if err != nil {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
userId := ctx.Request.Header[http.CanonicalHeaderKey("User-ID")]
if len(userId) == 0 {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
if !database.MatchTokenUid(authToken, userId[0]) {
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce, err := utils.GetAuthorizeNonce(authorizeStr)
if err != nil {
fmt.Println(err)
ctx.String(http.StatusForbidden, "Fuck you!")
return
}
nonce++
respTime := time.Now().Unix()
newAuthorizeStr := fmt.Sprintf("consumerKey=lovelive_test&timeStamp=%d&version=1.1&token=%s&nonce=%d&user_id=%s&requestTimeStamp=%d", respTime, authToken, nonce, userId[0], reqTime)
// fmt.Println(newAuthorizeStr)
resp := utils.ReadAllText("assets/userinfo.json")
xms := encrypt.RSA_Sign_SHA1([]byte(resp), "privatekey.pem")
xms64 := base64.RawStdEncoding.EncodeToString(xms)
ctx.Header("Server-Version", config.Conf.Server.VersionNumber)
ctx.Header("user_id", userId[0])
ctx.Header("authorize", newAuthorizeStr)
ctx.Header("X-Message-Sign", xms64)
ctx.String(http.StatusOK, resp)
} }
+3
View File
@@ -43,6 +43,9 @@ func main() {
r.POST("/main.php/announce/checkState", handler.AnnounceCheckStateHandler) r.POST("/main.php/announce/checkState", handler.AnnounceCheckStateHandler)
r.POST("/main.php/scenario/startup", handler.ScenarioStartupHandler) r.POST("/main.php/scenario/startup", handler.ScenarioStartupHandler)
r.POST("/main.php/user/setNotificationToken", handler.SetNotificationTokenHandler) r.POST("/main.php/user/setNotificationToken", handler.SetNotificationTokenHandler)
r.POST("/main.php/user/changeNavi", handler.SetNotificationTokenHandler)
r.POST("/main.php/event/eventList", handler.EventListHandler)
r.POST("/main.php/payment/productList", handler.ProductListHandler)
r.Run(":8080") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") r.Run(":8080") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
} }
+1
View File
@@ -3,4 +3,5 @@ package resp
var ( var (
AnnounceState = `{"response_data":{"has_unread_announce":false,"server_timestamp":1679360075},"release_info":[],"status_code":200}` AnnounceState = `{"response_data":{"has_unread_announce":false,"server_timestamp":1679360075},"release_info":[],"status_code":200}`
NotificationToken = `{"response_data":[],"release_info":[],"status_code":200}` NotificationToken = `{"response_data":[],"release_info":[],"status_code":200}`
ScenarioStartup = `{"response_data":{"scenario_id":1,"scenario_adjustment":50,"server_timestamp":1678785161},"release_info":[],"status_code":200}`
) )
+50
View File
@@ -6,8 +6,11 @@ package utils
import ( import (
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
"errors"
"math/rand" "math/rand"
"net/url"
"os" "os"
"strconv"
"time" "time"
) )
@@ -58,3 +61,50 @@ func RandomBase64Token(len int) string {
return base64.RawStdEncoding.EncodeToString([]byte(mRandStr)) return base64.RawStdEncoding.EncodeToString([]byte(mRandStr))
} }
func ParseAuthorizeStr(authorize []string) (url.Values, error) {
if len(authorize) == 0 {
return nil, errors.New("authorize is null")
}
urlParams, err := url.ParseQuery(authorize[0])
if err != nil {
return nil, err
}
return urlParams, nil
}
func GetAuthorizeToken(authorize []string) (string, error) {
params, err := ParseAuthorizeStr(authorize)
if err != nil {
return "", err
}
token := params["token"]
if len(token) == 0 {
return "", errors.New("token is null")
}
return token[0], nil
}
func GetAuthorizeNonce(authorize []string) (int, error) {
params, err := ParseAuthorizeStr(authorize)
if err != nil {
return 0, err
}
nonce := params["nonce"]
if len(nonce) == 0 {
return 0, errors.New("nonce is null")
}
n_nonce, err := strconv.Atoi(nonce[0])
if err != nil {
return 0, err
}
if n_nonce == 0 {
return 0, errors.New("nonce is 0")
}
return n_nonce, nil
}