add hotfix support

This commit is contained in:
Eccentric 2024-01-04 19:02:14 +00:00
parent e3161d9524
commit a77e26502c
5 changed files with 57 additions and 7 deletions

View File

@ -29,7 +29,7 @@ port=":3000"
; host that the api is running on
; e.g. if you are running the api on your local machine, you would set this to 127.0.0.1
; if you are running the api on a server, you would set this to the ip of the server or the domain name
host="http://127.0.0.1"
host="127.0.0.1"
[jwt]
; secret for jwt signing

View File

@ -16,7 +16,7 @@ import (
func GetDiscordOAuthURL(c *fiber.Ctx) error {
code := c.Query("code")
if code == "" {
return c.Status(200).SendString("https://discord.com/oauth2/authorize?client_id="+ aid.Config.Discord.ID +"&redirect_uri="+ url.QueryEscape(aid.Config.API.Host + aid.Config.API.Port +"/snow/discord") + "&response_type=code&scope=identify")
return c.Status(200).SendString("https://discord.com/oauth2/authorize?client_id="+ aid.Config.Discord.ID +"&redirect_uri="+ url.QueryEscape("http://" + aid.Config.API.Host + aid.Config.API.Port +"/snow/discord") + "&response_type=code&scope=identify")
}
client := &http.Client{}
@ -26,7 +26,7 @@ func GetDiscordOAuthURL(c *fiber.Ctx) error {
"client_secret": {aid.Config.Discord.Secret},
"grant_type": {"authorization_code"},
"code": {code},
"redirect_uri": {aid.Config.API.Host + aid.Config.API.Port +"/snow/discord"},
"redirect_uri": {"http://" + aid.Config.API.Host + aid.Config.API.Port +"/snow/discord"},
})
if err != nil {
return c.Status(500).JSON(aid.JSON{"error":err.Error()})
@ -88,5 +88,5 @@ func GetDiscordOAuthURL(c *fiber.Ctx) error {
Name: "access_token",
Value: access,
})
return c.Redirect(aid.Config.API.Host + aid.Config.API.FrontendPort + "/attempt")
return c.Redirect("http://" + aid.Config.API.Host + aid.Config.API.FrontendPort + "/attempt")
}

View File

@ -76,7 +76,7 @@ func createPlaylist(mnemonic string, image string) aid.JSON {
func PostDiscovery(c *fiber.Ctx) error {
results := []aid.JSON{}
for playlist := range fortnite.PlaylistImages {
results = append(results, createPlaylist(playlist, aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999))))
results = append(results, createPlaylist(playlist, "https://" + aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999))))
}
results = append(results, createPlaylist("Playlist_DefaultSolo", "http://bucket.retrac.site/55737fa15677cd57fab9e7f4499d62f89cfde320.png"))
@ -158,7 +158,7 @@ func GetContentPages(c *fiber.Ctx) error {
playlists := []aid.JSON{}
for playlist := range fortnite.PlaylistImages {
playlists = append(playlists, aid.JSON{
"image": aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999)),
"image": "http://" +aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999)),
"playlist_name": playlist,
"hidden": false,
})

View File

@ -1,12 +1,32 @@
package handlers
import (
"crypto/sha1"
"crypto/sha256"
"encoding/hex"
"github.com/ectrc/snow/aid"
"github.com/ectrc/snow/storage"
"github.com/gofiber/fiber/v2"
)
func GetCloudStorageFiles(c *fiber.Ctx) error {
return c.Status(fiber.StatusOK).JSON([]aid.JSON{})
sum := sha1.Sum(storage.GetDefaultEngine())
more := sha256.Sum256(storage.GetDefaultEngine())
return c.Status(fiber.StatusOK).JSON([]aid.JSON{
{
"uniqueFilename": "DefaultEngine.ini",
"filename": "DefaultEngine.ini",
"hash": hex.EncodeToString(sum[:]),
"hash256": hex.EncodeToString(more[:]),
"length": len(storage.GetDefaultEngine()),
"contentType": "application/octet-stream",
"uploaded": "0000-00-00T00:00:00.000Z",
"storageType": "S3",
"doNotCache": false,
},
})
}
func GetCloudStorageConfig(c *fiber.Ctx) error {
@ -23,6 +43,11 @@ func GetCloudStorageConfig(c *fiber.Ctx) error {
}
func GetCloudStorageFile(c *fiber.Ctx) error {
switch c.Params("fileName") {
case "DefaultEngine.ini":
return c.Status(fiber.StatusOK).Send(storage.GetDefaultEngine())
}
return c.Status(400).JSON(aid.ErrorBadRequest)
}

25
storage/hotfix.go Normal file
View File

@ -0,0 +1,25 @@
package storage
import "github.com/ectrc/snow/aid"
func GetDefaultEngine() []byte {
return []byte(`
[OnlineSubsystemMcp]
bUsePartySystemV2=false
[OnlineSubsystemMcp.OnlinePartySystemMcpAdapter]
bUsePartySystemV2=false
[XMPP]
bEnableWebsockets=true
[OnlineSubsystemMcp.Xmpp]
bUseSSL=false
ServerAddr="ws://` + aid.Config.API.Host + `/socket/presence"
ServerPort=` + aid.Config.API.Port + `
[OnlineSubsystemMcp.Xmpp Prod]
bUseSSL=false
ServerAddr="ws://` + aid.Config.API.Host + `/socket/presence"
ServerPort=` + aid.Config.API.Port + ``)
}