Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import (
"context"
_ "embed"
"fmt"
"math/rand"
"net"
"net/http"
"net/http/httputil"
"net/url"
"os"
"os/signal"
"reflect"
Expand Down Expand Up @@ -595,6 +598,25 @@ func NewApiServer(config config.Config) *ApiServer {
// Unsplash proxy
app.All("/unsplash/*", app.unsplash)

// Archiver proxy
if len(config.ArchiverNodes) > 0 {
app.All("/archive/*", func(c *fiber.Ctx) error {
randIdx := rand.Intn(len(config.ArchiverNodes))
upstreamUrl := config.ArchiverNodes[randIdx]
upstream, err := url.Parse(upstreamUrl)
if err != nil {
return fiber.NewError(fiber.StatusBadGateway, "Invalid Archiver upstream url")
}
proxy := httputil.NewSingleHostReverseProxy(upstream)
origDirector := proxy.Director
proxy.Director = func(req *http.Request) {
origDirector(req)
req.Host = upstream.Host
}
return adaptor.HTTPHandler(proxy)(c)
})
}

app.Static("/", "./static")

// Disable swagger in test environments, because it will slow things down a lot
Expand Down
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
NetworkTakeRate float64
SolanaConfig SolanaConfig
AntiAbuseOracles []string
ArchiverNodes []string
Rewards []rewards.Reward
AudiusdURL string
OpenAudioURLs []string
Expand Down Expand Up @@ -99,6 +100,7 @@ func init() {
Cfg.DelegatePrivateKey = "13422b9affd75ff80f94f1ea394e6a6097830cb58cda2d3542f37464ecaee7df"
}
Cfg.AntiAbuseOracles = []string{"http://audius-discovery-provider-1"}
Cfg.ArchiverNodes = []string{"http://audius-discovery-provider-1"}
Cfg.Rewards = core_config.MakeRewards(core_config.DevClaimAuthorities, core_config.DevRewardExtensions)
Cfg.AudiusdURL = "http://audius-creator-node-1"
Cfg.ChainId = "audius-devnet"
Expand All @@ -121,6 +123,7 @@ func init() {
log.Fatalf("Missing required %s env var: delegatePrivateKey", env)
}
Cfg.AntiAbuseOracles = []string{"https://discoveryprovider.staging.audius.co"}
Cfg.ArchiverNodes = []string{"https://discoveryprovider.staging.audius.co"}
Cfg.DeadNodes = []string{}
Cfg.StoreAllNodes = []string{}
Cfg.UploadNodes = StageUploadNodes
Expand Down Expand Up @@ -162,6 +165,7 @@ func init() {
log.Fatalf("Missing required %s env var: delegatePrivateKey", env)
}
Cfg.AntiAbuseOracles = []string{"https://discoveryprovider.audius.co"}
Cfg.ArchiverNodes = []string{"https://discoveryprovider.audius.co"}
Cfg.DeadNodes = []string{
"https://content.grassfed.network",
}
Expand Down