@@ -0,0 +1,58 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"honoka-chan/config"
|
||||
"honoka-chan/database"
|
||||
"honoka-chan/encrypt"
|
||||
"honoka-chan/resp"
|
||||
"honoka-chan/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func SetDisplayRankHandler(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 := resp.NotificationToken
|
||||
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)
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"honoka-chan/sifcap"
|
||||
_ "honoka-chan/tools"
|
||||
"honoka-chan/xclog"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -23,6 +24,10 @@ func main() {
|
||||
r := gin.Default()
|
||||
r.Use(middleware.KlabHeader)
|
||||
|
||||
r.Any("/", func(ctx *gin.Context) {
|
||||
ctx.String(http.StatusOK, "Hello, world!")
|
||||
})
|
||||
|
||||
r.GET("/webview.php/announce/index", handler.AnnounceIndexHandler)
|
||||
|
||||
r.POST("/main.php/login/authkey", handler.AuthKeyHandler)
|
||||
@@ -44,6 +49,8 @@ func main() {
|
||||
r.POST("/main.php/live/partyList", handler.PartyListHandler)
|
||||
r.POST("/main.php/live/play", handler.PlayLiveHandler)
|
||||
r.POST("/main.php/live/gameover", handler.GameOverHandler)
|
||||
r.POST("/main.php/unit/setDisplayRank", handler.SetDisplayRankHandler)
|
||||
r.POST("/main.php/unit/favorite", handler.SetDisplayRankHandler)
|
||||
|
||||
r.Run(":8080") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,5 +5,5 @@ func init() {
|
||||
AnalysisApi2Data("assets/api2.json")
|
||||
AnalysisApi3Data("assets/api3.json")
|
||||
// ListUnitData()
|
||||
go SyncNotesList()
|
||||
// go SyncNotesList()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user