proxy

package
v1.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2022 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const StatsGetWorkers = 5

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedResponse added in v1.8.0

type CachedResponse struct {
	// contains filtered or unexported fields
}

type CachingResponseWriter

type CachingResponseWriter struct {
	// contains filtered or unexported fields
}

func (*CachingResponseWriter) Header

func (rw *CachingResponseWriter) Header() http.Header

func (*CachingResponseWriter) Write

func (rw *CachingResponseWriter) Write(data []byte) (int, error)

func (*CachingResponseWriter) WriteHeader

func (rw *CachingResponseWriter) WriteHeader(statusCode int)

type PredictionState

type PredictionState int

type Rating added in v1.10.0

type Rating struct {
	Value     float64
	Deviation float64
}

type RatingUpdate added in v1.10.0

type RatingUpdate struct {
	// contains filtered or unexported fields
}

func NewRatingUpdate added in v1.10.0

func NewRatingUpdate() *RatingUpdate

func (*RatingUpdate) FetchRatings added in v1.10.0

func (ru *RatingUpdate) FetchRatings(userID uint64) (Ratings, error)

func (*RatingUpdate) InjectRating added in v1.10.0

func (ru *RatingUpdate) InjectRating(next http.Handler, w http.ResponseWriter, r *http.Request)

func (*RatingUpdate) RatingUpdateHandler added in v1.10.0

func (ru *RatingUpdate) RatingUpdateHandler(next http.Handler) http.Handler

type Ratings added in v1.10.0

type Ratings []Rating

type ResponseCache added in v1.8.0

type ResponseCache struct {
	// contains filtered or unexported fields
}

func (*ResponseCache) AddResponse added in v1.8.0

func (c *ResponseCache) AddResponse(request string, response *http.Response, body []byte)

func (*ResponseCache) GetResponse added in v1.8.0

func (c *ResponseCache) GetResponse(request string) (http.Response, []byte)

func (*ResponseCache) RemoveResponse added in v1.8.0

func (c *ResponseCache) RemoveResponse(request string)

func (*ResponseCache) ResponseExists added in v1.8.0

func (c *ResponseCache) ResponseExists(request string) bool

type StatsGetPrediction

type StatsGetPrediction struct {
	GGStriveAPIURL string

	PredictReplay bool
	// contains filtered or unexported fields
}

func CreateStatsGetPrediction

func CreateStatsGetPrediction(GGStriveAPIURL string, client *http.Client, responseCache *ResponseCache) StatsGetPrediction

func (*StatsGetPrediction) AsyncGetStats

func (s *StatsGetPrediction) AsyncGetStats(body []byte, reqType StatsGetType)

func (*StatsGetPrediction) HandleGetStats

func (s *StatsGetPrediction) HandleGetStats(w http.ResponseWriter, r *http.Request) bool

Proxy getstats

func (*StatsGetPrediction) ProcessStatsQueue

func (s *StatsGetPrediction) ProcessStatsQueue(queue chan *StatsGetTask)

Process the filled queue, then exit when it's empty

func (*StatsGetPrediction) StatsGetStateHandler

func (s *StatsGetPrediction) StatsGetStateHandler(next http.Handler) http.Handler

type StatsGetTask

type StatsGetTask struct {
	// contains filtered or unexported fields
}

func ExpectedRCodeCalls added in v1.5.0

func ExpectedRCodeCalls() []StatsGetTask

func ExpectedTitleScreenCalls added in v1.5.0

func ExpectedTitleScreenCalls() []StatsGetTask

type StatsGetType added in v1.6.0

type StatsGetType int

type StriveAPIProxy

type StriveAPIProxy struct {
	Client         *http.Client
	Server         *http.Server
	GGStriveAPIURL string
	PatchedAPIURL  string

	CacheEnv bool
	// contains filtered or unexported fields
}

func CreateStriveProxy

func CreateStriveProxy(listen string, GGStriveAPIURL string, PatchedAPIURL string, options *StriveAPIProxyOptions) *StriveAPIProxy

func (*StriveAPIProxy) CacheInvalidationHandler added in v1.8.0

func (s *StriveAPIProxy) CacheInvalidationHandler(next http.Handler) http.Handler

Invalidate cache if certain requests are used

func (*StriveAPIProxy) HandleCachedRequest added in v1.8.0

func (s *StriveAPIProxy) HandleCachedRequest(request string, w http.ResponseWriter, r *http.Request)

Generic handler func for cached requests

func (*StriveAPIProxy) HandleCatchall

func (s *StriveAPIProxy) HandleCatchall(w http.ResponseWriter, r *http.Request)

Proxy everything else

func (*StriveAPIProxy) HandleGetBlock added in v1.8.0

func (s *StriveAPIProxy) HandleGetBlock(w http.ResponseWriter, r *http.Request)

UNSAFE: Cache get_block on first request. On every other request return the cached value.

func (*StriveAPIProxy) HandleGetEnv

func (s *StriveAPIProxy) HandleGetEnv(w http.ResponseWriter, r *http.Request)

GGST uses the URL from this API after initial launch so we need to intercept this.

func (*StriveAPIProxy) HandleGetFollow added in v1.8.0

func (s *StriveAPIProxy) HandleGetFollow(w http.ResponseWriter, r *http.Request)

UNSAFE: Cache get_follow on first request. On every other request return the cached value.

func (*StriveAPIProxy) HandleGetNews added in v1.3.0

func (s *StriveAPIProxy) HandleGetNews(w http.ResponseWriter, r *http.Request)

UNSAFE: Cache news on first request. On every other request return the cached value.

func (*StriveAPIProxy) HandleStatsSet

func (s *StriveAPIProxy) HandleStatsSet(w http.ResponseWriter, r *http.Request)

UNSAFE HandleStatsSet is the handler for buffered stats/set so the stats can be flushed asynchronously from the game.

func (*StriveAPIProxy) Shutdown

func (s *StriveAPIProxy) Shutdown()

type StriveAPIProxyOptions

type StriveAPIProxyOptions struct {
	AsyncStatsSet   bool
	PredictStatsGet bool
	CacheNews       bool
	NoNews          bool
	PredictReplay   bool
	CacheEnv        bool
	CacheFollow     bool
	RatingUpdate    bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL