mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2025-12-10 13:49:39 +05:00
also retry requests if connection closed; add /_/info endpoint
This commit is contained in:
@@ -18,6 +18,9 @@ const ImageCacheControl = "max-age=600; public" // 10 minutes by default, only u
|
||||
// proxy streams (hls playlist files and track parts)
|
||||
const ProxyStreams = false
|
||||
|
||||
// enable /_/info endpoint (shows if some settings are enabled/disabled)
|
||||
const InstanceInfo = true
|
||||
|
||||
// time-to-live for clientid cache
|
||||
// larger number will improve performance (no need to recheck everytime) but might make soundcloak briefly unusable for a larger amount of time if the client id is invalidated
|
||||
const ClientIDTTL = 30 * time.Minute
|
||||
|
||||
@@ -123,7 +123,7 @@ func DoWithRetry(httpc *fasthttp.HostClient, req *fasthttp.Request, resp *fastht
|
||||
return nil
|
||||
}
|
||||
|
||||
if !os.IsTimeout(err) && err != fasthttp.ErrTimeout {
|
||||
if !os.IsTimeout(err) && err != fasthttp.ErrTimeout && err != fasthttp.ErrConnectionClosed {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
22
main.go
22
main.go
@@ -142,6 +142,28 @@ func main() {
|
||||
proxystreams.Load(app)
|
||||
}
|
||||
|
||||
if cfg.InstanceInfo {
|
||||
type info struct {
|
||||
ProxyImages bool
|
||||
ProxyStreams bool
|
||||
FullyPreloadTrack bool
|
||||
}
|
||||
|
||||
data, err := cfg.JSON.Marshal(info{
|
||||
ProxyImages: cfg.ProxyImages,
|
||||
ProxyStreams: cfg.ProxyStreams,
|
||||
FullyPreloadTrack: cfg.FullyPreloadTrack,
|
||||
})
|
||||
if err != nil {
|
||||
log.Println("Failed to marshal instance info:", err)
|
||||
}
|
||||
|
||||
app.Get("/_/info", func(c *fiber.Ctx) error {
|
||||
c.Set("Content-Type", "application/json")
|
||||
return c.Send(data)
|
||||
})
|
||||
}
|
||||
|
||||
app.Get("/:user/sets", func(c *fiber.Ctx) error {
|
||||
user, err := sc.GetUser(c.Params("user"))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user