changed param logic & add more routes
This commit is contained in:
@@ -9,9 +9,10 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
path := routes.PathOf()
|
||||
routes.Register(func(app *fiber.App) {
|
||||
app.Get("/api/acdm/:userid", acdm)
|
||||
fmt.Println("Loaded: /api/acdm/:userid")
|
||||
app.Post(path, acdm)
|
||||
fmt.Println("Loaded:", path)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ func application(c *fiber.Ctx) error {
|
||||
url := fmt.Sprintf("%s/api/application", upstream.BaseUrl())
|
||||
data, err := upstream.Fetch(url, headers)
|
||||
if err != nil {
|
||||
// fallback 到 cache
|
||||
data, err = os.ReadFile(cachePath)
|
||||
if err != nil {
|
||||
return c.Status(500).SendString("no cache available")
|
||||
|
||||
@@ -41,7 +41,6 @@ func cleanupinfo(c *fiber.Ctx) error {
|
||||
url := fmt.Sprintf("%s/api/application", upstream.BaseUrl())
|
||||
data, err := upstream.Fetch(url, headers)
|
||||
if err != nil {
|
||||
// fallback 到 cache
|
||||
data, err = os.ReadFile(cachePath)
|
||||
if err != nil {
|
||||
return c.Status(500).SendString("no cache available")
|
||||
|
||||
@@ -41,7 +41,6 @@ func application(c *fiber.Ctx) error {
|
||||
url := fmt.Sprintf("%s/api/information/overview", upstream.BaseUrl())
|
||||
data, err := upstream.Fetch(url, headers)
|
||||
if err != nil {
|
||||
// fallback 到 cache
|
||||
data, err = os.ReadFile(cachePath)
|
||||
if err != nil {
|
||||
return c.Status(500).SendString("no cache available")
|
||||
|
||||
49
routes/api/missionreward.map.go
Normal file
49
routes/api/missionreward.map.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"bdgrp_go/routes"
|
||||
"bdgrp_go/routes/upstream"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
path := routes.PathOf()
|
||||
routes.Register(func(app *fiber.App) {
|
||||
app.Get(path, rewardmap)
|
||||
fmt.Println("Loaded:", path)
|
||||
})
|
||||
}
|
||||
|
||||
func rewardmap(c *fiber.Ctx) error {
|
||||
server := os.Getenv("SERVER")
|
||||
cachePath := filepath.Join("resp", server, "config.binpb")
|
||||
|
||||
headers := map[string]string{
|
||||
"User-Agent": c.Get("User-Agent"),
|
||||
"Content-Type": c.Get("Content-Type"),
|
||||
"Accept": c.Get("Accept"),
|
||||
"Accept-Encoding": c.Get("Accept-Encoding"),
|
||||
"x-clientversion": c.Get("x-clientversion"),
|
||||
"x-platformid": c.Get("x-platformid"),
|
||||
"x-deviceid": c.Get("x-deviceid"),
|
||||
"x-channelid": c.Get("x-channelid"),
|
||||
"x-clientplatform": c.Get("x-clientplatform"),
|
||||
}
|
||||
|
||||
data, err := upstream.Fetch("https://l3-prod-all-bd.bilibiligame.net/api/missionreward.map", headers)
|
||||
if err != nil {
|
||||
data, err = os.ReadFile(cachePath)
|
||||
if err != nil {
|
||||
return c.Status(500).SendString("no cache available")
|
||||
}
|
||||
} else {
|
||||
os.WriteFile(cachePath, data, 0644)
|
||||
}
|
||||
|
||||
return c.Send(data)
|
||||
}
|
||||
21
routes/api/multiroom.go
Normal file
21
routes/api/multiroom.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"bdgrp_go/routes"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
path := routes.PathOf()
|
||||
routes.Register(func(app *fiber.App) {
|
||||
app.Post(path, multiroom)
|
||||
fmt.Println("Loaded:", path)
|
||||
})
|
||||
}
|
||||
|
||||
func multiroom(c *fiber.Ctx) error {
|
||||
return c.SendString("")
|
||||
}
|
||||
55
routes/api/suite/master.go
Normal file
55
routes/api/suite/master.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package suite
|
||||
|
||||
import (
|
||||
mastermanager "bdgrp_go/master"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"bdgrp_go/routes"
|
||||
"bdgrp_go/routes/upstream"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
path := routes.PathOf()
|
||||
routes.Register(func(app *fiber.App) {
|
||||
app.Get(path, master)
|
||||
fmt.Println("Loaded:", path)
|
||||
})
|
||||
}
|
||||
|
||||
func master(c *fiber.Ctx) error {
|
||||
server := os.Getenv("SERVER")
|
||||
cachePath := filepath.Join("resp", server, "suitemaster.bz2")
|
||||
|
||||
headers := map[string]string{
|
||||
"User-Agent": c.Get("User-Agent"),
|
||||
"Content-Type": c.Get("Content-Type"),
|
||||
"Accept": c.Get("Accept"),
|
||||
"Accept-Encoding": c.Get("Accept-Encoding"),
|
||||
"x-clientversion": c.Get("x-clientversion"),
|
||||
}
|
||||
|
||||
if server == "CN" {
|
||||
headers["x-platformid"] = c.Get("x-platformid")
|
||||
headers["x-deviceid"] = c.Get("x-deviceid")
|
||||
headers["x-channelid"] = c.Get("x-channelid")
|
||||
headers["x-clientplatform"] = c.Get("x-clientplatform")
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/api/suite/master", upstream.BaseUrl())
|
||||
data, err := upstream.Fetch(url, headers)
|
||||
if err != nil {
|
||||
data, err = os.ReadFile(cachePath)
|
||||
if err != nil {
|
||||
return c.Status(500).SendString("no cache available")
|
||||
}
|
||||
} else {
|
||||
os.WriteFile(cachePath, data, 0644)
|
||||
mastermanager.ReloadMaster()
|
||||
}
|
||||
|
||||
return c.Send(data)
|
||||
}
|
||||
@@ -37,7 +37,6 @@ func config(c *fiber.Ctx) error {
|
||||
|
||||
data, err := upstream.Fetch("https://l3-prod-all-bd.bilibiligame.net/api/system/config", headers)
|
||||
if err != nil {
|
||||
// fallback 到 cache
|
||||
data, err = os.ReadFile(cachePath)
|
||||
if err != nil {
|
||||
return c.Status(500).SendString("no cache available")
|
||||
|
||||
21
routes/api/track.go
Normal file
21
routes/api/track.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"bdgrp_go/routes"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
path := routes.PathOf()
|
||||
routes.Register(func(app *fiber.App) {
|
||||
app.Get(path, track)
|
||||
fmt.Println("Loaded:", path)
|
||||
})
|
||||
}
|
||||
|
||||
func track(c *fiber.Ctx) error {
|
||||
return c.SendString("")
|
||||
}
|
||||
38
routes/api/validation/ngword.go
Normal file
38
routes/api/validation/ngword.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package validation
|
||||
|
||||
import (
|
||||
"bdgrp_go/pbutil"
|
||||
"bdgrp_go/routes"
|
||||
"bdgrp_go/utils"
|
||||
"fmt"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
path := routes.PathOf()
|
||||
routes.Register(func(app *fiber.App) {
|
||||
app.Post(path, ngword)
|
||||
fmt.Println("Loaded:", path)
|
||||
})
|
||||
}
|
||||
|
||||
func ngword(c *fiber.Ctx) error {
|
||||
data := map[string]any{
|
||||
"isBadWord": false,
|
||||
}
|
||||
|
||||
encoded, err := pbutil.Encode("NgWordResponse", data)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return c.Status(500).SendString("")
|
||||
}
|
||||
|
||||
encrypted, err := utils.Encrypt(encoded)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
return c.Send(encrypted)
|
||||
}
|
||||
Reference in New Issue
Block a user