-
Notifications
You must be signed in to change notification settings - Fork 35
Request caching + add ratelimit-over-408 + endpoint rewrite support #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cheesycod
wants to merge
29
commits into
germanoeich:main
Choose a base branch
from
Anti-Raid:nirn-backports
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
98a7571
add antiraid-specific get gateway patch
3d26a93
proxy more
78d9a35
caching
ea5bc3d
fix
9274dbe
fix
c838583
Merge pull request #1 from Anti-Raid/main
cheesycod 73623aa
add wsProxy support better
003174a
.
af34aac
d
w-zz-w-zz-w c15e05c
Merge branch 'germanoeich:main' into development
cheesycod 3bc2e30
add support for ratelimit-over-408
cheesycod 51e6ac5
fix headers
cheesycod a13a893
set scope on 408 rls to shared
cheesycod f6785b5
Update discord.go
cheesycod a0b231d
Update lib/discord.go
cheesycod 0549e99
Revert queue change
cheesycod 1fe163f
Update lib/discord.go
cheesycod e67bf8b
Update discord.go with antiraid changes
cheesycod ffb5587
Update discord.go
cheesycod 7c10e17
Update lib/discord.go
cheesycod 4e8fed9
Update discord.go
cheesycod 39e8929
Update discord.go
cheesycod 6c0b85c
Update discord.go
cheesycod 1825863
Update cache.go
cheesycod eb33179
fix compile errors
cheesycod c04ae68
Delete Makefile
cheesycod 401676c
Update discord.go
cheesycod 4d8989e
Update lib/discord.go
cheesycod 8f86027
Update lib/discord.go
cheesycod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| nirn-proxy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package lib | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "time" | ||
| ) | ||
|
|
||
| type CacheEntry struct { | ||
| Data []byte | ||
| CreatedAt time.Time | ||
| ExpiresIn time.Duration | ||
| Headers http.Header | ||
| } | ||
|
|
||
| func (c *CacheEntry) Expired() bool { | ||
| return time.Since(c.CreatedAt) > c.ExpiresIn | ||
| } | ||
|
|
||
| type Cache struct { | ||
| entries map[string]*CacheEntry | ||
| } | ||
|
|
||
| func NewCache() *Cache { | ||
| return &Cache{ | ||
| entries: make(map[string]*CacheEntry), | ||
| } | ||
| } | ||
|
|
||
| func (c *Cache) Get(key string) *CacheEntry { | ||
| entry, ok := c.entries[key] | ||
|
|
||
| if !ok { | ||
| return nil | ||
| } | ||
|
|
||
| if entry.Expired() { | ||
| c.Delete(key) | ||
| return nil | ||
| } | ||
|
|
||
| return entry | ||
| } | ||
|
|
||
| func (c *Cache) Set(key string, entry *CacheEntry) { | ||
| c.entries[key] = entry | ||
| } | ||
|
|
||
| func (c *Cache) Delete(key string) { | ||
| delete(c.entries, key) | ||
| } | ||
|
|
||
| func (c *Cache) Clear() { | ||
| c.entries = make(map[string]*CacheEntry) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.