+6
-6
@@ -10,32 +10,32 @@ var (
|
|||||||
iv = []byte("12345678abcdefgh")
|
iv = []byte("12345678abcdefgh")
|
||||||
)
|
)
|
||||||
|
|
||||||
func Padding(plainText []byte, blockSize int) []byte {
|
func padding(plainText []byte, blockSize int) []byte {
|
||||||
n := blockSize - len(plainText)%blockSize
|
n := blockSize - len(plainText)%blockSize
|
||||||
temp := bytes.Repeat([]byte{byte(n)}, n)
|
temp := bytes.Repeat([]byte{byte(n)}, n)
|
||||||
plainText = append(plainText, temp...)
|
plainText = append(plainText, temp...)
|
||||||
return plainText
|
return plainText
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnPadding(cipherText []byte) []byte {
|
func unPadding(cipherText []byte) []byte {
|
||||||
end := cipherText[len(cipherText)-1]
|
end := cipherText[len(cipherText)-1]
|
||||||
cipherText = cipherText[:len(cipherText)-int(end)]
|
cipherText = cipherText[:len(cipherText)-int(end)]
|
||||||
return cipherText
|
return cipherText
|
||||||
}
|
}
|
||||||
|
|
||||||
func AES_CBC_Encrypt(plainText []byte, key []byte) []byte {
|
func AESCBCEncrypt(plainText []byte, key []byte) []byte {
|
||||||
block, err := aes.NewCipher(key)
|
block, err := aes.NewCipher(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
plainText = Padding(plainText, block.BlockSize())
|
plainText = padding(plainText, block.BlockSize())
|
||||||
blockMode := cipher.NewCBCEncrypter(block, iv)
|
blockMode := cipher.NewCBCEncrypter(block, iv)
|
||||||
cipherText := make([]byte, len(plainText))
|
cipherText := make([]byte, len(plainText))
|
||||||
blockMode.CryptBlocks(cipherText, plainText)
|
blockMode.CryptBlocks(cipherText, plainText)
|
||||||
return cipherText
|
return cipherText
|
||||||
}
|
}
|
||||||
|
|
||||||
func AES_CBC_Decrypt(cipherText []byte, key []byte) []byte {
|
func AESCBCDecrypt(cipherText []byte, key []byte) []byte {
|
||||||
block, err := aes.NewCipher(key)
|
block, err := aes.NewCipher(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -43,6 +43,6 @@ func AES_CBC_Decrypt(cipherText []byte, key []byte) []byte {
|
|||||||
plainText := make([]byte, len(cipherText))
|
plainText := make([]byte, len(cipherText))
|
||||||
blockMode := cipher.NewCBCDecrypter(block, iv)
|
blockMode := cipher.NewCBCDecrypter(block, iv)
|
||||||
blockMode.CryptBlocks(plainText, cipherText)
|
blockMode.CryptBlocks(plainText, cipherText)
|
||||||
plainText = UnPadding(plainText)
|
plainText = unPadding(plainText)
|
||||||
return plainText
|
return plainText
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -13,7 +13,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RSA_Gen(bits int) {
|
func RSAGen(bits int) {
|
||||||
//get current path
|
//get current path
|
||||||
_, currentpath, _, _ := runtime.Caller(0)
|
_, currentpath, _, _ := runtime.Caller(0)
|
||||||
currentpath = filepath.Dir(currentpath)
|
currentpath = filepath.Dir(currentpath)
|
||||||
@@ -75,7 +75,7 @@ func RSA_Gen(bits int) {
|
|||||||
pem.Encode(publickeyfile, &publickeyblock)
|
pem.Encode(publickeyfile, &publickeyblock)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RSA_Encrypt(plainText []byte, publickeypath string) []byte {
|
func RSAEncrypt(plainText []byte, publickeypath string) []byte {
|
||||||
//open publickeyfile
|
//open publickeyfile
|
||||||
publickeyfile, err := os.Open(publickeypath)
|
publickeyfile, err := os.Open(publickeypath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -110,7 +110,7 @@ func RSA_Encrypt(plainText []byte, publickeypath string) []byte {
|
|||||||
return cipherText
|
return cipherText
|
||||||
}
|
}
|
||||||
|
|
||||||
func RSA_Decrypt(cipherText []byte) []byte {
|
func RSADecrypt(cipherText []byte) []byte {
|
||||||
//open privatekeyfile
|
//open privatekeyfile
|
||||||
privatekeyfile, err := os.Open(config.PrivateKeyPath)
|
privatekeyfile, err := os.Open(config.PrivateKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -138,7 +138,7 @@ func RSA_Decrypt(cipherText []byte) []byte {
|
|||||||
return plainText
|
return plainText
|
||||||
}
|
}
|
||||||
|
|
||||||
func RSA_Sign_SHA1(cipherText []byte) []byte {
|
func RSASignSHA1(cipherText []byte) []byte {
|
||||||
//open privatekeyfile
|
//open privatekeyfile
|
||||||
privatekeyfile, err := os.Open(config.PrivateKeyPath)
|
privatekeyfile, err := os.Open(config.PrivateKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+1
-11
@@ -1,13 +1,9 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@@ -81,12 +77,6 @@ func AlbumSeriesAll(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(albumResp)
|
resp, err := json.Marshal(albumResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -34,12 +31,6 @@ func AnnounceCheckState(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(announceResp)
|
resp, err := json.Marshal(announceResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+640
-472
File diff suppressed because it is too large
Load Diff
+1
-11
@@ -1,14 +1,10 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/tools"
|
"honoka-chan/tools"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
@@ -29,12 +25,6 @@ func AwardSet(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(awardResp)
|
resp, err := json.Marshal(awardResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-11
@@ -1,14 +1,10 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/tools"
|
"honoka-chan/tools"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
@@ -29,12 +25,6 @@ func BackgroundSet(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(backgroundResp)
|
resp, err := json.Marshal(backgroundResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-38
@@ -1,16 +1,13 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/config"
|
"honoka-chan/config"
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
@@ -52,13 +49,7 @@ func DownloadAdditional(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(addResp)
|
resp, err := json.Marshal(addResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,13 +83,7 @@ func DownloadBatch(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(batchResp)
|
resp, err := json.Marshal(batchResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,13 +132,7 @@ func DownloadUpdate(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(updateResp)
|
resp, err := json.Marshal(updateResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,13 +157,7 @@ func DownloadUrl(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(urlResp)
|
resp, err := json.Marshal(urlResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,12 +170,6 @@ func DownloadEvent(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(eventResp)
|
resp, err := json.Marshal(eventResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -31,12 +28,6 @@ func EventList(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(eventsResp)
|
resp, err := json.Marshal(eventsResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -25,12 +22,6 @@ func Gdpr(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(gdprResp)
|
resp, err := json.Marshal(gdprResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"honoka-chan/config"
|
"honoka-chan/config"
|
||||||
|
"honoka-chan/encrypt"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
@@ -33,3 +35,7 @@ func IsSigned(unitId int) bool {
|
|||||||
|
|
||||||
return exists
|
return exists
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenXMS(resp []byte) string {
|
||||||
|
return base64.StdEncoding.EncodeToString(encrypt.RSASignSHA1(resp))
|
||||||
|
}
|
||||||
+1
-10
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -153,12 +150,6 @@ func LBonusExecute(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(LbRes)
|
resp, err := json.Marshal(LbRes)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-38
@@ -1,12 +1,9 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/config"
|
"honoka-chan/config"
|
||||||
"honoka-chan/database"
|
"honoka-chan/database"
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/utils"
|
||||||
"math"
|
"math"
|
||||||
@@ -21,13 +18,7 @@ import (
|
|||||||
func PartyList(ctx *gin.Context) {
|
func PartyList(ctx *gin.Context) {
|
||||||
resp := utils.ReadAllText("assets/sif/partylist.json")
|
resp := utils.ReadAllText("assets/sif/partylist.json")
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS([]byte(resp)))
|
||||||
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.String(http.StatusOK, resp)
|
ctx.String(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,13 +407,7 @@ func PlayLive(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(playResp)
|
resp, err := json.Marshal(playResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,13 +420,7 @@ func GameOver(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(overResp)
|
resp, err := json.Marshal(overResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,13 +506,7 @@ func PlayScore(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(playResp)
|
resp, err := json.Marshal(playResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,12 +687,6 @@ func PlayReward(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(playResp)
|
resp, err := json.Marshal(playResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-11
@@ -1,11 +1,8 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/database"
|
"honoka-chan/database"
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -26,10 +23,7 @@ func AuthKey(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(authResp)
|
resp, err := json.Marshal(authResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
xMessageSign := base64.StdEncoding.EncodeToString(encrypt.RSA_Sign_SHA1(resp))
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
|
|
||||||
ctx.Header("X-Message-Sign", xMessageSign)
|
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, authResp)
|
ctx.JSON(http.StatusOK, authResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,9 +54,6 @@ func Login(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(loginResp)
|
resp, err := json.Marshal(loginResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
ctx.Header("user_id", "")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.JSON(http.StatusOK, loginResp)
|
ctx.JSON(http.StatusOK, loginResp)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -29,12 +26,6 @@ func MultiUnitStartUp(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(startResp)
|
resp, err := json.Marshal(startResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -49,12 +46,6 @@ func MuseumInfo(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(museumResp)
|
resp, err := json.Marshal(museumResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-24
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -25,13 +22,7 @@ func NoticeFriendVariety(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(noticeResp)
|
resp, err := json.Marshal(noticeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,13 +39,7 @@ func NoticeFriendGreeting(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(noticeResp)
|
resp, err := json.Marshal(noticeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,12 +57,6 @@ func NoticeUserGreeting(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(noticeResp)
|
resp, err := json.Marshal(noticeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -36,12 +33,6 @@ func ProductList(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(prodReesp)
|
resp, err := json.Marshal(prodReesp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -28,12 +25,6 @@ func PersonalNotice(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(noticeResp)
|
resp, err := json.Marshal(noticeResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(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))
|
body64, err := base64.StdEncoding.DecodeString(string(body))
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
decryptedBody := encrypt.RSA_Decrypt(body64)
|
decryptedBody := encrypt.RSADecrypt(body64)
|
||||||
// fmt.Println(decryptedBody)
|
// fmt.Println(decryptedBody)
|
||||||
// fmt.Println(string(decryptedBody))
|
// fmt.Println(string(decryptedBody))
|
||||||
|
|
||||||
|
|||||||
+1
-11
@@ -1,14 +1,10 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/tools"
|
"honoka-chan/tools"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
@@ -29,12 +25,6 @@ func ProfileRegister(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(profileResp)
|
resp, err := json.Marshal(profileResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(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("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("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))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
@@ -43,12 +43,6 @@ func ScenarioStartup(ctx *gin.Context) {
|
|||||||
func ScenarioReward(ctx *gin.Context) {
|
func ScenarioReward(ctx *gin.Context) {
|
||||||
resp := utils.ReadAllText("assets/sif/reward.json")
|
resp := utils.ReadAllText("assets/sif/reward.json")
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS([]byte(resp)))
|
||||||
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.String(http.StatusOK, resp)
|
ctx.String(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func SubScenarioStartup(ctx *gin.Context) {
|
|||||||
|
|
||||||
ctx.Header("user_id", ctx.GetString("userid"))
|
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("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))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
@@ -43,12 +43,6 @@ func SubScenarioStartup(ctx *gin.Context) {
|
|||||||
func SubScenarioReward(ctx *gin.Context) {
|
func SubScenarioReward(ctx *gin.Context) {
|
||||||
resp := utils.ReadAllText("assets/sif/subreward.json")
|
resp := utils.ReadAllText("assets/sif/subreward.json")
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS([]byte(resp)))
|
||||||
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.String(http.StatusOK, resp)
|
ctx.String(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -26,12 +23,6 @@ func TosCheck(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(tosResp)
|
resp, err := json.Marshal(tosResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-37
@@ -1,10 +1,8 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -22,13 +20,7 @@ func SetDisplayRank(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(dispResp)
|
resp, err := json.Marshal(dispResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,13 +157,7 @@ func SetDeck(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(dispResp)
|
resp, err := json.Marshal(dispResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,13 +193,7 @@ func SetDeckName(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(dispResp)
|
resp, err := json.Marshal(dispResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,13 +251,7 @@ func WearAccessory(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(wearResp)
|
resp, err := json.Marshal(wearResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,12 +310,6 @@ func RemoveSkillEquip(ctx *gin.Context) {
|
|||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
fmt.Println(string(resp))
|
fmt.Println(string(resp))
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-24
@@ -1,10 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/tools"
|
"honoka-chan/tools"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -23,13 +20,7 @@ func SetNotificationToken(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(notifResp)
|
resp, err := json.Marshal(notifResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,13 +39,7 @@ func ChangeNavi(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(naviResp)
|
resp, err := json.Marshal(naviResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,12 +69,6 @@ func ChangeName(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(nameResp)
|
resp, err := json.Marshal(nameResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -1,11 +1,8 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"honoka-chan/config"
|
"honoka-chan/config"
|
||||||
"honoka-chan/encrypt"
|
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/tools"
|
"honoka-chan/tools"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -71,12 +68,6 @@ func UserInfo(ctx *gin.Context) {
|
|||||||
resp, err := json.Marshal(userResp)
|
resp, err := json.Marshal(userResp)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
ctx.Header("X-Message-Sign", GenXMS(resp))
|
||||||
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.String(http.StatusOK, string(resp))
|
ctx.String(http.StatusOK, string(resp))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func AuthKey(ctx *gin.Context) {
|
|||||||
req := gjson.Parse(ctx.PostForm("request_data"))
|
req := gjson.Parse(ctx.PostForm("request_data"))
|
||||||
tDummyToken, err := base64.StdEncoding.DecodeString(req.Get("dummy_token").String())
|
tDummyToken, err := base64.StdEncoding.DecodeString(req.Get("dummy_token").String())
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
dummyToken := encrypt.RSA_Decrypt(tDummyToken)
|
dummyToken := encrypt.RSADecrypt(tDummyToken)
|
||||||
|
|
||||||
// aesKey := dummyToken[0:16]
|
// aesKey := dummyToken[0:16]
|
||||||
// tAuthData, err := base64.StdEncoding.DecodeString(req.Get("auth_data").String())
|
// 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.String(http.StatusForbidden, ErrorMsg)
|
||||||
ctx.Abort()
|
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")
|
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"))
|
req := gjson.Parse(ctx.GetString("request_data"))
|
||||||
tKey, err := base64.StdEncoding.DecodeString(req.Get("login_key").String())
|
tKey, err := base64.StdEncoding.DecodeString(req.Get("login_key").String())
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
loginKey := utils.Sub16(encrypt.AES_CBC_Decrypt(tKey, aesKey))
|
loginKey := utils.Sub16(encrypt.AESCBCDecrypt(tKey, aesKey))
|
||||||
ctx.Set("login_key", string(loginKey))
|
ctx.Set("login_key", string(loginKey))
|
||||||
|
|
||||||
tPasswd, err := base64.StdEncoding.DecodeString(req.Get("login_passwd").String())
|
tPasswd, err := base64.StdEncoding.DecodeString(req.Get("login_passwd").String())
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
loginPasswd := utils.Sub16(encrypt.AES_CBC_Decrypt(tPasswd, aesKey))
|
loginPasswd := utils.Sub16(encrypt.AESCBCDecrypt(tPasswd, aesKey))
|
||||||
ctx.Set("login_passwd", string(loginPasswd))
|
ctx.Set("login_passwd", string(loginPasswd))
|
||||||
|
|
||||||
nonce := ctx.GetInt("nonce")
|
nonce := ctx.GetInt("nonce")
|
||||||
@@ -41,5 +41,4 @@ func Login(ctx *gin.Context) {
|
|||||||
ctx.Set("authorize_token", authorizeToken)
|
ctx.Set("authorize_token", authorizeToken)
|
||||||
|
|
||||||
ctx.Next()
|
ctx.Next()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,3 +15,11 @@ type ApiResp struct {
|
|||||||
ReleaseInfo []any `json:"release_info"`
|
ReleaseInfo []any `json:"release_info"`
|
||||||
StatusCode int `json:"status_code"`
|
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